]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.2-201312011111.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.2-201312011111.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 e6e72b6..570e70a 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 define filechk_kernel.release
403 @@ -838,6 +900,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -945,6 +1008,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -960,7 +1025,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1026,7 +1091,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1066,6 +1131,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1227,6 +1293,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1366,17 +1434,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1386,11 +1458,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 98838a0..b304fb4 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 1ad6fb6..4e7fae5 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1832,7 +1832,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 15f2d5b..43ffa53 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index f4b46d3..abc9b2b 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index f94784f..41c7f61 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __do_const;
1803
1804 extern struct outer_cache_fns outer_cache;
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index be956db..c8f25e2 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index df5e13d..97efb82 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -88,9 +88,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -163,7 +163,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -176,10 +180,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 72abdc5..9eba222 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #if __LINUX_ARM_ARCH__ < 6
2148 #include <asm-generic/uaccess-unaligned.h>
2149 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -195,8 +227,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -237,13 +273,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -319,13 +359,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -425,11 +469,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -438,6 +515,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -447,6 +527,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index bc6bd96..bd026cb 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index 39f89fb..d612bd9 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 476de57..4857a76 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 084dc88..fce4e68 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index 0e1e2b3..c0e821d 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 72024ea..ae302dd 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index 8fcda14..4512b9d 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -628,7 +633,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -885,7 +892,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 9c697db..115237f 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index 1767611..d2e7e24 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index 579697a..1d5a3b2 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static int gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index b69dd9a..70e5409 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index 3d5db8c..ddfa144 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index b82dcae..44ee5b6 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index 656324a..0beba28 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 84e6f77..0b52f31 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index eb8830a..5360ce7 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3801 + if (addr < TASK_SIZE) {
3802 + if (current->signal->curr_ip)
3803 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3804 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3805 + else
3806 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3808 + }
3809 +#endif
3810 +
3811 +#ifdef CONFIG_PAX_KERNEXEC
3812 + if ((fsr & FSR_WRITE) &&
3813 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3814 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3815 + {
3816 + if (current->signal->curr_ip)
3817 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3818 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3819 + else
3820 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3821 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3822 + }
3823 +#endif
3824 +
3825 /*
3826 * No handler, we'll have to terminate things with extreme prejudice.
3827 */
3828 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3829 }
3830 #endif
3831
3832 +#ifdef CONFIG_PAX_PAGEEXEC
3833 + if (fsr & FSR_LNX_PF) {
3834 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3835 + do_group_exit(SIGKILL);
3836 + }
3837 +#endif
3838 +
3839 tsk->thread.address = addr;
3840 tsk->thread.error_code = fsr;
3841 tsk->thread.trap_no = 14;
3842 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3843 }
3844 #endif /* CONFIG_MMU */
3845
3846 +#ifdef CONFIG_PAX_PAGEEXEC
3847 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3848 +{
3849 + long i;
3850 +
3851 + printk(KERN_ERR "PAX: bytes at PC: ");
3852 + for (i = 0; i < 20; i++) {
3853 + unsigned char c;
3854 + if (get_user(c, (__force unsigned char __user *)pc+i))
3855 + printk(KERN_CONT "?? ");
3856 + else
3857 + printk(KERN_CONT "%02x ", c);
3858 + }
3859 + printk("\n");
3860 +
3861 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3862 + for (i = -1; i < 20; i++) {
3863 + unsigned long c;
3864 + if (get_user(c, (__force unsigned long __user *)sp+i))
3865 + printk(KERN_CONT "???????? ");
3866 + else
3867 + printk(KERN_CONT "%08lx ", c);
3868 + }
3869 + printk("\n");
3870 +}
3871 +#endif
3872 +
3873 /*
3874 * First Level Translation Fault Handler
3875 *
3876 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3877 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3878 struct siginfo info;
3879
3880 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3881 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3882 + if (current->signal->curr_ip)
3883 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3884 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3885 + else
3886 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3887 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3888 + goto die;
3889 + }
3890 +#endif
3891 +
3892 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3893 return;
3894
3895 +die:
3896 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3897 inf->name, fsr, addr);
3898
3899 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3900 ifsr_info[nr].name = name;
3901 }
3902
3903 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3904 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3905 +
3906 asmlinkage void __exception
3907 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3908 {
3909 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3910 struct siginfo info;
3911 + unsigned long pc = instruction_pointer(regs);
3912 +
3913 + if (user_mode(regs)) {
3914 + unsigned long sigpage = current->mm->context.sigpage;
3915 +
3916 + if (sigpage <= pc && pc < sigpage + 7*4) {
3917 + if (pc < sigpage + 3*4)
3918 + sys_sigreturn(regs);
3919 + else
3920 + sys_rt_sigreturn(regs);
3921 + return;
3922 + }
3923 + if (pc == 0xffff0f60UL) {
3924 + /*
3925 + * PaX: __kuser_cmpxchg64 emulation
3926 + */
3927 + // TODO
3928 + //regs->ARM_pc = regs->ARM_lr;
3929 + //return;
3930 + }
3931 + if (pc == 0xffff0fa0UL) {
3932 + /*
3933 + * PaX: __kuser_memory_barrier emulation
3934 + */
3935 + // dmb(); implied by the exception
3936 + regs->ARM_pc = regs->ARM_lr;
3937 + return;
3938 + }
3939 + if (pc == 0xffff0fc0UL) {
3940 + /*
3941 + * PaX: __kuser_cmpxchg emulation
3942 + */
3943 + // TODO
3944 + //long new;
3945 + //int op;
3946 +
3947 + //op = FUTEX_OP_SET << 28;
3948 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3949 + //regs->ARM_r0 = old != new;
3950 + //regs->ARM_pc = regs->ARM_lr;
3951 + //return;
3952 + }
3953 + if (pc == 0xffff0fe0UL) {
3954 + /*
3955 + * PaX: __kuser_get_tls emulation
3956 + */
3957 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3958 + regs->ARM_pc = regs->ARM_lr;
3959 + return;
3960 + }
3961 + }
3962 +
3963 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3964 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3965 + if (current->signal->curr_ip)
3966 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3967 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3968 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3969 + else
3970 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3971 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3972 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3973 + goto die;
3974 + }
3975 +#endif
3976 +
3977 +#ifdef CONFIG_PAX_REFCOUNT
3978 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3979 + unsigned int bkpt;
3980 +
3981 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3982 + current->thread.error_code = ifsr;
3983 + current->thread.trap_no = 0;
3984 + pax_report_refcount_overflow(regs);
3985 + fixup_exception(regs);
3986 + return;
3987 + }
3988 + }
3989 +#endif
3990
3991 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3992 return;
3993
3994 +die:
3995 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3996 inf->name, ifsr, addr);
3997
3998 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3999 index cf08bdf..772656c 100644
4000 --- a/arch/arm/mm/fault.h
4001 +++ b/arch/arm/mm/fault.h
4002 @@ -3,6 +3,7 @@
4003
4004 /*
4005 * Fault status register encodings. We steal bit 31 for our own purposes.
4006 + * Set when the FSR value is from an instruction fault.
4007 */
4008 #define FSR_LNX_PF (1 << 31)
4009 #define FSR_WRITE (1 << 11)
4010 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4011 }
4012 #endif
4013
4014 +/* valid for LPAE and !LPAE */
4015 +static inline int is_xn_fault(unsigned int fsr)
4016 +{
4017 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4018 +}
4019 +
4020 +static inline int is_domain_fault(unsigned int fsr)
4021 +{
4022 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4023 +}
4024 +
4025 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4026 unsigned long search_exception_table(unsigned long addr);
4027
4028 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4029 index 18ec4c5..479bb6a 100644
4030 --- a/arch/arm/mm/init.c
4031 +++ b/arch/arm/mm/init.c
4032 @@ -30,6 +30,8 @@
4033 #include <asm/setup.h>
4034 #include <asm/tlb.h>
4035 #include <asm/fixmap.h>
4036 +#include <asm/system_info.h>
4037 +#include <asm/cp15.h>
4038
4039 #include <asm/mach/arch.h>
4040 #include <asm/mach/map.h>
4041 @@ -684,7 +686,46 @@ void free_initmem(void)
4042 {
4043 #ifdef CONFIG_HAVE_TCM
4044 extern char __tcm_start, __tcm_end;
4045 +#endif
4046
4047 +#ifdef CONFIG_PAX_KERNEXEC
4048 + unsigned long addr;
4049 + pgd_t *pgd;
4050 + pud_t *pud;
4051 + pmd_t *pmd;
4052 + int cpu_arch = cpu_architecture();
4053 + unsigned int cr = get_cr();
4054 +
4055 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4056 + /* make pages tables, etc before .text NX */
4057 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4058 + pgd = pgd_offset_k(addr);
4059 + pud = pud_offset(pgd, addr);
4060 + pmd = pmd_offset(pud, addr);
4061 + __section_update(pmd, addr, PMD_SECT_XN);
4062 + }
4063 + /* make init NX */
4064 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make kernel code/rodata RX */
4071 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 +#ifdef CONFIG_ARM_LPAE
4076 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4077 +#else
4078 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4079 +#endif
4080 + }
4081 + }
4082 +#endif
4083 +
4084 +#ifdef CONFIG_HAVE_TCM
4085 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4086 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4087 #endif
4088 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4089 index f123d6e..04bf569 100644
4090 --- a/arch/arm/mm/ioremap.c
4091 +++ b/arch/arm/mm/ioremap.c
4092 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4093 unsigned int mtype;
4094
4095 if (cached)
4096 - mtype = MT_MEMORY;
4097 + mtype = MT_MEMORY_RX;
4098 else
4099 - mtype = MT_MEMORY_NONCACHED;
4100 + mtype = MT_MEMORY_NONCACHED_RX;
4101
4102 return __arm_ioremap_caller(phys_addr, size, mtype,
4103 __builtin_return_address(0));
4104 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4105 index 0c63562..7128a90 100644
4106 --- a/arch/arm/mm/mmap.c
4107 +++ b/arch/arm/mm/mmap.c
4108 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4109 struct vm_area_struct *vma;
4110 int do_align = 0;
4111 int aliasing = cache_is_vipt_aliasing();
4112 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4113 struct vm_unmapped_area_info info;
4114
4115 /*
4116 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4117 if (len > TASK_SIZE)
4118 return -ENOMEM;
4119
4120 +#ifdef CONFIG_PAX_RANDMMAP
4121 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4122 +#endif
4123 +
4124 if (addr) {
4125 if (do_align)
4126 addr = COLOUR_ALIGN(addr, pgoff);
4127 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4128 addr = PAGE_ALIGN(addr);
4129
4130 vma = find_vma(mm, addr);
4131 - if (TASK_SIZE - len >= addr &&
4132 - (!vma || addr + len <= vma->vm_start))
4133 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4134 return addr;
4135 }
4136
4137 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 info.high_limit = TASK_SIZE;
4139 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4140 info.align_offset = pgoff << PAGE_SHIFT;
4141 + info.threadstack_offset = offset;
4142 return vm_unmapped_area(&info);
4143 }
4144
4145 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4146 unsigned long addr = addr0;
4147 int do_align = 0;
4148 int aliasing = cache_is_vipt_aliasing();
4149 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4150 struct vm_unmapped_area_info info;
4151
4152 /*
4153 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4154 return addr;
4155 }
4156
4157 +#ifdef CONFIG_PAX_RANDMMAP
4158 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4159 +#endif
4160 +
4161 /* requesting a specific address */
4162 if (addr) {
4163 if (do_align)
4164 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4165 else
4166 addr = PAGE_ALIGN(addr);
4167 vma = find_vma(mm, addr);
4168 - if (TASK_SIZE - len >= addr &&
4169 - (!vma || addr + len <= vma->vm_start))
4170 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4171 return addr;
4172 }
4173
4174 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4175 info.high_limit = mm->mmap_base;
4176 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4177 info.align_offset = pgoff << PAGE_SHIFT;
4178 + info.threadstack_offset = offset;
4179 addr = vm_unmapped_area(&info);
4180
4181 /*
4182 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4183 {
4184 unsigned long random_factor = 0UL;
4185
4186 +#ifdef CONFIG_PAX_RANDMMAP
4187 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4188 +#endif
4189 +
4190 /* 8 bits of randomness in 20 address space bits */
4191 if ((current->flags & PF_RANDOMIZE) &&
4192 !(current->personality & ADDR_NO_RANDOMIZE))
4193 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4194
4195 if (mmap_is_legacy()) {
4196 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4197 +
4198 +#ifdef CONFIG_PAX_RANDMMAP
4199 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4200 + mm->mmap_base += mm->delta_mmap;
4201 +#endif
4202 +
4203 mm->get_unmapped_area = arch_get_unmapped_area;
4204 } else {
4205 mm->mmap_base = mmap_base(random_factor);
4206 +
4207 +#ifdef CONFIG_PAX_RANDMMAP
4208 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4209 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4210 +#endif
4211 +
4212 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4213 }
4214 }
4215 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4216 index b1d17ee..7a6f4d3 100644
4217 --- a/arch/arm/mm/mmu.c
4218 +++ b/arch/arm/mm/mmu.c
4219 @@ -36,6 +36,22 @@
4220 #include "mm.h"
4221 #include "tcm.h"
4222
4223 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4224 +void modify_domain(unsigned int dom, unsigned int type)
4225 +{
4226 + struct thread_info *thread = current_thread_info();
4227 + unsigned int domain = thread->cpu_domain;
4228 + /*
4229 + * DOMAIN_MANAGER might be defined to some other value,
4230 + * use the arch-defined constant
4231 + */
4232 + domain &= ~domain_val(dom, 3);
4233 + thread->cpu_domain = domain | domain_val(dom, type);
4234 + set_domain(thread->cpu_domain);
4235 +}
4236 +EXPORT_SYMBOL(modify_domain);
4237 +#endif
4238 +
4239 /*
4240 * empty_zero_page is a special page that is used for
4241 * zero-initialized data and COW.
4242 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4243
4244 #endif /* ifdef CONFIG_CPU_CP15 / else */
4245
4246 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4247 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4248 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4249
4250 -static struct mem_type mem_types[] = {
4251 +#ifdef CONFIG_PAX_KERNEXEC
4252 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4253 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4254 +#else
4255 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4256 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4257 +#endif
4258 +
4259 +static struct mem_type mem_types[] __read_only = {
4260 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4261 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4262 L_PTE_SHARED,
4263 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4264 [MT_UNCACHED] = {
4265 .prot_pte = PROT_PTE_DEVICE,
4266 .prot_l1 = PMD_TYPE_TABLE,
4267 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4268 + .prot_sect = PROT_SECT_DEVICE,
4269 .domain = DOMAIN_IO,
4270 },
4271 [MT_CACHECLEAN] = {
4272 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4273 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4274 .domain = DOMAIN_KERNEL,
4275 },
4276 #ifndef CONFIG_ARM_LPAE
4277 [MT_MINICLEAN] = {
4278 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4279 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4280 .domain = DOMAIN_KERNEL,
4281 },
4282 #endif
4283 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4284 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4285 L_PTE_RDONLY,
4286 .prot_l1 = PMD_TYPE_TABLE,
4287 - .domain = DOMAIN_USER,
4288 + .domain = DOMAIN_VECTORS,
4289 },
4290 [MT_HIGH_VECTORS] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_USER | L_PTE_RDONLY,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 - .domain = DOMAIN_USER,
4295 + .domain = DOMAIN_VECTORS,
4296 },
4297 - [MT_MEMORY] = {
4298 + [MT_MEMORY_RWX] = {
4299 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4300 .prot_l1 = PMD_TYPE_TABLE,
4301 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 + [MT_MEMORY_RW] = {
4305 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4306 + .prot_l1 = PMD_TYPE_TABLE,
4307 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4308 + .domain = DOMAIN_KERNEL,
4309 + },
4310 + [MT_MEMORY_RX] = {
4311 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4312 + .prot_l1 = PMD_TYPE_TABLE,
4313 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4314 + .domain = DOMAIN_KERNEL,
4315 + },
4316 [MT_ROM] = {
4317 - .prot_sect = PMD_TYPE_SECT,
4318 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4319 .domain = DOMAIN_KERNEL,
4320 },
4321 - [MT_MEMORY_NONCACHED] = {
4322 + [MT_MEMORY_NONCACHED_RW] = {
4323 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4324 L_PTE_MT_BUFFERABLE,
4325 .prot_l1 = PMD_TYPE_TABLE,
4326 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4327 .domain = DOMAIN_KERNEL,
4328 },
4329 + [MT_MEMORY_NONCACHED_RX] = {
4330 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4331 + L_PTE_MT_BUFFERABLE,
4332 + .prot_l1 = PMD_TYPE_TABLE,
4333 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4334 + .domain = DOMAIN_KERNEL,
4335 + },
4336 [MT_MEMORY_DTCM] = {
4337 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4338 - L_PTE_XN,
4339 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4340 .prot_l1 = PMD_TYPE_TABLE,
4341 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4342 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4343 .domain = DOMAIN_KERNEL,
4344 },
4345 [MT_MEMORY_ITCM] = {
4346 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4347 },
4348 [MT_MEMORY_SO] = {
4349 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4350 - L_PTE_MT_UNCACHED | L_PTE_XN,
4351 + L_PTE_MT_UNCACHED,
4352 .prot_l1 = PMD_TYPE_TABLE,
4353 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4354 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4355 + PMD_SECT_UNCACHED,
4356 .domain = DOMAIN_KERNEL,
4357 },
4358 [MT_MEMORY_DMA_READY] = {
4359 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4360 * to prevent speculative instruction fetches.
4361 */
4362 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4364 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4365 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4366 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4367 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4368 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4369 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4370 +
4371 + /* Mark other regions on ARMv6+ as execute-never */
4372 +
4373 +#ifdef CONFIG_PAX_KERNEXEC
4374 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4376 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4378 +#ifndef CONFIG_ARM_LPAE
4379 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4380 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4381 +#endif
4382 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4383 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4384 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4386 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4388 +#endif
4389 +
4390 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4391 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4392 }
4393 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4394 /*
4395 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4396 * from SVC mode and no access from userspace.
4397 */
4398 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4399 +#ifdef CONFIG_PAX_KERNEXEC
4400 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4401 +#endif
4402 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4403 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4404 #endif
4405 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4406 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4407 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4408 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4409 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4410 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4411 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4412 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4413 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4414 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4415 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4416 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4418 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4419 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4420 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4421 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4422 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4423 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4424 }
4425 }
4426
4427 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4428 if (cpu_arch >= CPU_ARCH_ARMv6) {
4429 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4430 /* Non-cacheable Normal is XCB = 001 */
4431 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4432 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4433 + PMD_SECT_BUFFERED;
4434 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4435 PMD_SECT_BUFFERED;
4436 } else {
4437 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4438 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4440 + PMD_SECT_TEX(1);
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4442 PMD_SECT_TEX(1);
4443 }
4444 } else {
4445 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4446 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4447 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4448 }
4449
4450 #ifdef CONFIG_ARM_LPAE
4451 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4452 vecs_pgprot |= PTE_EXT_AF;
4453 #endif
4454
4455 + user_pgprot |= __supported_pte_mask;
4456 +
4457 for (i = 0; i < 16; i++) {
4458 pteval_t v = pgprot_val(protection_map[i]);
4459 protection_map[i] = __pgprot(v | user_pgprot);
4460 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4461
4462 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4463 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4464 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4465 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4466 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4467 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4468 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4469 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4470 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4471 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4472 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4473 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4474 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4475 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4476 mem_types[MT_ROM].prot_sect |= cp->pmd;
4477
4478 switch (cp->pmd) {
4479 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4480 * called function. This means you can't use any function or debugging
4481 * method which may touch any device, otherwise the kernel _will_ crash.
4482 */
4483 +
4484 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4485 +
4486 static void __init devicemaps_init(const struct machine_desc *mdesc)
4487 {
4488 struct map_desc map;
4489 unsigned long addr;
4490 - void *vectors;
4491
4492 - /*
4493 - * Allocate the vector page early.
4494 - */
4495 - vectors = early_alloc(PAGE_SIZE * 2);
4496 -
4497 - early_trap_init(vectors);
4498 + early_trap_init(&vectors);
4499
4500 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4501 pmd_clear(pmd_off_k(addr));
4502 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4503 * location (0xffff0000). If we aren't using high-vectors, also
4504 * create a mapping at the low-vectors virtual address.
4505 */
4506 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4507 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4508 map.virtual = 0xffff0000;
4509 map.length = PAGE_SIZE;
4510 #ifdef CONFIG_KUSER_HELPERS
4511 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4512 map.pfn = __phys_to_pfn(start);
4513 map.virtual = __phys_to_virt(start);
4514 map.length = end - start;
4515 - map.type = MT_MEMORY;
4516
4517 +#ifdef CONFIG_PAX_KERNEXEC
4518 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4519 + struct map_desc kernel;
4520 + struct map_desc initmap;
4521 +
4522 + /* when freeing initmem we will make this RW */
4523 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4524 + initmap.virtual = (unsigned long)__init_begin;
4525 + initmap.length = _sdata - __init_begin;
4526 + initmap.type = MT_MEMORY_RWX;
4527 + create_mapping(&initmap);
4528 +
4529 + /* when freeing initmem we will make this RX */
4530 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4531 + kernel.virtual = (unsigned long)_stext;
4532 + kernel.length = __init_begin - _stext;
4533 + kernel.type = MT_MEMORY_RWX;
4534 + create_mapping(&kernel);
4535 +
4536 + if (map.virtual < (unsigned long)_stext) {
4537 + map.length = (unsigned long)_stext - map.virtual;
4538 + map.type = MT_MEMORY_RWX;
4539 + create_mapping(&map);
4540 + }
4541 +
4542 + map.pfn = __phys_to_pfn(__pa(_sdata));
4543 + map.virtual = (unsigned long)_sdata;
4544 + map.length = end - __pa(_sdata);
4545 + }
4546 +#endif
4547 +
4548 + map.type = MT_MEMORY_RW;
4549 create_mapping(&map);
4550 }
4551 }
4552 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4553 index a5bc92d..0bb4730 100644
4554 --- a/arch/arm/plat-omap/sram.c
4555 +++ b/arch/arm/plat-omap/sram.c
4556 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4557 * Looks like we need to preserve some bootloader code at the
4558 * beginning of SRAM for jumping to flash for reboot to work...
4559 */
4560 + pax_open_kernel();
4561 memset_io(omap_sram_base + omap_sram_skip, 0,
4562 omap_sram_size - omap_sram_skip);
4563 + pax_close_kernel();
4564 }
4565 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4566 index ce6d763..cfea917 100644
4567 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4568 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4569 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4570 int (*started)(unsigned ch);
4571 int (*flush)(unsigned ch);
4572 int (*stop)(unsigned ch);
4573 -};
4574 +} __no_const;
4575
4576 extern void *samsung_dmadev_get_ops(void);
4577 extern void *s3c_dma_get_ops(void);
4578 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4579 index c3a58a1..78fbf54 100644
4580 --- a/arch/avr32/include/asm/cache.h
4581 +++ b/arch/avr32/include/asm/cache.h
4582 @@ -1,8 +1,10 @@
4583 #ifndef __ASM_AVR32_CACHE_H
4584 #define __ASM_AVR32_CACHE_H
4585
4586 +#include <linux/const.h>
4587 +
4588 #define L1_CACHE_SHIFT 5
4589 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4590 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4591
4592 /*
4593 * Memory returned by kmalloc() may be used for DMA, so we must make
4594 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4595 index d232888..87c8df1 100644
4596 --- a/arch/avr32/include/asm/elf.h
4597 +++ b/arch/avr32/include/asm/elf.h
4598 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4599 the loader. We need to make sure that it is out of the way of the program
4600 that it will "exec", and that there is sufficient room for the brk. */
4601
4602 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4603 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4604
4605 +#ifdef CONFIG_PAX_ASLR
4606 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4607 +
4608 +#define PAX_DELTA_MMAP_LEN 15
4609 +#define PAX_DELTA_STACK_LEN 15
4610 +#endif
4611
4612 /* This yields a mask that user programs can use to figure out what
4613 instruction set this CPU supports. This could be done in user space,
4614 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4615 index 479330b..53717a8 100644
4616 --- a/arch/avr32/include/asm/kmap_types.h
4617 +++ b/arch/avr32/include/asm/kmap_types.h
4618 @@ -2,9 +2,9 @@
4619 #define __ASM_AVR32_KMAP_TYPES_H
4620
4621 #ifdef CONFIG_DEBUG_HIGHMEM
4622 -# define KM_TYPE_NR 29
4623 +# define KM_TYPE_NR 30
4624 #else
4625 -# define KM_TYPE_NR 14
4626 +# define KM_TYPE_NR 15
4627 #endif
4628
4629 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4630 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4631 index 0eca933..eb78c7b 100644
4632 --- a/arch/avr32/mm/fault.c
4633 +++ b/arch/avr32/mm/fault.c
4634 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4635
4636 int exception_trace = 1;
4637
4638 +#ifdef CONFIG_PAX_PAGEEXEC
4639 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4640 +{
4641 + unsigned long i;
4642 +
4643 + printk(KERN_ERR "PAX: bytes at PC: ");
4644 + for (i = 0; i < 20; i++) {
4645 + unsigned char c;
4646 + if (get_user(c, (unsigned char *)pc+i))
4647 + printk(KERN_CONT "???????? ");
4648 + else
4649 + printk(KERN_CONT "%02x ", c);
4650 + }
4651 + printk("\n");
4652 +}
4653 +#endif
4654 +
4655 /*
4656 * This routine handles page faults. It determines the address and the
4657 * problem, and then passes it off to one of the appropriate routines.
4658 @@ -176,6 +193,16 @@ bad_area:
4659 up_read(&mm->mmap_sem);
4660
4661 if (user_mode(regs)) {
4662 +
4663 +#ifdef CONFIG_PAX_PAGEEXEC
4664 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4665 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4666 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4667 + do_group_exit(SIGKILL);
4668 + }
4669 + }
4670 +#endif
4671 +
4672 if (exception_trace && printk_ratelimit())
4673 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4674 "sp %08lx ecr %lu\n",
4675 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4676 index 568885a..f8008df 100644
4677 --- a/arch/blackfin/include/asm/cache.h
4678 +++ b/arch/blackfin/include/asm/cache.h
4679 @@ -7,6 +7,7 @@
4680 #ifndef __ARCH_BLACKFIN_CACHE_H
4681 #define __ARCH_BLACKFIN_CACHE_H
4682
4683 +#include <linux/const.h>
4684 #include <linux/linkage.h> /* for asmlinkage */
4685
4686 /*
4687 @@ -14,7 +15,7 @@
4688 * Blackfin loads 32 bytes for cache
4689 */
4690 #define L1_CACHE_SHIFT 5
4691 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4692 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4693 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4694
4695 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4696 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4697 index aea2718..3639a60 100644
4698 --- a/arch/cris/include/arch-v10/arch/cache.h
4699 +++ b/arch/cris/include/arch-v10/arch/cache.h
4700 @@ -1,8 +1,9 @@
4701 #ifndef _ASM_ARCH_CACHE_H
4702 #define _ASM_ARCH_CACHE_H
4703
4704 +#include <linux/const.h>
4705 /* Etrax 100LX have 32-byte cache-lines. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #endif /* _ASM_ARCH_CACHE_H */
4711 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4712 index 7caf25d..ee65ac5 100644
4713 --- a/arch/cris/include/arch-v32/arch/cache.h
4714 +++ b/arch/cris/include/arch-v32/arch/cache.h
4715 @@ -1,11 +1,12 @@
4716 #ifndef _ASM_CRIS_ARCH_CACHE_H
4717 #define _ASM_CRIS_ARCH_CACHE_H
4718
4719 +#include <linux/const.h>
4720 #include <arch/hwregs/dma.h>
4721
4722 /* A cache-line is 32 bytes. */
4723 -#define L1_CACHE_BYTES 32
4724 #define L1_CACHE_SHIFT 5
4725 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4726
4727 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4728
4729 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4730 index b86329d..6709906 100644
4731 --- a/arch/frv/include/asm/atomic.h
4732 +++ b/arch/frv/include/asm/atomic.h
4733 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4734 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4735 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4736
4737 +#define atomic64_read_unchecked(v) atomic64_read(v)
4738 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4739 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4740 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4741 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4742 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4743 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4744 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4745 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4746 +
4747 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4748 {
4749 int c, old;
4750 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4751 index 2797163..c2a401d 100644
4752 --- a/arch/frv/include/asm/cache.h
4753 +++ b/arch/frv/include/asm/cache.h
4754 @@ -12,10 +12,11 @@
4755 #ifndef __ASM_CACHE_H
4756 #define __ASM_CACHE_H
4757
4758 +#include <linux/const.h>
4759
4760 /* bytes per L1 cache line */
4761 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4762 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4763 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4764
4765 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4766 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4767 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4768 index 43901f2..0d8b865 100644
4769 --- a/arch/frv/include/asm/kmap_types.h
4770 +++ b/arch/frv/include/asm/kmap_types.h
4771 @@ -2,6 +2,6 @@
4772 #ifndef _ASM_KMAP_TYPES_H
4773 #define _ASM_KMAP_TYPES_H
4774
4775 -#define KM_TYPE_NR 17
4776 +#define KM_TYPE_NR 18
4777
4778 #endif
4779 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4780 index 836f147..4cf23f5 100644
4781 --- a/arch/frv/mm/elf-fdpic.c
4782 +++ b/arch/frv/mm/elf-fdpic.c
4783 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4784 {
4785 struct vm_area_struct *vma;
4786 struct vm_unmapped_area_info info;
4787 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4788
4789 if (len > TASK_SIZE)
4790 return -ENOMEM;
4791 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4792 if (addr) {
4793 addr = PAGE_ALIGN(addr);
4794 vma = find_vma(current->mm, addr);
4795 - if (TASK_SIZE - len >= addr &&
4796 - (!vma || addr + len <= vma->vm_start))
4797 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4798 goto success;
4799 }
4800
4801 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4802 info.high_limit = (current->mm->start_stack - 0x00200000);
4803 info.align_mask = 0;
4804 info.align_offset = 0;
4805 + info.threadstack_offset = offset;
4806 addr = vm_unmapped_area(&info);
4807 if (!(addr & ~PAGE_MASK))
4808 goto success;
4809 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4810 index f4ca594..adc72fd6 100644
4811 --- a/arch/hexagon/include/asm/cache.h
4812 +++ b/arch/hexagon/include/asm/cache.h
4813 @@ -21,9 +21,11 @@
4814 #ifndef __ASM_CACHE_H
4815 #define __ASM_CACHE_H
4816
4817 +#include <linux/const.h>
4818 +
4819 /* Bytes per L1 cache line */
4820 -#define L1_CACHE_SHIFT (5)
4821 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4822 +#define L1_CACHE_SHIFT 5
4823 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4824
4825 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4826 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4827 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4828 index 6e6fe18..a6ae668 100644
4829 --- a/arch/ia64/include/asm/atomic.h
4830 +++ b/arch/ia64/include/asm/atomic.h
4831 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4832 #define atomic64_inc(v) atomic64_add(1, (v))
4833 #define atomic64_dec(v) atomic64_sub(1, (v))
4834
4835 +#define atomic64_read_unchecked(v) atomic64_read(v)
4836 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4837 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4838 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4839 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4840 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4841 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4842 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4843 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4844 +
4845 /* Atomic operations are already serializing */
4846 #define smp_mb__before_atomic_dec() barrier()
4847 #define smp_mb__after_atomic_dec() barrier()
4848 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4849 index 988254a..e1ee885 100644
4850 --- a/arch/ia64/include/asm/cache.h
4851 +++ b/arch/ia64/include/asm/cache.h
4852 @@ -1,6 +1,7 @@
4853 #ifndef _ASM_IA64_CACHE_H
4854 #define _ASM_IA64_CACHE_H
4855
4856 +#include <linux/const.h>
4857
4858 /*
4859 * Copyright (C) 1998-2000 Hewlett-Packard Co
4860 @@ -9,7 +10,7 @@
4861
4862 /* Bytes per L1 (data) cache line. */
4863 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4864 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4865 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4866
4867 #ifdef CONFIG_SMP
4868 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4869 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4870 index 5a83c5c..4d7f553 100644
4871 --- a/arch/ia64/include/asm/elf.h
4872 +++ b/arch/ia64/include/asm/elf.h
4873 @@ -42,6 +42,13 @@
4874 */
4875 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4876
4877 +#ifdef CONFIG_PAX_ASLR
4878 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4879 +
4880 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4881 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4882 +#endif
4883 +
4884 #define PT_IA_64_UNWIND 0x70000001
4885
4886 /* IA-64 relocations: */
4887 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4888 index 96a8d92..617a1cf 100644
4889 --- a/arch/ia64/include/asm/pgalloc.h
4890 +++ b/arch/ia64/include/asm/pgalloc.h
4891 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4892 pgd_val(*pgd_entry) = __pa(pud);
4893 }
4894
4895 +static inline void
4896 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4897 +{
4898 + pgd_populate(mm, pgd_entry, pud);
4899 +}
4900 +
4901 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4902 {
4903 return quicklist_alloc(0, GFP_KERNEL, NULL);
4904 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4905 pud_val(*pud_entry) = __pa(pmd);
4906 }
4907
4908 +static inline void
4909 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4910 +{
4911 + pud_populate(mm, pud_entry, pmd);
4912 +}
4913 +
4914 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4915 {
4916 return quicklist_alloc(0, GFP_KERNEL, NULL);
4917 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4918 index 7935115..c0eca6a 100644
4919 --- a/arch/ia64/include/asm/pgtable.h
4920 +++ b/arch/ia64/include/asm/pgtable.h
4921 @@ -12,7 +12,7 @@
4922 * David Mosberger-Tang <davidm@hpl.hp.com>
4923 */
4924
4925 -
4926 +#include <linux/const.h>
4927 #include <asm/mman.h>
4928 #include <asm/page.h>
4929 #include <asm/processor.h>
4930 @@ -142,6 +142,17 @@
4931 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4932 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4933 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4934 +
4935 +#ifdef CONFIG_PAX_PAGEEXEC
4936 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4937 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4938 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4939 +#else
4940 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4941 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4942 +# define PAGE_COPY_NOEXEC PAGE_COPY
4943 +#endif
4944 +
4945 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4946 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4947 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4948 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4949 index 45698cd..e8e2dbc 100644
4950 --- a/arch/ia64/include/asm/spinlock.h
4951 +++ b/arch/ia64/include/asm/spinlock.h
4952 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4953 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4954
4955 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4956 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4957 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4958 }
4959
4960 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4961 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4962 index 449c8c0..18965fb 100644
4963 --- a/arch/ia64/include/asm/uaccess.h
4964 +++ b/arch/ia64/include/asm/uaccess.h
4965 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4966 static inline unsigned long
4967 __copy_to_user (void __user *to, const void *from, unsigned long count)
4968 {
4969 + if (count > INT_MAX)
4970 + return count;
4971 +
4972 + if (!__builtin_constant_p(count))
4973 + check_object_size(from, count, true);
4974 +
4975 return __copy_user(to, (__force void __user *) from, count);
4976 }
4977
4978 static inline unsigned long
4979 __copy_from_user (void *to, const void __user *from, unsigned long count)
4980 {
4981 + if (count > INT_MAX)
4982 + return count;
4983 +
4984 + if (!__builtin_constant_p(count))
4985 + check_object_size(to, count, false);
4986 +
4987 return __copy_user((__force void __user *) to, from, count);
4988 }
4989
4990 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4991 ({ \
4992 void __user *__cu_to = (to); \
4993 const void *__cu_from = (from); \
4994 - long __cu_len = (n); \
4995 + unsigned long __cu_len = (n); \
4996 \
4997 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_from, __cu_len, true); \
5001 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5007 ({ \
5008 void *__cu_to = (to); \
5009 const void __user *__cu_from = (from); \
5010 - long __cu_len = (n); \
5011 + unsigned long __cu_len = (n); \
5012 \
5013 __chk_user_ptr(__cu_from); \
5014 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5015 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5016 + if (!__builtin_constant_p(n)) \
5017 + check_object_size(__cu_to, __cu_len, false); \
5018 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5019 + } \
5020 __cu_len; \
5021 })
5022
5023 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5024 index 24603be..948052d 100644
5025 --- a/arch/ia64/kernel/module.c
5026 +++ b/arch/ia64/kernel/module.c
5027 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5028 void
5029 module_free (struct module *mod, void *module_region)
5030 {
5031 - if (mod && mod->arch.init_unw_table &&
5032 - module_region == mod->module_init) {
5033 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5034 unw_remove_unwind_table(mod->arch.init_unw_table);
5035 mod->arch.init_unw_table = NULL;
5036 }
5037 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5038 }
5039
5040 static inline int
5041 +in_init_rx (const struct module *mod, uint64_t addr)
5042 +{
5043 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5044 +}
5045 +
5046 +static inline int
5047 +in_init_rw (const struct module *mod, uint64_t addr)
5048 +{
5049 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5050 +}
5051 +
5052 +static inline int
5053 in_init (const struct module *mod, uint64_t addr)
5054 {
5055 - return addr - (uint64_t) mod->module_init < mod->init_size;
5056 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5057 +}
5058 +
5059 +static inline int
5060 +in_core_rx (const struct module *mod, uint64_t addr)
5061 +{
5062 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5063 +}
5064 +
5065 +static inline int
5066 +in_core_rw (const struct module *mod, uint64_t addr)
5067 +{
5068 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5069 }
5070
5071 static inline int
5072 in_core (const struct module *mod, uint64_t addr)
5073 {
5074 - return addr - (uint64_t) mod->module_core < mod->core_size;
5075 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5076 }
5077
5078 static inline int
5079 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5080 break;
5081
5082 case RV_BDREL:
5083 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5084 + if (in_init_rx(mod, val))
5085 + val -= (uint64_t) mod->module_init_rx;
5086 + else if (in_init_rw(mod, val))
5087 + val -= (uint64_t) mod->module_init_rw;
5088 + else if (in_core_rx(mod, val))
5089 + val -= (uint64_t) mod->module_core_rx;
5090 + else if (in_core_rw(mod, val))
5091 + val -= (uint64_t) mod->module_core_rw;
5092 break;
5093
5094 case RV_LTV:
5095 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5096 * addresses have been selected...
5097 */
5098 uint64_t gp;
5099 - if (mod->core_size > MAX_LTOFF)
5100 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5101 /*
5102 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5103 * at the end of the module.
5104 */
5105 - gp = mod->core_size - MAX_LTOFF / 2;
5106 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5107 else
5108 - gp = mod->core_size / 2;
5109 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5110 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5111 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5112 mod->arch.gp = gp;
5113 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5114 }
5115 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5116 index ab33328..f39506c 100644
5117 --- a/arch/ia64/kernel/palinfo.c
5118 +++ b/arch/ia64/kernel/palinfo.c
5119 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5120 return NOTIFY_OK;
5121 }
5122
5123 -static struct notifier_block __refdata palinfo_cpu_notifier =
5124 +static struct notifier_block palinfo_cpu_notifier =
5125 {
5126 .notifier_call = palinfo_cpu_callback,
5127 .priority = 0,
5128 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5129 index 41e33f8..65180b2 100644
5130 --- a/arch/ia64/kernel/sys_ia64.c
5131 +++ b/arch/ia64/kernel/sys_ia64.c
5132 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5133 unsigned long align_mask = 0;
5134 struct mm_struct *mm = current->mm;
5135 struct vm_unmapped_area_info info;
5136 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5137
5138 if (len > RGN_MAP_LIMIT)
5139 return -ENOMEM;
5140 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5141 if (REGION_NUMBER(addr) == RGN_HPAGE)
5142 addr = 0;
5143 #endif
5144 +
5145 +#ifdef CONFIG_PAX_RANDMMAP
5146 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5147 + addr = mm->free_area_cache;
5148 + else
5149 +#endif
5150 +
5151 if (!addr)
5152 addr = TASK_UNMAPPED_BASE;
5153
5154 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5155 info.high_limit = TASK_SIZE;
5156 info.align_mask = align_mask;
5157 info.align_offset = 0;
5158 + info.threadstack_offset = offset;
5159 return vm_unmapped_area(&info);
5160 }
5161
5162 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5163 index 0ccb28f..8992469 100644
5164 --- a/arch/ia64/kernel/vmlinux.lds.S
5165 +++ b/arch/ia64/kernel/vmlinux.lds.S
5166 @@ -198,7 +198,7 @@ SECTIONS {
5167 /* Per-cpu data: */
5168 . = ALIGN(PERCPU_PAGE_SIZE);
5169 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5170 - __phys_per_cpu_start = __per_cpu_load;
5171 + __phys_per_cpu_start = per_cpu_load;
5172 /*
5173 * ensure percpu data fits
5174 * into percpu page size
5175 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5176 index 7225dad..2a7c8256 100644
5177 --- a/arch/ia64/mm/fault.c
5178 +++ b/arch/ia64/mm/fault.c
5179 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5180 return pte_present(pte);
5181 }
5182
5183 +#ifdef CONFIG_PAX_PAGEEXEC
5184 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5185 +{
5186 + unsigned long i;
5187 +
5188 + printk(KERN_ERR "PAX: bytes at PC: ");
5189 + for (i = 0; i < 8; i++) {
5190 + unsigned int c;
5191 + if (get_user(c, (unsigned int *)pc+i))
5192 + printk(KERN_CONT "???????? ");
5193 + else
5194 + printk(KERN_CONT "%08x ", c);
5195 + }
5196 + printk("\n");
5197 +}
5198 +#endif
5199 +
5200 # define VM_READ_BIT 0
5201 # define VM_WRITE_BIT 1
5202 # define VM_EXEC_BIT 2
5203 @@ -151,8 +168,21 @@ retry:
5204 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5205 goto bad_area;
5206
5207 - if ((vma->vm_flags & mask) != mask)
5208 + if ((vma->vm_flags & mask) != mask) {
5209 +
5210 +#ifdef CONFIG_PAX_PAGEEXEC
5211 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5212 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5213 + goto bad_area;
5214 +
5215 + up_read(&mm->mmap_sem);
5216 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5217 + do_group_exit(SIGKILL);
5218 + }
5219 +#endif
5220 +
5221 goto bad_area;
5222 + }
5223
5224 /*
5225 * If for any reason at all we couldn't handle the fault, make
5226 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5227 index 68232db..6ca80af 100644
5228 --- a/arch/ia64/mm/hugetlbpage.c
5229 +++ b/arch/ia64/mm/hugetlbpage.c
5230 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5231 unsigned long pgoff, unsigned long flags)
5232 {
5233 struct vm_unmapped_area_info info;
5234 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5235
5236 if (len > RGN_MAP_LIMIT)
5237 return -ENOMEM;
5238 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5239 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5240 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5241 info.align_offset = 0;
5242 + info.threadstack_offset = offset;
5243 return vm_unmapped_area(&info);
5244 }
5245
5246 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5247 index b6f7f43..c04320d 100644
5248 --- a/arch/ia64/mm/init.c
5249 +++ b/arch/ia64/mm/init.c
5250 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5251 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5252 vma->vm_end = vma->vm_start + PAGE_SIZE;
5253 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5254 +
5255 +#ifdef CONFIG_PAX_PAGEEXEC
5256 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5257 + vma->vm_flags &= ~VM_EXEC;
5258 +
5259 +#ifdef CONFIG_PAX_MPROTECT
5260 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5261 + vma->vm_flags &= ~VM_MAYEXEC;
5262 +#endif
5263 +
5264 + }
5265 +#endif
5266 +
5267 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5268 down_write(&current->mm->mmap_sem);
5269 if (insert_vm_struct(current->mm, vma)) {
5270 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5271 index 40b3ee9..8c2c112 100644
5272 --- a/arch/m32r/include/asm/cache.h
5273 +++ b/arch/m32r/include/asm/cache.h
5274 @@ -1,8 +1,10 @@
5275 #ifndef _ASM_M32R_CACHE_H
5276 #define _ASM_M32R_CACHE_H
5277
5278 +#include <linux/const.h>
5279 +
5280 /* L1 cache line size */
5281 #define L1_CACHE_SHIFT 4
5282 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5283 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5284
5285 #endif /* _ASM_M32R_CACHE_H */
5286 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5287 index 82abd15..d95ae5d 100644
5288 --- a/arch/m32r/lib/usercopy.c
5289 +++ b/arch/m32r/lib/usercopy.c
5290 @@ -14,6 +14,9 @@
5291 unsigned long
5292 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5293 {
5294 + if ((long)n < 0)
5295 + return n;
5296 +
5297 prefetch(from);
5298 if (access_ok(VERIFY_WRITE, to, n))
5299 __copy_user(to,from,n);
5300 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5301 unsigned long
5302 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5303 {
5304 + if ((long)n < 0)
5305 + return n;
5306 +
5307 prefetchw(to);
5308 if (access_ok(VERIFY_READ, from, n))
5309 __copy_user_zeroing(to,from,n);
5310 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5311 index 0395c51..5f26031 100644
5312 --- a/arch/m68k/include/asm/cache.h
5313 +++ b/arch/m68k/include/asm/cache.h
5314 @@ -4,9 +4,11 @@
5315 #ifndef __ARCH_M68K_CACHE_H
5316 #define __ARCH_M68K_CACHE_H
5317
5318 +#include <linux/const.h>
5319 +
5320 /* bytes per L1 cache line */
5321 #define L1_CACHE_SHIFT 4
5322 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5323 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5324
5325 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5326
5327 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5328 index 0424315..defcca9 100644
5329 --- a/arch/metag/mm/hugetlbpage.c
5330 +++ b/arch/metag/mm/hugetlbpage.c
5331 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5332 info.high_limit = TASK_SIZE;
5333 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5334 info.align_offset = 0;
5335 + info.threadstack_offset = 0;
5336 return vm_unmapped_area(&info);
5337 }
5338
5339 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5340 index 4efe96a..60e8699 100644
5341 --- a/arch/microblaze/include/asm/cache.h
5342 +++ b/arch/microblaze/include/asm/cache.h
5343 @@ -13,11 +13,12 @@
5344 #ifndef _ASM_MICROBLAZE_CACHE_H
5345 #define _ASM_MICROBLAZE_CACHE_H
5346
5347 +#include <linux/const.h>
5348 #include <asm/registers.h>
5349
5350 #define L1_CACHE_SHIFT 5
5351 /* word-granular cache in microblaze */
5352 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5353 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5354
5355 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5356
5357 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5358 index 08b6079..8b554d2 100644
5359 --- a/arch/mips/include/asm/atomic.h
5360 +++ b/arch/mips/include/asm/atomic.h
5361 @@ -21,15 +21,39 @@
5362 #include <asm/cmpxchg.h>
5363 #include <asm/war.h>
5364
5365 +#ifdef CONFIG_GENERIC_ATOMIC64
5366 +#include <asm-generic/atomic64.h>
5367 +#endif
5368 +
5369 #define ATOMIC_INIT(i) { (i) }
5370
5371 +#ifdef CONFIG_64BIT
5372 +#define _ASM_EXTABLE(from, to) \
5373 +" .section __ex_table,\"a\"\n" \
5374 +" .dword " #from ", " #to"\n" \
5375 +" .previous\n"
5376 +#else
5377 +#define _ASM_EXTABLE(from, to) \
5378 +" .section __ex_table,\"a\"\n" \
5379 +" .word " #from ", " #to"\n" \
5380 +" .previous\n"
5381 +#endif
5382 +
5383 /*
5384 * atomic_read - read atomic variable
5385 * @v: pointer of type atomic_t
5386 *
5387 * Atomically reads the value of @v.
5388 */
5389 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5390 +static inline int atomic_read(const atomic_t *v)
5391 +{
5392 + return (*(volatile const int *) &v->counter);
5393 +}
5394 +
5395 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5396 +{
5397 + return (*(volatile const int *) &v->counter);
5398 +}
5399
5400 /*
5401 * atomic_set - set atomic variable
5402 @@ -38,7 +62,15 @@
5403 *
5404 * Atomically sets the value of @v to @i.
5405 */
5406 -#define atomic_set(v, i) ((v)->counter = (i))
5407 +static inline void atomic_set(atomic_t *v, int i)
5408 +{
5409 + v->counter = i;
5410 +}
5411 +
5412 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5413 +{
5414 + v->counter = i;
5415 +}
5416
5417 /*
5418 * atomic_add - add integer to atomic variable
5419 @@ -47,7 +79,67 @@
5420 *
5421 * Atomically adds @i to @v.
5422 */
5423 -static __inline__ void atomic_add(int i, atomic_t * v)
5424 +static __inline__ void atomic_add(int i, atomic_t *v)
5425 +{
5426 + int temp;
5427 +
5428 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5429 + __asm__ __volatile__(
5430 + " .set mips3 \n"
5431 + "1: ll %0, %1 # atomic_add \n"
5432 +#ifdef CONFIG_PAX_REFCOUNT
5433 + /* Exception on overflow. */
5434 + "2: add %0, %2 \n"
5435 +#else
5436 + " addu %0, %2 \n"
5437 +#endif
5438 + " sc %0, %1 \n"
5439 + " beqzl %0, 1b \n"
5440 +#ifdef CONFIG_PAX_REFCOUNT
5441 + "3: \n"
5442 + _ASM_EXTABLE(2b, 3b)
5443 +#endif
5444 + " .set mips0 \n"
5445 + : "=&r" (temp), "+m" (v->counter)
5446 + : "Ir" (i));
5447 + } else if (kernel_uses_llsc) {
5448 + __asm__ __volatile__(
5449 + " .set mips3 \n"
5450 + "1: ll %0, %1 # atomic_add \n"
5451 +#ifdef CONFIG_PAX_REFCOUNT
5452 + /* Exception on overflow. */
5453 + "2: add %0, %2 \n"
5454 +#else
5455 + " addu %0, %2 \n"
5456 +#endif
5457 + " sc %0, %1 \n"
5458 + " beqz %0, 1b \n"
5459 +#ifdef CONFIG_PAX_REFCOUNT
5460 + "3: \n"
5461 + _ASM_EXTABLE(2b, 3b)
5462 +#endif
5463 + " .set mips0 \n"
5464 + : "=&r" (temp), "+m" (v->counter)
5465 + : "Ir" (i));
5466 + } else {
5467 + unsigned long flags;
5468 +
5469 + raw_local_irq_save(flags);
5470 + __asm__ __volatile__(
5471 +#ifdef CONFIG_PAX_REFCOUNT
5472 + /* Exception on overflow. */
5473 + "1: add %0, %1 \n"
5474 + "2: \n"
5475 + _ASM_EXTABLE(1b, 2b)
5476 +#else
5477 + " addu %0, %1 \n"
5478 +#endif
5479 + : "+r" (v->counter) : "Ir" (i));
5480 + raw_local_irq_restore(flags);
5481 + }
5482 +}
5483 +
5484 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5485 {
5486 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5487 int temp;
5488 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5489 *
5490 * Atomically subtracts @i from @v.
5491 */
5492 -static __inline__ void atomic_sub(int i, atomic_t * v)
5493 +static __inline__ void atomic_sub(int i, atomic_t *v)
5494 +{
5495 + int temp;
5496 +
5497 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5498 + __asm__ __volatile__(
5499 + " .set mips3 \n"
5500 + "1: ll %0, %1 # atomic64_sub \n"
5501 +#ifdef CONFIG_PAX_REFCOUNT
5502 + /* Exception on overflow. */
5503 + "2: sub %0, %2 \n"
5504 +#else
5505 + " subu %0, %2 \n"
5506 +#endif
5507 + " sc %0, %1 \n"
5508 + " beqzl %0, 1b \n"
5509 +#ifdef CONFIG_PAX_REFCOUNT
5510 + "3: \n"
5511 + _ASM_EXTABLE(2b, 3b)
5512 +#endif
5513 + " .set mips0 \n"
5514 + : "=&r" (temp), "+m" (v->counter)
5515 + : "Ir" (i));
5516 + } else if (kernel_uses_llsc) {
5517 + __asm__ __volatile__(
5518 + " .set mips3 \n"
5519 + "1: ll %0, %1 # atomic64_sub \n"
5520 +#ifdef CONFIG_PAX_REFCOUNT
5521 + /* Exception on overflow. */
5522 + "2: sub %0, %2 \n"
5523 +#else
5524 + " subu %0, %2 \n"
5525 +#endif
5526 + " sc %0, %1 \n"
5527 + " beqz %0, 1b \n"
5528 +#ifdef CONFIG_PAX_REFCOUNT
5529 + "3: \n"
5530 + _ASM_EXTABLE(2b, 3b)
5531 +#endif
5532 + " .set mips0 \n"
5533 + : "=&r" (temp), "+m" (v->counter)
5534 + : "Ir" (i));
5535 + } else {
5536 + unsigned long flags;
5537 +
5538 + raw_local_irq_save(flags);
5539 + __asm__ __volatile__(
5540 +#ifdef CONFIG_PAX_REFCOUNT
5541 + /* Exception on overflow. */
5542 + "1: sub %0, %1 \n"
5543 + "2: \n"
5544 + _ASM_EXTABLE(1b, 2b)
5545 +#else
5546 + " subu %0, %1 \n"
5547 +#endif
5548 + : "+r" (v->counter) : "Ir" (i));
5549 + raw_local_irq_restore(flags);
5550 + }
5551 +}
5552 +
5553 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5554 {
5555 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5556 int temp;
5557 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5558 /*
5559 * Same as above, but return the result value
5560 */
5561 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5562 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5563 +{
5564 + int result;
5565 + int temp;
5566 +
5567 + smp_mb__before_llsc();
5568 +
5569 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5570 + __asm__ __volatile__(
5571 + " .set mips3 \n"
5572 + "1: ll %1, %2 # atomic_add_return \n"
5573 +#ifdef CONFIG_PAX_REFCOUNT
5574 + "2: add %0, %1, %3 \n"
5575 +#else
5576 + " addu %0, %1, %3 \n"
5577 +#endif
5578 + " sc %0, %2 \n"
5579 + " beqzl %0, 1b \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + " b 4f \n"
5582 + " .set noreorder \n"
5583 + "3: b 5f \n"
5584 + " move %0, %1 \n"
5585 + " .set reorder \n"
5586 + _ASM_EXTABLE(2b, 3b)
5587 +#endif
5588 + "4: addu %0, %1, %3 \n"
5589 +#ifdef CONFIG_PAX_REFCOUNT
5590 + "5: \n"
5591 +#endif
5592 + " .set mips0 \n"
5593 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5594 + : "Ir" (i));
5595 + } else if (kernel_uses_llsc) {
5596 + __asm__ __volatile__(
5597 + " .set mips3 \n"
5598 + "1: ll %1, %2 # atomic_add_return \n"
5599 +#ifdef CONFIG_PAX_REFCOUNT
5600 + "2: add %0, %1, %3 \n"
5601 +#else
5602 + " addu %0, %1, %3 \n"
5603 +#endif
5604 + " sc %0, %2 \n"
5605 + " bnez %0, 4f \n"
5606 + " b 1b \n"
5607 +#ifdef CONFIG_PAX_REFCOUNT
5608 + " .set noreorder \n"
5609 + "3: b 5f \n"
5610 + " move %0, %1 \n"
5611 + " .set reorder \n"
5612 + _ASM_EXTABLE(2b, 3b)
5613 +#endif
5614 + "4: addu %0, %1, %3 \n"
5615 +#ifdef CONFIG_PAX_REFCOUNT
5616 + "5: \n"
5617 +#endif
5618 + " .set mips0 \n"
5619 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5620 + : "Ir" (i));
5621 + } else {
5622 + unsigned long flags;
5623 +
5624 + raw_local_irq_save(flags);
5625 + __asm__ __volatile__(
5626 + " lw %0, %1 \n"
5627 +#ifdef CONFIG_PAX_REFCOUNT
5628 + /* Exception on overflow. */
5629 + "1: add %0, %2 \n"
5630 +#else
5631 + " addu %0, %2 \n"
5632 +#endif
5633 + " sw %0, %1 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + /* Note: Dest reg is not modified on overflow */
5636 + "2: \n"
5637 + _ASM_EXTABLE(1b, 2b)
5638 +#endif
5639 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5640 + raw_local_irq_restore(flags);
5641 + }
5642 +
5643 + smp_llsc_mb();
5644 +
5645 + return result;
5646 +}
5647 +
5648 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5649 {
5650 int result;
5651
5652 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5653 return result;
5654 }
5655
5656 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5657 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5658 +{
5659 + int result;
5660 + int temp;
5661 +
5662 + smp_mb__before_llsc();
5663 +
5664 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5665 + __asm__ __volatile__(
5666 + " .set mips3 \n"
5667 + "1: ll %1, %2 # atomic_sub_return \n"
5668 +#ifdef CONFIG_PAX_REFCOUNT
5669 + "2: sub %0, %1, %3 \n"
5670 +#else
5671 + " subu %0, %1, %3 \n"
5672 +#endif
5673 + " sc %0, %2 \n"
5674 + " beqzl %0, 1b \n"
5675 +#ifdef CONFIG_PAX_REFCOUNT
5676 + " b 4f \n"
5677 + " .set noreorder \n"
5678 + "3: b 5f \n"
5679 + " move %0, %1 \n"
5680 + " .set reorder \n"
5681 + _ASM_EXTABLE(2b, 3b)
5682 +#endif
5683 + "4: subu %0, %1, %3 \n"
5684 +#ifdef CONFIG_PAX_REFCOUNT
5685 + "5: \n"
5686 +#endif
5687 + " .set mips0 \n"
5688 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5689 + : "Ir" (i), "m" (v->counter)
5690 + : "memory");
5691 + } else if (kernel_uses_llsc) {
5692 + __asm__ __volatile__(
5693 + " .set mips3 \n"
5694 + "1: ll %1, %2 # atomic_sub_return \n"
5695 +#ifdef CONFIG_PAX_REFCOUNT
5696 + "2: sub %0, %1, %3 \n"
5697 +#else
5698 + " subu %0, %1, %3 \n"
5699 +#endif
5700 + " sc %0, %2 \n"
5701 + " bnez %0, 4f \n"
5702 + " b 1b \n"
5703 +#ifdef CONFIG_PAX_REFCOUNT
5704 + " .set noreorder \n"
5705 + "3: b 5f \n"
5706 + " move %0, %1 \n"
5707 + " .set reorder \n"
5708 + _ASM_EXTABLE(2b, 3b)
5709 +#endif
5710 + "4: subu %0, %1, %3 \n"
5711 +#ifdef CONFIG_PAX_REFCOUNT
5712 + "5: \n"
5713 +#endif
5714 + " .set mips0 \n"
5715 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5716 + : "Ir" (i));
5717 + } else {
5718 + unsigned long flags;
5719 +
5720 + raw_local_irq_save(flags);
5721 + __asm__ __volatile__(
5722 + " lw %0, %1 \n"
5723 +#ifdef CONFIG_PAX_REFCOUNT
5724 + /* Exception on overflow. */
5725 + "1: sub %0, %2 \n"
5726 +#else
5727 + " subu %0, %2 \n"
5728 +#endif
5729 + " sw %0, %1 \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Note: Dest reg is not modified on overflow */
5732 + "2: \n"
5733 + _ASM_EXTABLE(1b, 2b)
5734 +#endif
5735 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5736 + raw_local_irq_restore(flags);
5737 + }
5738 +
5739 + smp_llsc_mb();
5740 +
5741 + return result;
5742 +}
5743 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5744 {
5745 int result;
5746
5747 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5748 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5749 * The function returns the old value of @v minus @i.
5750 */
5751 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5752 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5753 {
5754 int result;
5755
5756 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5757 return result;
5758 }
5759
5760 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5761 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5762 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5763 +{
5764 + return cmpxchg(&v->counter, old, new);
5765 +}
5766 +
5767 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5768 + int new)
5769 +{
5770 + return cmpxchg(&(v->counter), old, new);
5771 +}
5772 +
5773 +static inline int atomic_xchg(atomic_t *v, int new)
5774 +{
5775 + return xchg(&v->counter, new);
5776 +}
5777 +
5778 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5779 +{
5780 + return xchg(&(v->counter), new);
5781 +}
5782
5783 /**
5784 * __atomic_add_unless - add unless the number is a given value
5785 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5786
5787 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5788 #define atomic_inc_return(v) atomic_add_return(1, (v))
5789 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5790 +{
5791 + return atomic_add_return_unchecked(1, v);
5792 +}
5793
5794 /*
5795 * atomic_sub_and_test - subtract value from variable and test result
5796 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5797 * other cases.
5798 */
5799 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5800 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5801 +{
5802 + return atomic_add_return_unchecked(1, v) == 0;
5803 +}
5804
5805 /*
5806 * atomic_dec_and_test - decrement by 1 and test
5807 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5808 * Atomically increments @v by 1.
5809 */
5810 #define atomic_inc(v) atomic_add(1, (v))
5811 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5812 +{
5813 + atomic_add_unchecked(1, v);
5814 +}
5815
5816 /*
5817 * atomic_dec - decrement and test
5818 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5819 * Atomically decrements @v by 1.
5820 */
5821 #define atomic_dec(v) atomic_sub(1, (v))
5822 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5823 +{
5824 + atomic_sub_unchecked(1, v);
5825 +}
5826
5827 /*
5828 * atomic_add_negative - add and test if negative
5829 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5830 * @v: pointer of type atomic64_t
5831 *
5832 */
5833 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5834 +static inline long atomic64_read(const atomic64_t *v)
5835 +{
5836 + return (*(volatile const long *) &v->counter);
5837 +}
5838 +
5839 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5840 +{
5841 + return (*(volatile const long *) &v->counter);
5842 +}
5843
5844 /*
5845 * atomic64_set - set atomic variable
5846 * @v: pointer of type atomic64_t
5847 * @i: required value
5848 */
5849 -#define atomic64_set(v, i) ((v)->counter = (i))
5850 +static inline void atomic64_set(atomic64_t *v, long i)
5851 +{
5852 + v->counter = i;
5853 +}
5854 +
5855 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5856 +{
5857 + v->counter = i;
5858 +}
5859
5860 /*
5861 * atomic64_add - add integer to atomic variable
5862 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5863 *
5864 * Atomically adds @i to @v.
5865 */
5866 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5867 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5868 +{
5869 + long temp;
5870 +
5871 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5872 + __asm__ __volatile__(
5873 + " .set mips3 \n"
5874 + "1: lld %0, %1 # atomic64_add \n"
5875 +#ifdef CONFIG_PAX_REFCOUNT
5876 + /* Exception on overflow. */
5877 + "2: dadd %0, %2 \n"
5878 +#else
5879 + " daddu %0, %2 \n"
5880 +#endif
5881 + " scd %0, %1 \n"
5882 + " beqzl %0, 1b \n"
5883 +#ifdef CONFIG_PAX_REFCOUNT
5884 + "3: \n"
5885 + _ASM_EXTABLE(2b, 3b)
5886 +#endif
5887 + " .set mips0 \n"
5888 + : "=&r" (temp), "+m" (v->counter)
5889 + : "Ir" (i));
5890 + } else if (kernel_uses_llsc) {
5891 + __asm__ __volatile__(
5892 + " .set mips3 \n"
5893 + "1: lld %0, %1 # atomic64_add \n"
5894 +#ifdef CONFIG_PAX_REFCOUNT
5895 + /* Exception on overflow. */
5896 + "2: dadd %0, %2 \n"
5897 +#else
5898 + " daddu %0, %2 \n"
5899 +#endif
5900 + " scd %0, %1 \n"
5901 + " beqz %0, 1b \n"
5902 +#ifdef CONFIG_PAX_REFCOUNT
5903 + "3: \n"
5904 + _ASM_EXTABLE(2b, 3b)
5905 +#endif
5906 + " .set mips0 \n"
5907 + : "=&r" (temp), "+m" (v->counter)
5908 + : "Ir" (i));
5909 + } else {
5910 + unsigned long flags;
5911 +
5912 + raw_local_irq_save(flags);
5913 + __asm__ __volatile__(
5914 +#ifdef CONFIG_PAX_REFCOUNT
5915 + /* Exception on overflow. */
5916 + "1: dadd %0, %1 \n"
5917 + "2: \n"
5918 + _ASM_EXTABLE(1b, 2b)
5919 +#else
5920 + " daddu %0, %1 \n"
5921 +#endif
5922 + : "+r" (v->counter) : "Ir" (i));
5923 + raw_local_irq_restore(flags);
5924 + }
5925 +}
5926 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5927 {
5928 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5929 long temp;
5930 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5931 *
5932 * Atomically subtracts @i from @v.
5933 */
5934 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5935 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5936 +{
5937 + long temp;
5938 +
5939 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5940 + __asm__ __volatile__(
5941 + " .set mips3 \n"
5942 + "1: lld %0, %1 # atomic64_sub \n"
5943 +#ifdef CONFIG_PAX_REFCOUNT
5944 + /* Exception on overflow. */
5945 + "2: dsub %0, %2 \n"
5946 +#else
5947 + " dsubu %0, %2 \n"
5948 +#endif
5949 + " scd %0, %1 \n"
5950 + " beqzl %0, 1b \n"
5951 +#ifdef CONFIG_PAX_REFCOUNT
5952 + "3: \n"
5953 + _ASM_EXTABLE(2b, 3b)
5954 +#endif
5955 + " .set mips0 \n"
5956 + : "=&r" (temp), "+m" (v->counter)
5957 + : "Ir" (i));
5958 + } else if (kernel_uses_llsc) {
5959 + __asm__ __volatile__(
5960 + " .set mips3 \n"
5961 + "1: lld %0, %1 # atomic64_sub \n"
5962 +#ifdef CONFIG_PAX_REFCOUNT
5963 + /* Exception on overflow. */
5964 + "2: dsub %0, %2 \n"
5965 +#else
5966 + " dsubu %0, %2 \n"
5967 +#endif
5968 + " scd %0, %1 \n"
5969 + " beqz %0, 1b \n"
5970 +#ifdef CONFIG_PAX_REFCOUNT
5971 + "3: \n"
5972 + _ASM_EXTABLE(2b, 3b)
5973 +#endif
5974 + " .set mips0 \n"
5975 + : "=&r" (temp), "+m" (v->counter)
5976 + : "Ir" (i));
5977 + } else {
5978 + unsigned long flags;
5979 +
5980 + raw_local_irq_save(flags);
5981 + __asm__ __volatile__(
5982 +#ifdef CONFIG_PAX_REFCOUNT
5983 + /* Exception on overflow. */
5984 + "1: dsub %0, %1 \n"
5985 + "2: \n"
5986 + _ASM_EXTABLE(1b, 2b)
5987 +#else
5988 + " dsubu %0, %1 \n"
5989 +#endif
5990 + : "+r" (v->counter) : "Ir" (i));
5991 + raw_local_irq_restore(flags);
5992 + }
5993 +}
5994 +
5995 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5996 {
5997 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5998 long temp;
5999 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6000 /*
6001 * Same as above, but return the result value
6002 */
6003 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6004 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6005 +{
6006 + long result;
6007 + long temp;
6008 +
6009 + smp_mb__before_llsc();
6010 +
6011 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6012 + __asm__ __volatile__(
6013 + " .set mips3 \n"
6014 + "1: lld %1, %2 # atomic64_add_return \n"
6015 +#ifdef CONFIG_PAX_REFCOUNT
6016 + "2: dadd %0, %1, %3 \n"
6017 +#else
6018 + " daddu %0, %1, %3 \n"
6019 +#endif
6020 + " scd %0, %2 \n"
6021 + " beqzl %0, 1b \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + " b 4f \n"
6024 + " .set noreorder \n"
6025 + "3: b 5f \n"
6026 + " move %0, %1 \n"
6027 + " .set reorder \n"
6028 + _ASM_EXTABLE(2b, 3b)
6029 +#endif
6030 + "4: daddu %0, %1, %3 \n"
6031 +#ifdef CONFIG_PAX_REFCOUNT
6032 + "5: \n"
6033 +#endif
6034 + " .set mips0 \n"
6035 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6036 + : "Ir" (i));
6037 + } else if (kernel_uses_llsc) {
6038 + __asm__ __volatile__(
6039 + " .set mips3 \n"
6040 + "1: lld %1, %2 # atomic64_add_return \n"
6041 +#ifdef CONFIG_PAX_REFCOUNT
6042 + "2: dadd %0, %1, %3 \n"
6043 +#else
6044 + " daddu %0, %1, %3 \n"
6045 +#endif
6046 + " scd %0, %2 \n"
6047 + " bnez %0, 4f \n"
6048 + " b 1b \n"
6049 +#ifdef CONFIG_PAX_REFCOUNT
6050 + " .set noreorder \n"
6051 + "3: b 5f \n"
6052 + " move %0, %1 \n"
6053 + " .set reorder \n"
6054 + _ASM_EXTABLE(2b, 3b)
6055 +#endif
6056 + "4: daddu %0, %1, %3 \n"
6057 +#ifdef CONFIG_PAX_REFCOUNT
6058 + "5: \n"
6059 +#endif
6060 + " .set mips0 \n"
6061 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6062 + : "Ir" (i), "m" (v->counter)
6063 + : "memory");
6064 + } else {
6065 + unsigned long flags;
6066 +
6067 + raw_local_irq_save(flags);
6068 + __asm__ __volatile__(
6069 + " ld %0, %1 \n"
6070 +#ifdef CONFIG_PAX_REFCOUNT
6071 + /* Exception on overflow. */
6072 + "1: dadd %0, %2 \n"
6073 +#else
6074 + " daddu %0, %2 \n"
6075 +#endif
6076 + " sd %0, %1 \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + /* Note: Dest reg is not modified on overflow */
6079 + "2: \n"
6080 + _ASM_EXTABLE(1b, 2b)
6081 +#endif
6082 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6083 + raw_local_irq_restore(flags);
6084 + }
6085 +
6086 + smp_llsc_mb();
6087 +
6088 + return result;
6089 +}
6090 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6091 {
6092 long result;
6093
6094 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6095 return result;
6096 }
6097
6098 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6099 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6100 +{
6101 + long result;
6102 + long temp;
6103 +
6104 + smp_mb__before_llsc();
6105 +
6106 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6107 + long temp;
6108 +
6109 + __asm__ __volatile__(
6110 + " .set mips3 \n"
6111 + "1: lld %1, %2 # atomic64_sub_return \n"
6112 +#ifdef CONFIG_PAX_REFCOUNT
6113 + "2: dsub %0, %1, %3 \n"
6114 +#else
6115 + " dsubu %0, %1, %3 \n"
6116 +#endif
6117 + " scd %0, %2 \n"
6118 + " beqzl %0, 1b \n"
6119 +#ifdef CONFIG_PAX_REFCOUNT
6120 + " b 4f \n"
6121 + " .set noreorder \n"
6122 + "3: b 5f \n"
6123 + " move %0, %1 \n"
6124 + " .set reorder \n"
6125 + _ASM_EXTABLE(2b, 3b)
6126 +#endif
6127 + "4: dsubu %0, %1, %3 \n"
6128 +#ifdef CONFIG_PAX_REFCOUNT
6129 + "5: \n"
6130 +#endif
6131 + " .set mips0 \n"
6132 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6133 + : "Ir" (i), "m" (v->counter)
6134 + : "memory");
6135 + } else if (kernel_uses_llsc) {
6136 + __asm__ __volatile__(
6137 + " .set mips3 \n"
6138 + "1: lld %1, %2 # atomic64_sub_return \n"
6139 +#ifdef CONFIG_PAX_REFCOUNT
6140 + "2: dsub %0, %1, %3 \n"
6141 +#else
6142 + " dsubu %0, %1, %3 \n"
6143 +#endif
6144 + " scd %0, %2 \n"
6145 + " bnez %0, 4f \n"
6146 + " b 1b \n"
6147 +#ifdef CONFIG_PAX_REFCOUNT
6148 + " .set noreorder \n"
6149 + "3: b 5f \n"
6150 + " move %0, %1 \n"
6151 + " .set reorder \n"
6152 + _ASM_EXTABLE(2b, 3b)
6153 +#endif
6154 + "4: dsubu %0, %1, %3 \n"
6155 +#ifdef CONFIG_PAX_REFCOUNT
6156 + "5: \n"
6157 +#endif
6158 + " .set mips0 \n"
6159 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6160 + : "Ir" (i), "m" (v->counter)
6161 + : "memory");
6162 + } else {
6163 + unsigned long flags;
6164 +
6165 + raw_local_irq_save(flags);
6166 + __asm__ __volatile__(
6167 + " ld %0, %1 \n"
6168 +#ifdef CONFIG_PAX_REFCOUNT
6169 + /* Exception on overflow. */
6170 + "1: dsub %0, %2 \n"
6171 +#else
6172 + " dsubu %0, %2 \n"
6173 +#endif
6174 + " sd %0, %1 \n"
6175 +#ifdef CONFIG_PAX_REFCOUNT
6176 + /* Note: Dest reg is not modified on overflow */
6177 + "2: \n"
6178 + _ASM_EXTABLE(1b, 2b)
6179 +#endif
6180 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6181 + raw_local_irq_restore(flags);
6182 + }
6183 +
6184 + smp_llsc_mb();
6185 +
6186 + return result;
6187 +}
6188 +
6189 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6190 {
6191 long result;
6192
6193 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6194 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6195 * The function returns the old value of @v minus @i.
6196 */
6197 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6198 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6199 {
6200 long result;
6201
6202 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6203 return result;
6204 }
6205
6206 -#define atomic64_cmpxchg(v, o, n) \
6207 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6208 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6209 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6210 +{
6211 + return cmpxchg(&v->counter, old, new);
6212 +}
6213 +
6214 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6215 + long new)
6216 +{
6217 + return cmpxchg(&(v->counter), old, new);
6218 +}
6219 +
6220 +static inline long atomic64_xchg(atomic64_t *v, long new)
6221 +{
6222 + return xchg(&v->counter, new);
6223 +}
6224 +
6225 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6226 +{
6227 + return xchg(&(v->counter), new);
6228 +}
6229
6230 /**
6231 * atomic64_add_unless - add unless the number is a given value
6232 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6233
6234 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6235 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6236 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6237
6238 /*
6239 * atomic64_sub_and_test - subtract value from variable and test result
6240 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6241 * other cases.
6242 */
6243 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6244 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6245
6246 /*
6247 * atomic64_dec_and_test - decrement by 1 and test
6248 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6249 * Atomically increments @v by 1.
6250 */
6251 #define atomic64_inc(v) atomic64_add(1, (v))
6252 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6253
6254 /*
6255 * atomic64_dec - decrement and test
6256 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6257 * Atomically decrements @v by 1.
6258 */
6259 #define atomic64_dec(v) atomic64_sub(1, (v))
6260 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6261
6262 /*
6263 * atomic64_add_negative - add and test if negative
6264 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6265 index b4db69f..8f3b093 100644
6266 --- a/arch/mips/include/asm/cache.h
6267 +++ b/arch/mips/include/asm/cache.h
6268 @@ -9,10 +9,11 @@
6269 #ifndef _ASM_CACHE_H
6270 #define _ASM_CACHE_H
6271
6272 +#include <linux/const.h>
6273 #include <kmalloc.h>
6274
6275 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6276 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6277 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6278
6279 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6280 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6281 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6282 index cf3ae24..238d22f 100644
6283 --- a/arch/mips/include/asm/elf.h
6284 +++ b/arch/mips/include/asm/elf.h
6285 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6286 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6287 #endif
6288
6289 +#ifdef CONFIG_PAX_ASLR
6290 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6291 +
6292 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6293 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6294 +#endif
6295 +
6296 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6297 struct linux_binprm;
6298 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6299 int uses_interp);
6300
6301 -struct mm_struct;
6302 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6303 -#define arch_randomize_brk arch_randomize_brk
6304 -
6305 #endif /* _ASM_ELF_H */
6306 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6307 index c1f6afa..38cc6e9 100644
6308 --- a/arch/mips/include/asm/exec.h
6309 +++ b/arch/mips/include/asm/exec.h
6310 @@ -12,6 +12,6 @@
6311 #ifndef _ASM_EXEC_H
6312 #define _ASM_EXEC_H
6313
6314 -extern unsigned long arch_align_stack(unsigned long sp);
6315 +#define arch_align_stack(x) ((x) & ~0xfUL)
6316
6317 #endif /* _ASM_EXEC_H */
6318 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6319 index d44622c..64990d2 100644
6320 --- a/arch/mips/include/asm/local.h
6321 +++ b/arch/mips/include/asm/local.h
6322 @@ -12,15 +12,25 @@ typedef struct
6323 atomic_long_t a;
6324 } local_t;
6325
6326 +typedef struct {
6327 + atomic_long_unchecked_t a;
6328 +} local_unchecked_t;
6329 +
6330 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6331
6332 #define local_read(l) atomic_long_read(&(l)->a)
6333 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6334 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6335 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6336
6337 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6338 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6339 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6340 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6341 #define local_inc(l) atomic_long_inc(&(l)->a)
6342 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6343 #define local_dec(l) atomic_long_dec(&(l)->a)
6344 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6345
6346 /*
6347 * Same as above, but return the result value
6348 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6349 return result;
6350 }
6351
6352 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6353 +{
6354 + unsigned long result;
6355 +
6356 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6357 + unsigned long temp;
6358 +
6359 + __asm__ __volatile__(
6360 + " .set mips3 \n"
6361 + "1:" __LL "%1, %2 # local_add_return \n"
6362 + " addu %0, %1, %3 \n"
6363 + __SC "%0, %2 \n"
6364 + " beqzl %0, 1b \n"
6365 + " addu %0, %1, %3 \n"
6366 + " .set mips0 \n"
6367 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6368 + : "Ir" (i), "m" (l->a.counter)
6369 + : "memory");
6370 + } else if (kernel_uses_llsc) {
6371 + unsigned long temp;
6372 +
6373 + __asm__ __volatile__(
6374 + " .set mips3 \n"
6375 + "1:" __LL "%1, %2 # local_add_return \n"
6376 + " addu %0, %1, %3 \n"
6377 + __SC "%0, %2 \n"
6378 + " beqz %0, 1b \n"
6379 + " addu %0, %1, %3 \n"
6380 + " .set mips0 \n"
6381 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6382 + : "Ir" (i), "m" (l->a.counter)
6383 + : "memory");
6384 + } else {
6385 + unsigned long flags;
6386 +
6387 + local_irq_save(flags);
6388 + result = l->a.counter;
6389 + result += i;
6390 + l->a.counter = result;
6391 + local_irq_restore(flags);
6392 + }
6393 +
6394 + return result;
6395 +}
6396 +
6397 static __inline__ long local_sub_return(long i, local_t * l)
6398 {
6399 unsigned long result;
6400 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6401
6402 #define local_cmpxchg(l, o, n) \
6403 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6404 +#define local_cmpxchg_unchecked(l, o, n) \
6405 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6406 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6407
6408 /**
6409 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6410 index f6be474..12ad554 100644
6411 --- a/arch/mips/include/asm/page.h
6412 +++ b/arch/mips/include/asm/page.h
6413 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6414 #ifdef CONFIG_CPU_MIPS32
6415 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6416 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6417 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6418 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6419 #else
6420 typedef struct { unsigned long long pte; } pte_t;
6421 #define pte_val(x) ((x).pte)
6422 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6423 index 881d18b..cea38bc 100644
6424 --- a/arch/mips/include/asm/pgalloc.h
6425 +++ b/arch/mips/include/asm/pgalloc.h
6426 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6427 {
6428 set_pud(pud, __pud((unsigned long)pmd));
6429 }
6430 +
6431 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6432 +{
6433 + pud_populate(mm, pud, pmd);
6434 +}
6435 #endif
6436
6437 /*
6438 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6439 index 25da651..ae2a259 100644
6440 --- a/arch/mips/include/asm/smtc_proc.h
6441 +++ b/arch/mips/include/asm/smtc_proc.h
6442 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6443
6444 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6445
6446 -extern atomic_t smtc_fpu_recoveries;
6447 +extern atomic_unchecked_t smtc_fpu_recoveries;
6448
6449 #endif /* __ASM_SMTC_PROC_H */
6450 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6451 index 61215a3..213ee0e 100644
6452 --- a/arch/mips/include/asm/thread_info.h
6453 +++ b/arch/mips/include/asm/thread_info.h
6454 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6455 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6456 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6457 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6458 +/* li takes a 32bit immediate */
6459 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6460 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6461
6462 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6463 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6464 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6465 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6466 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6467 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6468
6469 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6470 - _TIF_SYSCALL_AUDIT)
6471 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6472
6473 /* work to do in syscall_trace_leave() */
6474 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6475 - _TIF_SYSCALL_AUDIT)
6476 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6477
6478 /* work to do on interrupt/exception return */
6479 #define _TIF_WORK_MASK \
6480 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6481 /* work to do on any return to u-space */
6482 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6483 - _TIF_WORK_SYSCALL_EXIT)
6484 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6485
6486 #endif /* __KERNEL__ */
6487
6488 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6489 index 1188e00..41cf144 100644
6490 --- a/arch/mips/kernel/binfmt_elfn32.c
6491 +++ b/arch/mips/kernel/binfmt_elfn32.c
6492 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6493 #undef ELF_ET_DYN_BASE
6494 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6495
6496 +#ifdef CONFIG_PAX_ASLR
6497 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6498 +
6499 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6500 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#endif
6502 +
6503 #include <asm/processor.h>
6504 #include <linux/module.h>
6505 #include <linux/elfcore.h>
6506 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6507 index 202e581..689ca79 100644
6508 --- a/arch/mips/kernel/binfmt_elfo32.c
6509 +++ b/arch/mips/kernel/binfmt_elfo32.c
6510 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6511 #undef ELF_ET_DYN_BASE
6512 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6513
6514 +#ifdef CONFIG_PAX_ASLR
6515 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6516 +
6517 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6518 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6519 +#endif
6520 +
6521 #include <asm/processor.h>
6522
6523 /*
6524 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6525 index d1fea7a..45602ea 100644
6526 --- a/arch/mips/kernel/irq.c
6527 +++ b/arch/mips/kernel/irq.c
6528 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6529 printk("unexpected IRQ # %d\n", irq);
6530 }
6531
6532 -atomic_t irq_err_count;
6533 +atomic_unchecked_t irq_err_count;
6534
6535 int arch_show_interrupts(struct seq_file *p, int prec)
6536 {
6537 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6538 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6539 return 0;
6540 }
6541
6542 asmlinkage void spurious_interrupt(void)
6543 {
6544 - atomic_inc(&irq_err_count);
6545 + atomic_inc_unchecked(&irq_err_count);
6546 }
6547
6548 void __init init_IRQ(void)
6549 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6550 index ddc7610..8c58f17 100644
6551 --- a/arch/mips/kernel/process.c
6552 +++ b/arch/mips/kernel/process.c
6553 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6554 out:
6555 return pc;
6556 }
6557 -
6558 -/*
6559 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6560 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6561 - */
6562 -unsigned long arch_align_stack(unsigned long sp)
6563 -{
6564 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6565 - sp -= get_random_int() & ~PAGE_MASK;
6566 -
6567 - return sp & ALMASK;
6568 -}
6569 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6570 index 8ae1ebe..1bcbf47 100644
6571 --- a/arch/mips/kernel/ptrace.c
6572 +++ b/arch/mips/kernel/ptrace.c
6573 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6574 return arch;
6575 }
6576
6577 +#ifdef CONFIG_GRKERNSEC_SETXID
6578 +extern void gr_delayed_cred_worker(void);
6579 +#endif
6580 +
6581 /*
6582 * Notification of system call entry/exit
6583 * - triggered by current->work.syscall_trace
6584 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6585 /* do the secure computing check first */
6586 secure_computing_strict(regs->regs[2]);
6587
6588 +#ifdef CONFIG_GRKERNSEC_SETXID
6589 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6590 + gr_delayed_cred_worker();
6591 +#endif
6592 +
6593 if (!(current->ptrace & PT_PTRACED))
6594 goto out;
6595
6596 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6597 index c10aa84..9ec2e60 100644
6598 --- a/arch/mips/kernel/smtc-proc.c
6599 +++ b/arch/mips/kernel/smtc-proc.c
6600 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6601
6602 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6603
6604 -atomic_t smtc_fpu_recoveries;
6605 +atomic_unchecked_t smtc_fpu_recoveries;
6606
6607 static int smtc_proc_show(struct seq_file *m, void *v)
6608 {
6609 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6610 for(i = 0; i < NR_CPUS; i++)
6611 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6612 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6613 - atomic_read(&smtc_fpu_recoveries));
6614 + atomic_read_unchecked(&smtc_fpu_recoveries));
6615 return 0;
6616 }
6617
6618 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6619 smtc_cpu_stats[i].selfipis = 0;
6620 }
6621
6622 - atomic_set(&smtc_fpu_recoveries, 0);
6623 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6624
6625 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6626 }
6627 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6628 index dfc1b91..11a2c07 100644
6629 --- a/arch/mips/kernel/smtc.c
6630 +++ b/arch/mips/kernel/smtc.c
6631 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6632 }
6633 smtc_ipi_qdump();
6634 printk("%d Recoveries of \"stolen\" FPU\n",
6635 - atomic_read(&smtc_fpu_recoveries));
6636 + atomic_read_unchecked(&smtc_fpu_recoveries));
6637 }
6638
6639
6640 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6641 index 84536bf..79caa4d 100644
6642 --- a/arch/mips/kernel/sync-r4k.c
6643 +++ b/arch/mips/kernel/sync-r4k.c
6644 @@ -21,8 +21,8 @@
6645 #include <asm/mipsregs.h>
6646
6647 static atomic_t count_start_flag = ATOMIC_INIT(0);
6648 -static atomic_t count_count_start = ATOMIC_INIT(0);
6649 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6650 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6651 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6652 static atomic_t count_reference = ATOMIC_INIT(0);
6653
6654 #define COUNTON 100
6655 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6656
6657 for (i = 0; i < NR_LOOPS; i++) {
6658 /* slaves loop on '!= 2' */
6659 - while (atomic_read(&count_count_start) != 1)
6660 + while (atomic_read_unchecked(&count_count_start) != 1)
6661 mb();
6662 - atomic_set(&count_count_stop, 0);
6663 + atomic_set_unchecked(&count_count_stop, 0);
6664 smp_wmb();
6665
6666 /* this lets the slaves write their count register */
6667 - atomic_inc(&count_count_start);
6668 + atomic_inc_unchecked(&count_count_start);
6669
6670 /*
6671 * Everyone initialises count in the last loop:
6672 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6673 /*
6674 * Wait for all slaves to leave the synchronization point:
6675 */
6676 - while (atomic_read(&count_count_stop) != 1)
6677 + while (atomic_read_unchecked(&count_count_stop) != 1)
6678 mb();
6679 - atomic_set(&count_count_start, 0);
6680 + atomic_set_unchecked(&count_count_start, 0);
6681 smp_wmb();
6682 - atomic_inc(&count_count_stop);
6683 + atomic_inc_unchecked(&count_count_stop);
6684 }
6685 /* Arrange for an interrupt in a short while */
6686 write_c0_compare(read_c0_count() + COUNTON);
6687 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6688 initcount = atomic_read(&count_reference);
6689
6690 for (i = 0; i < NR_LOOPS; i++) {
6691 - atomic_inc(&count_count_start);
6692 - while (atomic_read(&count_count_start) != 2)
6693 + atomic_inc_unchecked(&count_count_start);
6694 + while (atomic_read_unchecked(&count_count_start) != 2)
6695 mb();
6696
6697 /*
6698 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6699 if (i == NR_LOOPS-1)
6700 write_c0_count(initcount);
6701
6702 - atomic_inc(&count_count_stop);
6703 - while (atomic_read(&count_count_stop) != 2)
6704 + atomic_inc_unchecked(&count_count_stop);
6705 + while (atomic_read_unchecked(&count_count_stop) != 2)
6706 mb();
6707 }
6708 /* Arrange for an interrupt in a short while */
6709 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6710 index 524841f..3eef41e 100644
6711 --- a/arch/mips/kernel/traps.c
6712 +++ b/arch/mips/kernel/traps.c
6713 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6714 siginfo_t info;
6715
6716 prev_state = exception_enter();
6717 - die_if_kernel("Integer overflow", regs);
6718 + if (unlikely(!user_mode(regs))) {
6719 +
6720 +#ifdef CONFIG_PAX_REFCOUNT
6721 + if (fixup_exception(regs)) {
6722 + pax_report_refcount_overflow(regs);
6723 + exception_exit(prev_state);
6724 + return;
6725 + }
6726 +#endif
6727 +
6728 + die("Integer overflow", regs);
6729 + }
6730
6731 info.si_code = FPE_INTOVF;
6732 info.si_signo = SIGFPE;
6733 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6734 index becc42b..9e43d4b 100644
6735 --- a/arch/mips/mm/fault.c
6736 +++ b/arch/mips/mm/fault.c
6737 @@ -28,6 +28,23 @@
6738 #include <asm/highmem.h> /* For VMALLOC_END */
6739 #include <linux/kdebug.h>
6740
6741 +#ifdef CONFIG_PAX_PAGEEXEC
6742 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6743 +{
6744 + unsigned long i;
6745 +
6746 + printk(KERN_ERR "PAX: bytes at PC: ");
6747 + for (i = 0; i < 5; i++) {
6748 + unsigned int c;
6749 + if (get_user(c, (unsigned int *)pc+i))
6750 + printk(KERN_CONT "???????? ");
6751 + else
6752 + printk(KERN_CONT "%08x ", c);
6753 + }
6754 + printk("\n");
6755 +}
6756 +#endif
6757 +
6758 /*
6759 * This routine handles page faults. It determines the address,
6760 * and the problem, and then passes it off to one of the appropriate
6761 @@ -199,6 +216,14 @@ bad_area:
6762 bad_area_nosemaphore:
6763 /* User mode accesses just cause a SIGSEGV */
6764 if (user_mode(regs)) {
6765 +
6766 +#ifdef CONFIG_PAX_PAGEEXEC
6767 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6768 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6769 + do_group_exit(SIGKILL);
6770 + }
6771 +#endif
6772 +
6773 tsk->thread.cp0_badvaddr = address;
6774 tsk->thread.error_code = write;
6775 #if 0
6776 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6777 index f1baadd..8537544 100644
6778 --- a/arch/mips/mm/mmap.c
6779 +++ b/arch/mips/mm/mmap.c
6780 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6781 struct vm_area_struct *vma;
6782 unsigned long addr = addr0;
6783 int do_color_align;
6784 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6785 struct vm_unmapped_area_info info;
6786
6787 if (unlikely(len > TASK_SIZE))
6788 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6789 do_color_align = 1;
6790
6791 /* requesting a specific address */
6792 +
6793 +#ifdef CONFIG_PAX_RANDMMAP
6794 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6795 +#endif
6796 +
6797 if (addr) {
6798 if (do_color_align)
6799 addr = COLOUR_ALIGN(addr, pgoff);
6800 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6801 addr = PAGE_ALIGN(addr);
6802
6803 vma = find_vma(mm, addr);
6804 - if (TASK_SIZE - len >= addr &&
6805 - (!vma || addr + len <= vma->vm_start))
6806 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6807 return addr;
6808 }
6809
6810 info.length = len;
6811 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6812 info.align_offset = pgoff << PAGE_SHIFT;
6813 + info.threadstack_offset = offset;
6814
6815 if (dir == DOWN) {
6816 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6817 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6818 {
6819 unsigned long random_factor = 0UL;
6820
6821 +#ifdef CONFIG_PAX_RANDMMAP
6822 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6823 +#endif
6824 +
6825 if (current->flags & PF_RANDOMIZE) {
6826 random_factor = get_random_int();
6827 random_factor = random_factor << PAGE_SHIFT;
6828 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6829
6830 if (mmap_is_legacy()) {
6831 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6832 +
6833 +#ifdef CONFIG_PAX_RANDMMAP
6834 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6835 + mm->mmap_base += mm->delta_mmap;
6836 +#endif
6837 +
6838 mm->get_unmapped_area = arch_get_unmapped_area;
6839 } else {
6840 mm->mmap_base = mmap_base(random_factor);
6841 +
6842 +#ifdef CONFIG_PAX_RANDMMAP
6843 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6844 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6845 +#endif
6846 +
6847 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6848 }
6849 }
6850
6851 -static inline unsigned long brk_rnd(void)
6852 -{
6853 - unsigned long rnd = get_random_int();
6854 -
6855 - rnd = rnd << PAGE_SHIFT;
6856 - /* 8MB for 32bit, 256MB for 64bit */
6857 - if (TASK_IS_32BIT_ADDR)
6858 - rnd = rnd & 0x7ffffful;
6859 - else
6860 - rnd = rnd & 0xffffffful;
6861 -
6862 - return rnd;
6863 -}
6864 -
6865 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6866 -{
6867 - unsigned long base = mm->brk;
6868 - unsigned long ret;
6869 -
6870 - ret = PAGE_ALIGN(base + brk_rnd());
6871 -
6872 - if (ret < mm->brk)
6873 - return mm->brk;
6874 -
6875 - return ret;
6876 -}
6877 -
6878 int __virt_addr_valid(const volatile void *kaddr)
6879 {
6880 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6881 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6882 index a2358b4..7cead4f 100644
6883 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6884 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6885 @@ -187,9 +187,9 @@ void
6886 cont_nmi_dump(void)
6887 {
6888 #ifndef REAL_NMI_SIGNAL
6889 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6890 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6891
6892 - atomic_inc(&nmied_cpus);
6893 + atomic_inc_unchecked(&nmied_cpus);
6894 #endif
6895 /*
6896 * Only allow 1 cpu to proceed
6897 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6898 udelay(10000);
6899 }
6900 #else
6901 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6902 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6903 #endif
6904
6905 /*
6906 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6907 index 967d144..db12197 100644
6908 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6909 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6910 @@ -11,12 +11,14 @@
6911 #ifndef _ASM_PROC_CACHE_H
6912 #define _ASM_PROC_CACHE_H
6913
6914 +#include <linux/const.h>
6915 +
6916 /* L1 cache */
6917
6918 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6919 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6920 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6921 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6922 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6923 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6924
6925 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6926 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6927 index bcb5df2..84fabd2 100644
6928 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6929 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6930 @@ -16,13 +16,15 @@
6931 #ifndef _ASM_PROC_CACHE_H
6932 #define _ASM_PROC_CACHE_H
6933
6934 +#include <linux/const.h>
6935 +
6936 /*
6937 * L1 cache
6938 */
6939 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6940 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6941 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6942 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6943 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6944 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6945
6946 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6947 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6948 index 4ce7a01..449202a 100644
6949 --- a/arch/openrisc/include/asm/cache.h
6950 +++ b/arch/openrisc/include/asm/cache.h
6951 @@ -19,11 +19,13 @@
6952 #ifndef __ASM_OPENRISC_CACHE_H
6953 #define __ASM_OPENRISC_CACHE_H
6954
6955 +#include <linux/const.h>
6956 +
6957 /* FIXME: How can we replace these with values from the CPU...
6958 * they shouldn't be hard-coded!
6959 */
6960
6961 -#define L1_CACHE_BYTES 16
6962 #define L1_CACHE_SHIFT 4
6963 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6964
6965 #endif /* __ASM_OPENRISC_CACHE_H */
6966 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6967 index 472886c..00e7df9 100644
6968 --- a/arch/parisc/include/asm/atomic.h
6969 +++ b/arch/parisc/include/asm/atomic.h
6970 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6971 return dec;
6972 }
6973
6974 +#define atomic64_read_unchecked(v) atomic64_read(v)
6975 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6976 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6977 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6978 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6979 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6980 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6981 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6982 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6983 +
6984 #endif /* !CONFIG_64BIT */
6985
6986
6987 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6988 index 47f11c7..3420df2 100644
6989 --- a/arch/parisc/include/asm/cache.h
6990 +++ b/arch/parisc/include/asm/cache.h
6991 @@ -5,6 +5,7 @@
6992 #ifndef __ARCH_PARISC_CACHE_H
6993 #define __ARCH_PARISC_CACHE_H
6994
6995 +#include <linux/const.h>
6996
6997 /*
6998 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6999 @@ -15,13 +16,13 @@
7000 * just ruin performance.
7001 */
7002 #ifdef CONFIG_PA20
7003 -#define L1_CACHE_BYTES 64
7004 #define L1_CACHE_SHIFT 6
7005 #else
7006 -#define L1_CACHE_BYTES 32
7007 #define L1_CACHE_SHIFT 5
7008 #endif
7009
7010 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7011 +
7012 #ifndef __ASSEMBLY__
7013
7014 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7015 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7016 index ad2b503..bdf1651 100644
7017 --- a/arch/parisc/include/asm/elf.h
7018 +++ b/arch/parisc/include/asm/elf.h
7019 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7020
7021 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7022
7023 +#ifdef CONFIG_PAX_ASLR
7024 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7025 +
7026 +#define PAX_DELTA_MMAP_LEN 16
7027 +#define PAX_DELTA_STACK_LEN 16
7028 +#endif
7029 +
7030 /* This yields a mask that user programs can use to figure out what
7031 instruction set this CPU supports. This could be done in user space,
7032 but it's not easy, and we've already done it here. */
7033 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7034 index fc987a1..6e068ef 100644
7035 --- a/arch/parisc/include/asm/pgalloc.h
7036 +++ b/arch/parisc/include/asm/pgalloc.h
7037 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7038 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7039 }
7040
7041 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7042 +{
7043 + pgd_populate(mm, pgd, pmd);
7044 +}
7045 +
7046 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7047 {
7048 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7049 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7050 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7051 #define pmd_free(mm, x) do { } while (0)
7052 #define pgd_populate(mm, pmd, pte) BUG()
7053 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7054
7055 #endif
7056
7057 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7058 index 34899b5..02dd060 100644
7059 --- a/arch/parisc/include/asm/pgtable.h
7060 +++ b/arch/parisc/include/asm/pgtable.h
7061 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7062 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7063 #define PAGE_COPY PAGE_EXECREAD
7064 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7065 +
7066 +#ifdef CONFIG_PAX_PAGEEXEC
7067 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7068 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7069 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7070 +#else
7071 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7072 +# define PAGE_COPY_NOEXEC PAGE_COPY
7073 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7074 +#endif
7075 +
7076 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7077 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7078 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7079 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7080 index e0a8235..ce2f1e1 100644
7081 --- a/arch/parisc/include/asm/uaccess.h
7082 +++ b/arch/parisc/include/asm/uaccess.h
7083 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7084 const void __user *from,
7085 unsigned long n)
7086 {
7087 - int sz = __compiletime_object_size(to);
7088 + size_t sz = __compiletime_object_size(to);
7089 int ret = -EFAULT;
7090
7091 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7092 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7093 ret = __copy_from_user(to, from, n);
7094 else
7095 copy_from_user_overflow();
7096 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7097 index 2a625fb..9908930 100644
7098 --- a/arch/parisc/kernel/module.c
7099 +++ b/arch/parisc/kernel/module.c
7100 @@ -98,16 +98,38 @@
7101
7102 /* three functions to determine where in the module core
7103 * or init pieces the location is */
7104 +static inline int in_init_rx(struct module *me, void *loc)
7105 +{
7106 + return (loc >= me->module_init_rx &&
7107 + loc < (me->module_init_rx + me->init_size_rx));
7108 +}
7109 +
7110 +static inline int in_init_rw(struct module *me, void *loc)
7111 +{
7112 + return (loc >= me->module_init_rw &&
7113 + loc < (me->module_init_rw + me->init_size_rw));
7114 +}
7115 +
7116 static inline int in_init(struct module *me, void *loc)
7117 {
7118 - return (loc >= me->module_init &&
7119 - loc <= (me->module_init + me->init_size));
7120 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7121 +}
7122 +
7123 +static inline int in_core_rx(struct module *me, void *loc)
7124 +{
7125 + return (loc >= me->module_core_rx &&
7126 + loc < (me->module_core_rx + me->core_size_rx));
7127 +}
7128 +
7129 +static inline int in_core_rw(struct module *me, void *loc)
7130 +{
7131 + return (loc >= me->module_core_rw &&
7132 + loc < (me->module_core_rw + me->core_size_rw));
7133 }
7134
7135 static inline int in_core(struct module *me, void *loc)
7136 {
7137 - return (loc >= me->module_core &&
7138 - loc <= (me->module_core + me->core_size));
7139 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7140 }
7141
7142 static inline int in_local(struct module *me, void *loc)
7143 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7144 }
7145
7146 /* align things a bit */
7147 - me->core_size = ALIGN(me->core_size, 16);
7148 - me->arch.got_offset = me->core_size;
7149 - me->core_size += gots * sizeof(struct got_entry);
7150 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7151 + me->arch.got_offset = me->core_size_rw;
7152 + me->core_size_rw += gots * sizeof(struct got_entry);
7153
7154 - me->core_size = ALIGN(me->core_size, 16);
7155 - me->arch.fdesc_offset = me->core_size;
7156 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7157 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7158 + me->arch.fdesc_offset = me->core_size_rw;
7159 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7160
7161 me->arch.got_max = gots;
7162 me->arch.fdesc_max = fdescs;
7163 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7164
7165 BUG_ON(value == 0);
7166
7167 - got = me->module_core + me->arch.got_offset;
7168 + got = me->module_core_rw + me->arch.got_offset;
7169 for (i = 0; got[i].addr; i++)
7170 if (got[i].addr == value)
7171 goto out;
7172 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7173 #ifdef CONFIG_64BIT
7174 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7175 {
7176 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7177 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7178
7179 if (!value) {
7180 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7181 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7182
7183 /* Create new one */
7184 fdesc->addr = value;
7185 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7186 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7187 return (Elf_Addr)fdesc;
7188 }
7189 #endif /* CONFIG_64BIT */
7190 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7191
7192 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7193 end = table + sechdrs[me->arch.unwind_section].sh_size;
7194 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7195 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7196
7197 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7198 me->arch.unwind_section, table, end, gp);
7199 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7200 index 5dfd248..64914ac 100644
7201 --- a/arch/parisc/kernel/sys_parisc.c
7202 +++ b/arch/parisc/kernel/sys_parisc.c
7203 @@ -33,9 +33,11 @@
7204 #include <linux/utsname.h>
7205 #include <linux/personality.h>
7206
7207 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7208 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7209 + unsigned long flags)
7210 {
7211 struct vm_unmapped_area_info info;
7212 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7213
7214 info.flags = 0;
7215 info.length = len;
7216 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7217 info.high_limit = TASK_SIZE;
7218 info.align_mask = 0;
7219 info.align_offset = 0;
7220 + info.threadstack_offset = offset;
7221 return vm_unmapped_area(&info);
7222 }
7223
7224 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7225 return (unsigned long) mapping >> 8;
7226 }
7227
7228 -static unsigned long get_shared_area(struct address_space *mapping,
7229 - unsigned long addr, unsigned long len, unsigned long pgoff)
7230 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7231 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7232 {
7233 struct vm_unmapped_area_info info;
7234 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7235
7236 info.flags = 0;
7237 info.length = len;
7238 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7239 info.high_limit = TASK_SIZE;
7240 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7241 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7242 + info.threadstack_offset = offset;
7243 return vm_unmapped_area(&info);
7244 }
7245
7246 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7247 return -EINVAL;
7248 return addr;
7249 }
7250 - if (!addr)
7251 + if (!addr) {
7252 addr = TASK_UNMAPPED_BASE;
7253
7254 +#ifdef CONFIG_PAX_RANDMMAP
7255 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7256 + addr += current->mm->delta_mmap;
7257 +#endif
7258 +
7259 + }
7260 +
7261 if (filp) {
7262 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7263 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7264 } else if(flags & MAP_SHARED) {
7265 - addr = get_shared_area(NULL, addr, len, pgoff);
7266 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7267 } else {
7268 - addr = get_unshared_area(addr, len);
7269 + addr = get_unshared_area(filp, addr, len, flags);
7270 }
7271 return addr;
7272 }
7273 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7274 index 1cd1d0c..44ec918 100644
7275 --- a/arch/parisc/kernel/traps.c
7276 +++ b/arch/parisc/kernel/traps.c
7277 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7278
7279 down_read(&current->mm->mmap_sem);
7280 vma = find_vma(current->mm,regs->iaoq[0]);
7281 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7282 - && (vma->vm_flags & VM_EXEC)) {
7283 -
7284 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7285 fault_address = regs->iaoq[0];
7286 fault_space = regs->iasq[0];
7287
7288 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7289 index 0293588..3b229aa 100644
7290 --- a/arch/parisc/mm/fault.c
7291 +++ b/arch/parisc/mm/fault.c
7292 @@ -15,6 +15,7 @@
7293 #include <linux/sched.h>
7294 #include <linux/interrupt.h>
7295 #include <linux/module.h>
7296 +#include <linux/unistd.h>
7297
7298 #include <asm/uaccess.h>
7299 #include <asm/traps.h>
7300 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7301 static unsigned long
7302 parisc_acctyp(unsigned long code, unsigned int inst)
7303 {
7304 - if (code == 6 || code == 16)
7305 + if (code == 6 || code == 7 || code == 16)
7306 return VM_EXEC;
7307
7308 switch (inst & 0xf0000000) {
7309 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7310 }
7311 #endif
7312
7313 +#ifdef CONFIG_PAX_PAGEEXEC
7314 +/*
7315 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7316 + *
7317 + * returns 1 when task should be killed
7318 + * 2 when rt_sigreturn trampoline was detected
7319 + * 3 when unpatched PLT trampoline was detected
7320 + */
7321 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7322 +{
7323 +
7324 +#ifdef CONFIG_PAX_EMUPLT
7325 + int err;
7326 +
7327 + do { /* PaX: unpatched PLT emulation */
7328 + unsigned int bl, depwi;
7329 +
7330 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7331 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7332 +
7333 + if (err)
7334 + break;
7335 +
7336 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7337 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7338 +
7339 + err = get_user(ldw, (unsigned int *)addr);
7340 + err |= get_user(bv, (unsigned int *)(addr+4));
7341 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7342 +
7343 + if (err)
7344 + break;
7345 +
7346 + if (ldw == 0x0E801096U &&
7347 + bv == 0xEAC0C000U &&
7348 + ldw2 == 0x0E881095U)
7349 + {
7350 + unsigned int resolver, map;
7351 +
7352 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7353 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7354 + if (err)
7355 + break;
7356 +
7357 + regs->gr[20] = instruction_pointer(regs)+8;
7358 + regs->gr[21] = map;
7359 + regs->gr[22] = resolver;
7360 + regs->iaoq[0] = resolver | 3UL;
7361 + regs->iaoq[1] = regs->iaoq[0] + 4;
7362 + return 3;
7363 + }
7364 + }
7365 + } while (0);
7366 +#endif
7367 +
7368 +#ifdef CONFIG_PAX_EMUTRAMP
7369 +
7370 +#ifndef CONFIG_PAX_EMUSIGRT
7371 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7372 + return 1;
7373 +#endif
7374 +
7375 + do { /* PaX: rt_sigreturn emulation */
7376 + unsigned int ldi1, ldi2, bel, nop;
7377 +
7378 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7379 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7380 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7381 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7382 +
7383 + if (err)
7384 + break;
7385 +
7386 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7387 + ldi2 == 0x3414015AU &&
7388 + bel == 0xE4008200U &&
7389 + nop == 0x08000240U)
7390 + {
7391 + regs->gr[25] = (ldi1 & 2) >> 1;
7392 + regs->gr[20] = __NR_rt_sigreturn;
7393 + regs->gr[31] = regs->iaoq[1] + 16;
7394 + regs->sr[0] = regs->iasq[1];
7395 + regs->iaoq[0] = 0x100UL;
7396 + regs->iaoq[1] = regs->iaoq[0] + 4;
7397 + regs->iasq[0] = regs->sr[2];
7398 + regs->iasq[1] = regs->sr[2];
7399 + return 2;
7400 + }
7401 + } while (0);
7402 +#endif
7403 +
7404 + return 1;
7405 +}
7406 +
7407 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7408 +{
7409 + unsigned long i;
7410 +
7411 + printk(KERN_ERR "PAX: bytes at PC: ");
7412 + for (i = 0; i < 5; i++) {
7413 + unsigned int c;
7414 + if (get_user(c, (unsigned int *)pc+i))
7415 + printk(KERN_CONT "???????? ");
7416 + else
7417 + printk(KERN_CONT "%08x ", c);
7418 + }
7419 + printk("\n");
7420 +}
7421 +#endif
7422 +
7423 int fixup_exception(struct pt_regs *regs)
7424 {
7425 const struct exception_table_entry *fix;
7426 @@ -204,8 +315,33 @@ retry:
7427
7428 good_area:
7429
7430 - if ((vma->vm_flags & acc_type) != acc_type)
7431 + if ((vma->vm_flags & acc_type) != acc_type) {
7432 +
7433 +#ifdef CONFIG_PAX_PAGEEXEC
7434 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7435 + (address & ~3UL) == instruction_pointer(regs))
7436 + {
7437 + up_read(&mm->mmap_sem);
7438 + switch (pax_handle_fetch_fault(regs)) {
7439 +
7440 +#ifdef CONFIG_PAX_EMUPLT
7441 + case 3:
7442 + return;
7443 +#endif
7444 +
7445 +#ifdef CONFIG_PAX_EMUTRAMP
7446 + case 2:
7447 + return;
7448 +#endif
7449 +
7450 + }
7451 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7452 + do_group_exit(SIGKILL);
7453 + }
7454 +#endif
7455 +
7456 goto bad_area;
7457 + }
7458
7459 /*
7460 * If for any reason at all we couldn't handle the fault, make
7461 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7462 index e3b1d41..8e81edf 100644
7463 --- a/arch/powerpc/include/asm/atomic.h
7464 +++ b/arch/powerpc/include/asm/atomic.h
7465 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7466 return t1;
7467 }
7468
7469 +#define atomic64_read_unchecked(v) atomic64_read(v)
7470 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7471 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7472 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7473 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7474 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7475 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7476 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7477 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7478 +
7479 #endif /* __powerpc64__ */
7480
7481 #endif /* __KERNEL__ */
7482 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7483 index 9e495c9..b6878e5 100644
7484 --- a/arch/powerpc/include/asm/cache.h
7485 +++ b/arch/powerpc/include/asm/cache.h
7486 @@ -3,6 +3,7 @@
7487
7488 #ifdef __KERNEL__
7489
7490 +#include <linux/const.h>
7491
7492 /* bytes per L1 cache line */
7493 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7494 @@ -22,7 +23,7 @@
7495 #define L1_CACHE_SHIFT 7
7496 #endif
7497
7498 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7499 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7500
7501 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7502
7503 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7504 index cc0655a..13eac2e 100644
7505 --- a/arch/powerpc/include/asm/elf.h
7506 +++ b/arch/powerpc/include/asm/elf.h
7507 @@ -28,8 +28,19 @@
7508 the loader. We need to make sure that it is out of the way of the program
7509 that it will "exec", and that there is sufficient room for the brk. */
7510
7511 -extern unsigned long randomize_et_dyn(unsigned long base);
7512 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7513 +#define ELF_ET_DYN_BASE (0x20000000)
7514 +
7515 +#ifdef CONFIG_PAX_ASLR
7516 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7517 +
7518 +#ifdef __powerpc64__
7519 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7520 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7521 +#else
7522 +#define PAX_DELTA_MMAP_LEN 15
7523 +#define PAX_DELTA_STACK_LEN 15
7524 +#endif
7525 +#endif
7526
7527 /*
7528 * Our registers are always unsigned longs, whether we're a 32 bit
7529 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7530 (0x7ff >> (PAGE_SHIFT - 12)) : \
7531 (0x3ffff >> (PAGE_SHIFT - 12)))
7532
7533 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7534 -#define arch_randomize_brk arch_randomize_brk
7535 -
7536 -
7537 #ifdef CONFIG_SPU_BASE
7538 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7539 #define NT_SPU 1
7540 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7541 index 8196e9c..d83a9f3 100644
7542 --- a/arch/powerpc/include/asm/exec.h
7543 +++ b/arch/powerpc/include/asm/exec.h
7544 @@ -4,6 +4,6 @@
7545 #ifndef _ASM_POWERPC_EXEC_H
7546 #define _ASM_POWERPC_EXEC_H
7547
7548 -extern unsigned long arch_align_stack(unsigned long sp);
7549 +#define arch_align_stack(x) ((x) & ~0xfUL)
7550
7551 #endif /* _ASM_POWERPC_EXEC_H */
7552 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7553 index 5acabbd..7ea14fa 100644
7554 --- a/arch/powerpc/include/asm/kmap_types.h
7555 +++ b/arch/powerpc/include/asm/kmap_types.h
7556 @@ -10,7 +10,7 @@
7557 * 2 of the License, or (at your option) any later version.
7558 */
7559
7560 -#define KM_TYPE_NR 16
7561 +#define KM_TYPE_NR 17
7562
7563 #endif /* __KERNEL__ */
7564 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7565 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7566 index 8565c25..2865190 100644
7567 --- a/arch/powerpc/include/asm/mman.h
7568 +++ b/arch/powerpc/include/asm/mman.h
7569 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7570 }
7571 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7572
7573 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7574 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7575 {
7576 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7577 }
7578 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7579 index b9f4262..dcf04f7 100644
7580 --- a/arch/powerpc/include/asm/page.h
7581 +++ b/arch/powerpc/include/asm/page.h
7582 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7583 * and needs to be executable. This means the whole heap ends
7584 * up being executable.
7585 */
7586 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7587 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7588 +#define VM_DATA_DEFAULT_FLAGS32 \
7589 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7590 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7591
7592 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7593 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7594 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7595 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7596 #endif
7597
7598 +#define ktla_ktva(addr) (addr)
7599 +#define ktva_ktla(addr) (addr)
7600 +
7601 #ifndef CONFIG_PPC_BOOK3S_64
7602 /*
7603 * Use the top bit of the higher-level page table entries to indicate whether
7604 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7605 index 88693ce..ac6f9ab 100644
7606 --- a/arch/powerpc/include/asm/page_64.h
7607 +++ b/arch/powerpc/include/asm/page_64.h
7608 @@ -153,15 +153,18 @@ do { \
7609 * stack by default, so in the absence of a PT_GNU_STACK program header
7610 * we turn execute permission off.
7611 */
7612 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7613 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7614 +#define VM_STACK_DEFAULT_FLAGS32 \
7615 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7616 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7617
7618 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7619 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7620
7621 +#ifndef CONFIG_PAX_PAGEEXEC
7622 #define VM_STACK_DEFAULT_FLAGS \
7623 (is_32bit_task() ? \
7624 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7625 +#endif
7626
7627 #include <asm-generic/getorder.h>
7628
7629 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7630 index f65e27b..23ffb5b 100644
7631 --- a/arch/powerpc/include/asm/pgalloc-64.h
7632 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7633 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7634 #ifndef CONFIG_PPC_64K_PAGES
7635
7636 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7637 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7638
7639 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7640 {
7641 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7642 pud_set(pud, (unsigned long)pmd);
7643 }
7644
7645 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7646 +{
7647 + pud_populate(mm, pud, pmd);
7648 +}
7649 +
7650 #define pmd_populate(mm, pmd, pte_page) \
7651 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7652 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7653 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7654 #endif
7655
7656 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7657 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7658
7659 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7660 pte_t *pte)
7661 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7662 index 7d6eacf..14c0240 100644
7663 --- a/arch/powerpc/include/asm/pgtable.h
7664 +++ b/arch/powerpc/include/asm/pgtable.h
7665 @@ -2,6 +2,7 @@
7666 #define _ASM_POWERPC_PGTABLE_H
7667 #ifdef __KERNEL__
7668
7669 +#include <linux/const.h>
7670 #ifndef __ASSEMBLY__
7671 #include <asm/processor.h> /* For TASK_SIZE */
7672 #include <asm/mmu.h>
7673 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7674 index 4aad413..85d86bf 100644
7675 --- a/arch/powerpc/include/asm/pte-hash32.h
7676 +++ b/arch/powerpc/include/asm/pte-hash32.h
7677 @@ -21,6 +21,7 @@
7678 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7679 #define _PAGE_USER 0x004 /* usermode access allowed */
7680 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7681 +#define _PAGE_EXEC _PAGE_GUARDED
7682 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7683 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7684 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7685 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7686 index 10d1ef0..8f83abc 100644
7687 --- a/arch/powerpc/include/asm/reg.h
7688 +++ b/arch/powerpc/include/asm/reg.h
7689 @@ -234,6 +234,7 @@
7690 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7691 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7692 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7693 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7694 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7695 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7696 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7697 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7698 index 98da78e..dc68271 100644
7699 --- a/arch/powerpc/include/asm/smp.h
7700 +++ b/arch/powerpc/include/asm/smp.h
7701 @@ -50,7 +50,7 @@ struct smp_ops_t {
7702 int (*cpu_disable)(void);
7703 void (*cpu_die)(unsigned int nr);
7704 int (*cpu_bootable)(unsigned int nr);
7705 -};
7706 +} __no_const;
7707
7708 extern void smp_send_debugger_break(void);
7709 extern void start_secondary_resume(void);
7710 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7711 index ba7b197..d292e26 100644
7712 --- a/arch/powerpc/include/asm/thread_info.h
7713 +++ b/arch/powerpc/include/asm/thread_info.h
7714 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7715 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7716 TIF_NEED_RESCHED */
7717 #define TIF_32BIT 4 /* 32 bit binary */
7718 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7719 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7720 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7721 #define TIF_SINGLESTEP 8 /* singlestepping active */
7722 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7723 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7724 for stack store? */
7725 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7726 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7727 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7728 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7729
7730 /* as above, but as bit values */
7731 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7732 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7733 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7734 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7735 #define _TIF_NOHZ (1<<TIF_NOHZ)
7736 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7737 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7738 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7739 - _TIF_NOHZ)
7740 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7741
7742 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7743 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7744 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7745 index 9485b43..4718d50 100644
7746 --- a/arch/powerpc/include/asm/uaccess.h
7747 +++ b/arch/powerpc/include/asm/uaccess.h
7748 @@ -318,52 +318,6 @@ do { \
7749 extern unsigned long __copy_tofrom_user(void __user *to,
7750 const void __user *from, unsigned long size);
7751
7752 -#ifndef __powerpc64__
7753 -
7754 -static inline unsigned long copy_from_user(void *to,
7755 - const void __user *from, unsigned long n)
7756 -{
7757 - unsigned long over;
7758 -
7759 - if (access_ok(VERIFY_READ, from, n))
7760 - return __copy_tofrom_user((__force void __user *)to, from, n);
7761 - if ((unsigned long)from < TASK_SIZE) {
7762 - over = (unsigned long)from + n - TASK_SIZE;
7763 - return __copy_tofrom_user((__force void __user *)to, from,
7764 - n - over) + over;
7765 - }
7766 - return n;
7767 -}
7768 -
7769 -static inline unsigned long copy_to_user(void __user *to,
7770 - const void *from, unsigned long n)
7771 -{
7772 - unsigned long over;
7773 -
7774 - if (access_ok(VERIFY_WRITE, to, n))
7775 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7776 - if ((unsigned long)to < TASK_SIZE) {
7777 - over = (unsigned long)to + n - TASK_SIZE;
7778 - return __copy_tofrom_user(to, (__force void __user *)from,
7779 - n - over) + over;
7780 - }
7781 - return n;
7782 -}
7783 -
7784 -#else /* __powerpc64__ */
7785 -
7786 -#define __copy_in_user(to, from, size) \
7787 - __copy_tofrom_user((to), (from), (size))
7788 -
7789 -extern unsigned long copy_from_user(void *to, const void __user *from,
7790 - unsigned long n);
7791 -extern unsigned long copy_to_user(void __user *to, const void *from,
7792 - unsigned long n);
7793 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7794 - unsigned long n);
7795 -
7796 -#endif /* __powerpc64__ */
7797 -
7798 static inline unsigned long __copy_from_user_inatomic(void *to,
7799 const void __user *from, unsigned long n)
7800 {
7801 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7802 if (ret == 0)
7803 return 0;
7804 }
7805 +
7806 + if (!__builtin_constant_p(n))
7807 + check_object_size(to, n, false);
7808 +
7809 return __copy_tofrom_user((__force void __user *)to, from, n);
7810 }
7811
7812 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7813 if (ret == 0)
7814 return 0;
7815 }
7816 +
7817 + if (!__builtin_constant_p(n))
7818 + check_object_size(from, n, true);
7819 +
7820 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7821 }
7822
7823 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7824 return __copy_to_user_inatomic(to, from, size);
7825 }
7826
7827 +#ifndef __powerpc64__
7828 +
7829 +static inline unsigned long __must_check copy_from_user(void *to,
7830 + const void __user *from, unsigned long n)
7831 +{
7832 + unsigned long over;
7833 +
7834 + if ((long)n < 0)
7835 + return n;
7836 +
7837 + if (access_ok(VERIFY_READ, from, n)) {
7838 + if (!__builtin_constant_p(n))
7839 + check_object_size(to, n, false);
7840 + return __copy_tofrom_user((__force void __user *)to, from, n);
7841 + }
7842 + if ((unsigned long)from < TASK_SIZE) {
7843 + over = (unsigned long)from + n - TASK_SIZE;
7844 + if (!__builtin_constant_p(n - over))
7845 + check_object_size(to, n - over, false);
7846 + return __copy_tofrom_user((__force void __user *)to, from,
7847 + n - over) + over;
7848 + }
7849 + return n;
7850 +}
7851 +
7852 +static inline unsigned long __must_check copy_to_user(void __user *to,
7853 + const void *from, unsigned long n)
7854 +{
7855 + unsigned long over;
7856 +
7857 + if ((long)n < 0)
7858 + return n;
7859 +
7860 + if (access_ok(VERIFY_WRITE, to, n)) {
7861 + if (!__builtin_constant_p(n))
7862 + check_object_size(from, n, true);
7863 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7864 + }
7865 + if ((unsigned long)to < TASK_SIZE) {
7866 + over = (unsigned long)to + n - TASK_SIZE;
7867 + if (!__builtin_constant_p(n))
7868 + check_object_size(from, n - over, true);
7869 + return __copy_tofrom_user(to, (__force void __user *)from,
7870 + n - over) + over;
7871 + }
7872 + return n;
7873 +}
7874 +
7875 +#else /* __powerpc64__ */
7876 +
7877 +#define __copy_in_user(to, from, size) \
7878 + __copy_tofrom_user((to), (from), (size))
7879 +
7880 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7881 +{
7882 + if ((long)n < 0 || n > INT_MAX)
7883 + return n;
7884 +
7885 + if (!__builtin_constant_p(n))
7886 + check_object_size(to, n, false);
7887 +
7888 + if (likely(access_ok(VERIFY_READ, from, n)))
7889 + n = __copy_from_user(to, from, n);
7890 + else
7891 + memset(to, 0, n);
7892 + return n;
7893 +}
7894 +
7895 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7896 +{
7897 + if ((long)n < 0 || n > INT_MAX)
7898 + return n;
7899 +
7900 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7901 + if (!__builtin_constant_p(n))
7902 + check_object_size(from, n, true);
7903 + n = __copy_to_user(to, from, n);
7904 + }
7905 + return n;
7906 +}
7907 +
7908 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7909 + unsigned long n);
7910 +
7911 +#endif /* __powerpc64__ */
7912 +
7913 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7914
7915 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7916 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7917 index 2d06704..1616f1b 100644
7918 --- a/arch/powerpc/kernel/exceptions-64e.S
7919 +++ b/arch/powerpc/kernel/exceptions-64e.S
7920 @@ -757,6 +757,7 @@ storage_fault_common:
7921 std r14,_DAR(r1)
7922 std r15,_DSISR(r1)
7923 addi r3,r1,STACK_FRAME_OVERHEAD
7924 + bl .save_nvgprs
7925 mr r4,r14
7926 mr r5,r15
7927 ld r14,PACA_EXGEN+EX_R14(r13)
7928 @@ -765,8 +766,7 @@ storage_fault_common:
7929 cmpdi r3,0
7930 bne- 1f
7931 b .ret_from_except_lite
7932 -1: bl .save_nvgprs
7933 - mr r5,r3
7934 +1: mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 ld r4,_DAR(r1)
7937 bl .bad_page_fault
7938 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7939 index 3a9ed6a..b534681 100644
7940 --- a/arch/powerpc/kernel/exceptions-64s.S
7941 +++ b/arch/powerpc/kernel/exceptions-64s.S
7942 @@ -1364,10 +1364,10 @@ handle_page_fault:
7943 11: ld r4,_DAR(r1)
7944 ld r5,_DSISR(r1)
7945 addi r3,r1,STACK_FRAME_OVERHEAD
7946 + bl .save_nvgprs
7947 bl .do_page_fault
7948 cmpdi r3,0
7949 beq+ 12f
7950 - bl .save_nvgprs
7951 mr r5,r3
7952 addi r3,r1,STACK_FRAME_OVERHEAD
7953 lwz r4,_DAR(r1)
7954 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7955 index 2e3200c..72095ce 100644
7956 --- a/arch/powerpc/kernel/module_32.c
7957 +++ b/arch/powerpc/kernel/module_32.c
7958 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7959 me->arch.core_plt_section = i;
7960 }
7961 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7962 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7963 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7964 return -ENOEXEC;
7965 }
7966
7967 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7968
7969 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7970 /* Init, or core PLT? */
7971 - if (location >= mod->module_core
7972 - && location < mod->module_core + mod->core_size)
7973 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7974 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7975 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7976 - else
7977 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7978 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7979 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7980 + else {
7981 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7982 + return ~0UL;
7983 + }
7984
7985 /* Find this entry, or if that fails, the next avail. entry */
7986 while (entry->jump[0]) {
7987 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7988 index 96d2fdf..f6d10c8 100644
7989 --- a/arch/powerpc/kernel/process.c
7990 +++ b/arch/powerpc/kernel/process.c
7991 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
7992 * Lookup NIP late so we have the best change of getting the
7993 * above info out without failing
7994 */
7995 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7996 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7997 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7998 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7999 #endif
8000 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8001 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8002 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8003 newsp = stack[0];
8004 ip = stack[STACK_FRAME_LR_SAVE];
8005 if (!firstframe || ip != lr) {
8006 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8007 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8008 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8009 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8010 - printk(" (%pS)",
8011 + printk(" (%pA)",
8012 (void *)current->ret_stack[curr_frame].ret);
8013 curr_frame--;
8014 }
8015 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8016 struct pt_regs *regs = (struct pt_regs *)
8017 (sp + STACK_FRAME_OVERHEAD);
8018 lr = regs->link;
8019 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8020 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8021 regs->trap, (void *)regs->nip, (void *)lr);
8022 firstframe = 1;
8023 }
8024 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8025 mtspr(SPRN_CTRLT, ctrl);
8026 }
8027 #endif /* CONFIG_PPC64 */
8028 -
8029 -unsigned long arch_align_stack(unsigned long sp)
8030 -{
8031 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8032 - sp -= get_random_int() & ~PAGE_MASK;
8033 - return sp & ~0xf;
8034 -}
8035 -
8036 -static inline unsigned long brk_rnd(void)
8037 -{
8038 - unsigned long rnd = 0;
8039 -
8040 - /* 8MB for 32bit, 1GB for 64bit */
8041 - if (is_32bit_task())
8042 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8043 - else
8044 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8045 -
8046 - return rnd << PAGE_SHIFT;
8047 -}
8048 -
8049 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8050 -{
8051 - unsigned long base = mm->brk;
8052 - unsigned long ret;
8053 -
8054 -#ifdef CONFIG_PPC_STD_MMU_64
8055 - /*
8056 - * If we are using 1TB segments and we are allowed to randomise
8057 - * the heap, we can put it above 1TB so it is backed by a 1TB
8058 - * segment. Otherwise the heap will be in the bottom 1TB
8059 - * which always uses 256MB segments and this may result in a
8060 - * performance penalty.
8061 - */
8062 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8063 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8064 -#endif
8065 -
8066 - ret = PAGE_ALIGN(base + brk_rnd());
8067 -
8068 - if (ret < mm->brk)
8069 - return mm->brk;
8070 -
8071 - return ret;
8072 -}
8073 -
8074 -unsigned long randomize_et_dyn(unsigned long base)
8075 -{
8076 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8077 -
8078 - if (ret < base)
8079 - return base;
8080 -
8081 - return ret;
8082 -}
8083 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8084 index 9a0d24c..e7fbedf 100644
8085 --- a/arch/powerpc/kernel/ptrace.c
8086 +++ b/arch/powerpc/kernel/ptrace.c
8087 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8088 return ret;
8089 }
8090
8091 +#ifdef CONFIG_GRKERNSEC_SETXID
8092 +extern void gr_delayed_cred_worker(void);
8093 +#endif
8094 +
8095 /*
8096 * We must return the syscall number to actually look up in the table.
8097 * This can be -1L to skip running any syscall at all.
8098 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8099
8100 secure_computing_strict(regs->gpr[0]);
8101
8102 +#ifdef CONFIG_GRKERNSEC_SETXID
8103 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8104 + gr_delayed_cred_worker();
8105 +#endif
8106 +
8107 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8108 tracehook_report_syscall_entry(regs))
8109 /*
8110 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8111 {
8112 int step;
8113
8114 +#ifdef CONFIG_GRKERNSEC_SETXID
8115 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8116 + gr_delayed_cred_worker();
8117 +#endif
8118 +
8119 audit_syscall_exit(regs);
8120
8121 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8122 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8123 index 36d49e6..9147e39d 100644
8124 --- a/arch/powerpc/kernel/signal_32.c
8125 +++ b/arch/powerpc/kernel/signal_32.c
8126 @@ -1004,7 +1004,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8127 /* Save user registers on the stack */
8128 frame = &rt_sf->uc.uc_mcontext;
8129 addr = frame;
8130 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8131 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8132 sigret = 0;
8133 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8134 } else {
8135 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8136 index f93ec28..97e0fbb 100644
8137 --- a/arch/powerpc/kernel/signal_64.c
8138 +++ b/arch/powerpc/kernel/signal_64.c
8139 @@ -757,7 +757,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8140 #endif
8141
8142 /* Set up to return from userspace. */
8143 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8144 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8145 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8146 } else {
8147 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8148 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8149 index f783c93..619baf1 100644
8150 --- a/arch/powerpc/kernel/traps.c
8151 +++ b/arch/powerpc/kernel/traps.c
8152 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8153 return flags;
8154 }
8155
8156 +extern void gr_handle_kernel_exploit(void);
8157 +
8158 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8159 int signr)
8160 {
8161 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8162 panic("Fatal exception in interrupt");
8163 if (panic_on_oops)
8164 panic("Fatal exception");
8165 +
8166 + gr_handle_kernel_exploit();
8167 +
8168 do_exit(signr);
8169 }
8170
8171 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8172 index 1d9c926..25f4741 100644
8173 --- a/arch/powerpc/kernel/vdso.c
8174 +++ b/arch/powerpc/kernel/vdso.c
8175 @@ -34,6 +34,7 @@
8176 #include <asm/firmware.h>
8177 #include <asm/vdso.h>
8178 #include <asm/vdso_datapage.h>
8179 +#include <asm/mman.h>
8180
8181 #include "setup.h"
8182
8183 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8184 vdso_base = VDSO32_MBASE;
8185 #endif
8186
8187 - current->mm->context.vdso_base = 0;
8188 + current->mm->context.vdso_base = ~0UL;
8189
8190 /* vDSO has a problem and was disabled, just don't "enable" it for the
8191 * process
8192 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8193 vdso_base = get_unmapped_area(NULL, vdso_base,
8194 (vdso_pages << PAGE_SHIFT) +
8195 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8196 - 0, 0);
8197 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8198 if (IS_ERR_VALUE(vdso_base)) {
8199 rc = vdso_base;
8200 goto fail_mmapsem;
8201 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8202 index 5eea6f3..5d10396 100644
8203 --- a/arch/powerpc/lib/usercopy_64.c
8204 +++ b/arch/powerpc/lib/usercopy_64.c
8205 @@ -9,22 +9,6 @@
8206 #include <linux/module.h>
8207 #include <asm/uaccess.h>
8208
8209 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8210 -{
8211 - if (likely(access_ok(VERIFY_READ, from, n)))
8212 - n = __copy_from_user(to, from, n);
8213 - else
8214 - memset(to, 0, n);
8215 - return n;
8216 -}
8217 -
8218 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8219 -{
8220 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8221 - n = __copy_to_user(to, from, n);
8222 - return n;
8223 -}
8224 -
8225 unsigned long copy_in_user(void __user *to, const void __user *from,
8226 unsigned long n)
8227 {
8228 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8229 return n;
8230 }
8231
8232 -EXPORT_SYMBOL(copy_from_user);
8233 -EXPORT_SYMBOL(copy_to_user);
8234 EXPORT_SYMBOL(copy_in_user);
8235
8236 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8237 index 51ab9e7..7d3c78b 100644
8238 --- a/arch/powerpc/mm/fault.c
8239 +++ b/arch/powerpc/mm/fault.c
8240 @@ -33,6 +33,10 @@
8241 #include <linux/magic.h>
8242 #include <linux/ratelimit.h>
8243 #include <linux/context_tracking.h>
8244 +#include <linux/slab.h>
8245 +#include <linux/pagemap.h>
8246 +#include <linux/compiler.h>
8247 +#include <linux/unistd.h>
8248
8249 #include <asm/firmware.h>
8250 #include <asm/page.h>
8251 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8252 }
8253 #endif
8254
8255 +#ifdef CONFIG_PAX_PAGEEXEC
8256 +/*
8257 + * PaX: decide what to do with offenders (regs->nip = fault address)
8258 + *
8259 + * returns 1 when task should be killed
8260 + */
8261 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8262 +{
8263 + return 1;
8264 +}
8265 +
8266 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8267 +{
8268 + unsigned long i;
8269 +
8270 + printk(KERN_ERR "PAX: bytes at PC: ");
8271 + for (i = 0; i < 5; i++) {
8272 + unsigned int c;
8273 + if (get_user(c, (unsigned int __user *)pc+i))
8274 + printk(KERN_CONT "???????? ");
8275 + else
8276 + printk(KERN_CONT "%08x ", c);
8277 + }
8278 + printk("\n");
8279 +}
8280 +#endif
8281 +
8282 /*
8283 * Check whether the instruction at regs->nip is a store using
8284 * an update addressing form which will update r1.
8285 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8286 * indicate errors in DSISR but can validly be set in SRR1.
8287 */
8288 if (trap == 0x400)
8289 - error_code &= 0x48200000;
8290 + error_code &= 0x58200000;
8291 else
8292 is_write = error_code & DSISR_ISSTORE;
8293 #else
8294 @@ -378,7 +409,7 @@ good_area:
8295 * "undefined". Of those that can be set, this is the only
8296 * one which seems bad.
8297 */
8298 - if (error_code & 0x10000000)
8299 + if (error_code & DSISR_GUARDED)
8300 /* Guarded storage error. */
8301 goto bad_area;
8302 #endif /* CONFIG_8xx */
8303 @@ -393,7 +424,7 @@ good_area:
8304 * processors use the same I/D cache coherency mechanism
8305 * as embedded.
8306 */
8307 - if (error_code & DSISR_PROTFAULT)
8308 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8309 goto bad_area;
8310 #endif /* CONFIG_PPC_STD_MMU */
8311
8312 @@ -483,6 +514,23 @@ bad_area:
8313 bad_area_nosemaphore:
8314 /* User mode accesses cause a SIGSEGV */
8315 if (user_mode(regs)) {
8316 +
8317 +#ifdef CONFIG_PAX_PAGEEXEC
8318 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8319 +#ifdef CONFIG_PPC_STD_MMU
8320 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8321 +#else
8322 + if (is_exec && regs->nip == address) {
8323 +#endif
8324 + switch (pax_handle_fetch_fault(regs)) {
8325 + }
8326 +
8327 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8328 + do_group_exit(SIGKILL);
8329 + }
8330 + }
8331 +#endif
8332 +
8333 _exception(SIGSEGV, regs, code, address);
8334 goto bail;
8335 }
8336 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8337 index cb8bdbe..d770680 100644
8338 --- a/arch/powerpc/mm/mmap.c
8339 +++ b/arch/powerpc/mm/mmap.c
8340 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8341 {
8342 unsigned long rnd = 0;
8343
8344 +#ifdef CONFIG_PAX_RANDMMAP
8345 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8346 +#endif
8347 +
8348 if (current->flags & PF_RANDOMIZE) {
8349 /* 8MB for 32bit, 1GB for 64bit */
8350 if (is_32bit_task())
8351 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8352 */
8353 if (mmap_is_legacy()) {
8354 mm->mmap_base = TASK_UNMAPPED_BASE;
8355 +
8356 +#ifdef CONFIG_PAX_RANDMMAP
8357 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8358 + mm->mmap_base += mm->delta_mmap;
8359 +#endif
8360 +
8361 mm->get_unmapped_area = arch_get_unmapped_area;
8362 } else {
8363 mm->mmap_base = mmap_base();
8364 +
8365 +#ifdef CONFIG_PAX_RANDMMAP
8366 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8367 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8368 +#endif
8369 +
8370 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8371 }
8372 }
8373 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8374 index 7ce9cf3..a964087 100644
8375 --- a/arch/powerpc/mm/slice.c
8376 +++ b/arch/powerpc/mm/slice.c
8377 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8378 if ((mm->task_size - len) < addr)
8379 return 0;
8380 vma = find_vma(mm, addr);
8381 - return (!vma || (addr + len) <= vma->vm_start);
8382 + return check_heap_stack_gap(vma, addr, len, 0);
8383 }
8384
8385 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8386 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8387 info.align_offset = 0;
8388
8389 addr = TASK_UNMAPPED_BASE;
8390 +
8391 +#ifdef CONFIG_PAX_RANDMMAP
8392 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8393 + addr += mm->delta_mmap;
8394 +#endif
8395 +
8396 while (addr < TASK_SIZE) {
8397 info.low_limit = addr;
8398 if (!slice_scan_available(addr, available, 1, &addr))
8399 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8400 if (fixed && addr > (mm->task_size - len))
8401 return -EINVAL;
8402
8403 +#ifdef CONFIG_PAX_RANDMMAP
8404 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8405 + addr = 0;
8406 +#endif
8407 +
8408 /* If hint, make sure it matches our alignment restrictions */
8409 if (!fixed && addr) {
8410 addr = _ALIGN_UP(addr, 1ul << pshift);
8411 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8412 index 9098692..3d54cd1 100644
8413 --- a/arch/powerpc/platforms/cell/spufs/file.c
8414 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8415 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8416 return VM_FAULT_NOPAGE;
8417 }
8418
8419 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8420 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8421 unsigned long address,
8422 - void *buf, int len, int write)
8423 + void *buf, size_t len, int write)
8424 {
8425 struct spu_context *ctx = vma->vm_file->private_data;
8426 unsigned long offset = address - vma->vm_start;
8427 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8428 index c797832..ce575c8 100644
8429 --- a/arch/s390/include/asm/atomic.h
8430 +++ b/arch/s390/include/asm/atomic.h
8431 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8432 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8433 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8434
8435 +#define atomic64_read_unchecked(v) atomic64_read(v)
8436 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8437 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8438 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8439 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8440 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8441 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8442 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8443 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8444 +
8445 #define smp_mb__before_atomic_dec() smp_mb()
8446 #define smp_mb__after_atomic_dec() smp_mb()
8447 #define smp_mb__before_atomic_inc() smp_mb()
8448 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8449 index 4d7ccac..d03d0ad 100644
8450 --- a/arch/s390/include/asm/cache.h
8451 +++ b/arch/s390/include/asm/cache.h
8452 @@ -9,8 +9,10 @@
8453 #ifndef __ARCH_S390_CACHE_H
8454 #define __ARCH_S390_CACHE_H
8455
8456 -#define L1_CACHE_BYTES 256
8457 +#include <linux/const.h>
8458 +
8459 #define L1_CACHE_SHIFT 8
8460 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8461 #define NET_SKB_PAD 32
8462
8463 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8464 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8465 index 78f4f87..598ce39 100644
8466 --- a/arch/s390/include/asm/elf.h
8467 +++ b/arch/s390/include/asm/elf.h
8468 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8469 the loader. We need to make sure that it is out of the way of the program
8470 that it will "exec", and that there is sufficient room for the brk. */
8471
8472 -extern unsigned long randomize_et_dyn(unsigned long base);
8473 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8474 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8475 +
8476 +#ifdef CONFIG_PAX_ASLR
8477 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8478 +
8479 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8480 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8481 +#endif
8482
8483 /* This yields a mask that user programs can use to figure out what
8484 instruction set this CPU supports. */
8485 @@ -222,9 +228,6 @@ struct linux_binprm;
8486 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8487 int arch_setup_additional_pages(struct linux_binprm *, int);
8488
8489 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8490 -#define arch_randomize_brk arch_randomize_brk
8491 -
8492 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8493
8494 #endif
8495 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8496 index c4a93d6..4d2a9b4 100644
8497 --- a/arch/s390/include/asm/exec.h
8498 +++ b/arch/s390/include/asm/exec.h
8499 @@ -7,6 +7,6 @@
8500 #ifndef __ASM_EXEC_H
8501 #define __ASM_EXEC_H
8502
8503 -extern unsigned long arch_align_stack(unsigned long sp);
8504 +#define arch_align_stack(x) ((x) & ~0xfUL)
8505
8506 #endif /* __ASM_EXEC_H */
8507 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8508 index 9c33ed4..e40cbef 100644
8509 --- a/arch/s390/include/asm/uaccess.h
8510 +++ b/arch/s390/include/asm/uaccess.h
8511 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8512 copy_to_user(void __user *to, const void *from, unsigned long n)
8513 {
8514 might_fault();
8515 +
8516 + if ((long)n < 0)
8517 + return n;
8518 +
8519 return __copy_to_user(to, from, n);
8520 }
8521
8522 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8523 static inline unsigned long __must_check
8524 __copy_from_user(void *to, const void __user *from, unsigned long n)
8525 {
8526 + if ((long)n < 0)
8527 + return n;
8528 +
8529 if (__builtin_constant_p(n) && (n <= 256))
8530 return uaccess.copy_from_user_small(n, from, to);
8531 else
8532 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8533 static inline unsigned long __must_check
8534 copy_from_user(void *to, const void __user *from, unsigned long n)
8535 {
8536 - unsigned int sz = __compiletime_object_size(to);
8537 + size_t sz = __compiletime_object_size(to);
8538
8539 might_fault();
8540 - if (unlikely(sz != -1 && sz < n)) {
8541 +
8542 + if ((long)n < 0)
8543 + return n;
8544 +
8545 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8546 copy_from_user_overflow();
8547 return n;
8548 }
8549 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8550 index 7845e15..59c4353 100644
8551 --- a/arch/s390/kernel/module.c
8552 +++ b/arch/s390/kernel/module.c
8553 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8554
8555 /* Increase core size by size of got & plt and set start
8556 offsets for got and plt. */
8557 - me->core_size = ALIGN(me->core_size, 4);
8558 - me->arch.got_offset = me->core_size;
8559 - me->core_size += me->arch.got_size;
8560 - me->arch.plt_offset = me->core_size;
8561 - me->core_size += me->arch.plt_size;
8562 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8563 + me->arch.got_offset = me->core_size_rw;
8564 + me->core_size_rw += me->arch.got_size;
8565 + me->arch.plt_offset = me->core_size_rx;
8566 + me->core_size_rx += me->arch.plt_size;
8567 return 0;
8568 }
8569
8570 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8571 if (info->got_initialized == 0) {
8572 Elf_Addr *gotent;
8573
8574 - gotent = me->module_core + me->arch.got_offset +
8575 + gotent = me->module_core_rw + me->arch.got_offset +
8576 info->got_offset;
8577 *gotent = val;
8578 info->got_initialized = 1;
8579 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8580 rc = apply_rela_bits(loc, val, 0, 64, 0);
8581 else if (r_type == R_390_GOTENT ||
8582 r_type == R_390_GOTPLTENT) {
8583 - val += (Elf_Addr) me->module_core - loc;
8584 + val += (Elf_Addr) me->module_core_rw - loc;
8585 rc = apply_rela_bits(loc, val, 1, 32, 1);
8586 }
8587 break;
8588 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8589 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8590 if (info->plt_initialized == 0) {
8591 unsigned int *ip;
8592 - ip = me->module_core + me->arch.plt_offset +
8593 + ip = me->module_core_rx + me->arch.plt_offset +
8594 info->plt_offset;
8595 #ifndef CONFIG_64BIT
8596 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8597 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8598 val - loc + 0xffffUL < 0x1ffffeUL) ||
8599 (r_type == R_390_PLT32DBL &&
8600 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8601 - val = (Elf_Addr) me->module_core +
8602 + val = (Elf_Addr) me->module_core_rx +
8603 me->arch.plt_offset +
8604 info->plt_offset;
8605 val += rela->r_addend - loc;
8606 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8607 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8608 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8609 val = val + rela->r_addend -
8610 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8611 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8612 if (r_type == R_390_GOTOFF16)
8613 rc = apply_rela_bits(loc, val, 0, 16, 0);
8614 else if (r_type == R_390_GOTOFF32)
8615 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8616 break;
8617 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8618 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8619 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8620 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8621 rela->r_addend - loc;
8622 if (r_type == R_390_GOTPC)
8623 rc = apply_rela_bits(loc, val, 1, 32, 0);
8624 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8625 index c5dbb33..b41f4ee 100644
8626 --- a/arch/s390/kernel/process.c
8627 +++ b/arch/s390/kernel/process.c
8628 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8629 }
8630 return 0;
8631 }
8632 -
8633 -unsigned long arch_align_stack(unsigned long sp)
8634 -{
8635 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8636 - sp -= get_random_int() & ~PAGE_MASK;
8637 - return sp & ~0xf;
8638 -}
8639 -
8640 -static inline unsigned long brk_rnd(void)
8641 -{
8642 - /* 8MB for 32bit, 1GB for 64bit */
8643 - if (is_32bit_task())
8644 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8645 - else
8646 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8647 -}
8648 -
8649 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8650 -{
8651 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8652 -
8653 - if (ret < mm->brk)
8654 - return mm->brk;
8655 - return ret;
8656 -}
8657 -
8658 -unsigned long randomize_et_dyn(unsigned long base)
8659 -{
8660 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8661 -
8662 - if (!(current->flags & PF_RANDOMIZE))
8663 - return base;
8664 - if (ret < base)
8665 - return base;
8666 - return ret;
8667 -}
8668 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8669 index 4002329..99b67cb 100644
8670 --- a/arch/s390/mm/mmap.c
8671 +++ b/arch/s390/mm/mmap.c
8672 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8673 */
8674 if (mmap_is_legacy()) {
8675 mm->mmap_base = TASK_UNMAPPED_BASE;
8676 +
8677 +#ifdef CONFIG_PAX_RANDMMAP
8678 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8679 + mm->mmap_base += mm->delta_mmap;
8680 +#endif
8681 +
8682 mm->get_unmapped_area = arch_get_unmapped_area;
8683 } else {
8684 mm->mmap_base = mmap_base();
8685 +
8686 +#ifdef CONFIG_PAX_RANDMMAP
8687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8688 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8689 +#endif
8690 +
8691 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8692 }
8693 }
8694 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8695 */
8696 if (mmap_is_legacy()) {
8697 mm->mmap_base = TASK_UNMAPPED_BASE;
8698 +
8699 +#ifdef CONFIG_PAX_RANDMMAP
8700 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8701 + mm->mmap_base += mm->delta_mmap;
8702 +#endif
8703 +
8704 mm->get_unmapped_area = s390_get_unmapped_area;
8705 } else {
8706 mm->mmap_base = mmap_base();
8707 +
8708 +#ifdef CONFIG_PAX_RANDMMAP
8709 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8710 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8711 +#endif
8712 +
8713 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8714 }
8715 }
8716 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8717 index ae3d59f..f65f075 100644
8718 --- a/arch/score/include/asm/cache.h
8719 +++ b/arch/score/include/asm/cache.h
8720 @@ -1,7 +1,9 @@
8721 #ifndef _ASM_SCORE_CACHE_H
8722 #define _ASM_SCORE_CACHE_H
8723
8724 +#include <linux/const.h>
8725 +
8726 #define L1_CACHE_SHIFT 4
8727 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8728 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8729
8730 #endif /* _ASM_SCORE_CACHE_H */
8731 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8732 index f9f3cd5..58ff438 100644
8733 --- a/arch/score/include/asm/exec.h
8734 +++ b/arch/score/include/asm/exec.h
8735 @@ -1,6 +1,6 @@
8736 #ifndef _ASM_SCORE_EXEC_H
8737 #define _ASM_SCORE_EXEC_H
8738
8739 -extern unsigned long arch_align_stack(unsigned long sp);
8740 +#define arch_align_stack(x) (x)
8741
8742 #endif /* _ASM_SCORE_EXEC_H */
8743 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8744 index a1519ad3..e8ac1ff 100644
8745 --- a/arch/score/kernel/process.c
8746 +++ b/arch/score/kernel/process.c
8747 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8748
8749 return task_pt_regs(task)->cp0_epc;
8750 }
8751 -
8752 -unsigned long arch_align_stack(unsigned long sp)
8753 -{
8754 - return sp;
8755 -}
8756 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8757 index ef9e555..331bd29 100644
8758 --- a/arch/sh/include/asm/cache.h
8759 +++ b/arch/sh/include/asm/cache.h
8760 @@ -9,10 +9,11 @@
8761 #define __ASM_SH_CACHE_H
8762 #ifdef __KERNEL__
8763
8764 +#include <linux/const.h>
8765 #include <linux/init.h>
8766 #include <cpu/cache.h>
8767
8768 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8769 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8770
8771 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8772
8773 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8774 index 6777177..cb5e44f 100644
8775 --- a/arch/sh/mm/mmap.c
8776 +++ b/arch/sh/mm/mmap.c
8777 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8778 struct mm_struct *mm = current->mm;
8779 struct vm_area_struct *vma;
8780 int do_colour_align;
8781 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8782 struct vm_unmapped_area_info info;
8783
8784 if (flags & MAP_FIXED) {
8785 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8786 if (filp || (flags & MAP_SHARED))
8787 do_colour_align = 1;
8788
8789 +#ifdef CONFIG_PAX_RANDMMAP
8790 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8791 +#endif
8792 +
8793 if (addr) {
8794 if (do_colour_align)
8795 addr = COLOUR_ALIGN(addr, pgoff);
8796 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8797 addr = PAGE_ALIGN(addr);
8798
8799 vma = find_vma(mm, addr);
8800 - if (TASK_SIZE - len >= addr &&
8801 - (!vma || addr + len <= vma->vm_start))
8802 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8803 return addr;
8804 }
8805
8806 info.flags = 0;
8807 info.length = len;
8808 - info.low_limit = TASK_UNMAPPED_BASE;
8809 + info.low_limit = mm->mmap_base;
8810 info.high_limit = TASK_SIZE;
8811 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8812 info.align_offset = pgoff << PAGE_SHIFT;
8813 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8814 struct mm_struct *mm = current->mm;
8815 unsigned long addr = addr0;
8816 int do_colour_align;
8817 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8818 struct vm_unmapped_area_info info;
8819
8820 if (flags & MAP_FIXED) {
8821 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8822 if (filp || (flags & MAP_SHARED))
8823 do_colour_align = 1;
8824
8825 +#ifdef CONFIG_PAX_RANDMMAP
8826 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8827 +#endif
8828 +
8829 /* requesting a specific address */
8830 if (addr) {
8831 if (do_colour_align)
8832 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8833 addr = PAGE_ALIGN(addr);
8834
8835 vma = find_vma(mm, addr);
8836 - if (TASK_SIZE - len >= addr &&
8837 - (!vma || addr + len <= vma->vm_start))
8838 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8839 return addr;
8840 }
8841
8842 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8843 VM_BUG_ON(addr != -ENOMEM);
8844 info.flags = 0;
8845 info.low_limit = TASK_UNMAPPED_BASE;
8846 +
8847 +#ifdef CONFIG_PAX_RANDMMAP
8848 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8849 + info.low_limit += mm->delta_mmap;
8850 +#endif
8851 +
8852 info.high_limit = TASK_SIZE;
8853 addr = vm_unmapped_area(&info);
8854 }
8855 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8856 index be56a24..443328f 100644
8857 --- a/arch/sparc/include/asm/atomic_64.h
8858 +++ b/arch/sparc/include/asm/atomic_64.h
8859 @@ -14,18 +14,40 @@
8860 #define ATOMIC64_INIT(i) { (i) }
8861
8862 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8863 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8864 +{
8865 + return v->counter;
8866 +}
8867 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8868 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8869 +{
8870 + return v->counter;
8871 +}
8872
8873 #define atomic_set(v, i) (((v)->counter) = i)
8874 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8875 +{
8876 + v->counter = i;
8877 +}
8878 #define atomic64_set(v, i) (((v)->counter) = i)
8879 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8880 +{
8881 + v->counter = i;
8882 +}
8883
8884 extern void atomic_add(int, atomic_t *);
8885 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8886 extern void atomic64_add(long, atomic64_t *);
8887 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8888 extern void atomic_sub(int, atomic_t *);
8889 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8890 extern void atomic64_sub(long, atomic64_t *);
8891 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8892
8893 extern int atomic_add_ret(int, atomic_t *);
8894 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8895 extern long atomic64_add_ret(long, atomic64_t *);
8896 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8897 extern int atomic_sub_ret(int, atomic_t *);
8898 extern long atomic64_sub_ret(long, atomic64_t *);
8899
8900 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8901 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8902
8903 #define atomic_inc_return(v) atomic_add_ret(1, v)
8904 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8905 +{
8906 + return atomic_add_ret_unchecked(1, v);
8907 +}
8908 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8909 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8910 +{
8911 + return atomic64_add_ret_unchecked(1, v);
8912 +}
8913
8914 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8915 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8916
8917 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8918 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8919 +{
8920 + return atomic_add_ret_unchecked(i, v);
8921 +}
8922 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8923 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8924 +{
8925 + return atomic64_add_ret_unchecked(i, v);
8926 +}
8927
8928 /*
8929 * atomic_inc_and_test - increment and test
8930 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8931 * other cases.
8932 */
8933 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8934 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8935 +{
8936 + return atomic_inc_return_unchecked(v) == 0;
8937 +}
8938 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8939
8940 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8941 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8942 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8943
8944 #define atomic_inc(v) atomic_add(1, v)
8945 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8946 +{
8947 + atomic_add_unchecked(1, v);
8948 +}
8949 #define atomic64_inc(v) atomic64_add(1, v)
8950 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8951 +{
8952 + atomic64_add_unchecked(1, v);
8953 +}
8954
8955 #define atomic_dec(v) atomic_sub(1, v)
8956 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8957 +{
8958 + atomic_sub_unchecked(1, v);
8959 +}
8960 #define atomic64_dec(v) atomic64_sub(1, v)
8961 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8962 +{
8963 + atomic64_sub_unchecked(1, v);
8964 +}
8965
8966 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8967 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8968
8969 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8970 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8971 +{
8972 + return cmpxchg(&v->counter, old, new);
8973 +}
8974 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8975 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8976 +{
8977 + return xchg(&v->counter, new);
8978 +}
8979
8980 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8981 {
8982 - int c, old;
8983 + int c, old, new;
8984 c = atomic_read(v);
8985 for (;;) {
8986 - if (unlikely(c == (u)))
8987 + if (unlikely(c == u))
8988 break;
8989 - old = atomic_cmpxchg((v), c, c + (a));
8990 +
8991 + asm volatile("addcc %2, %0, %0\n"
8992 +
8993 +#ifdef CONFIG_PAX_REFCOUNT
8994 + "tvs %%icc, 6\n"
8995 +#endif
8996 +
8997 + : "=r" (new)
8998 + : "0" (c), "ir" (a)
8999 + : "cc");
9000 +
9001 + old = atomic_cmpxchg(v, c, new);
9002 if (likely(old == c))
9003 break;
9004 c = old;
9005 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9006 #define atomic64_cmpxchg(v, o, n) \
9007 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9008 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9009 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9010 +{
9011 + return xchg(&v->counter, new);
9012 +}
9013
9014 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9015 {
9016 - long c, old;
9017 + long c, old, new;
9018 c = atomic64_read(v);
9019 for (;;) {
9020 - if (unlikely(c == (u)))
9021 + if (unlikely(c == u))
9022 break;
9023 - old = atomic64_cmpxchg((v), c, c + (a));
9024 +
9025 + asm volatile("addcc %2, %0, %0\n"
9026 +
9027 +#ifdef CONFIG_PAX_REFCOUNT
9028 + "tvs %%xcc, 6\n"
9029 +#endif
9030 +
9031 + : "=r" (new)
9032 + : "0" (c), "ir" (a)
9033 + : "cc");
9034 +
9035 + old = atomic64_cmpxchg(v, c, new);
9036 if (likely(old == c))
9037 break;
9038 c = old;
9039 }
9040 - return c != (u);
9041 + return c != u;
9042 }
9043
9044 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9045 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9046 index 5bb6991..5c2132e 100644
9047 --- a/arch/sparc/include/asm/cache.h
9048 +++ b/arch/sparc/include/asm/cache.h
9049 @@ -7,10 +7,12 @@
9050 #ifndef _SPARC_CACHE_H
9051 #define _SPARC_CACHE_H
9052
9053 +#include <linux/const.h>
9054 +
9055 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9056
9057 #define L1_CACHE_SHIFT 5
9058 -#define L1_CACHE_BYTES 32
9059 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9060
9061 #ifdef CONFIG_SPARC32
9062 #define SMP_CACHE_BYTES_SHIFT 5
9063 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9064 index a24e41f..47677ff 100644
9065 --- a/arch/sparc/include/asm/elf_32.h
9066 +++ b/arch/sparc/include/asm/elf_32.h
9067 @@ -114,6 +114,13 @@ typedef struct {
9068
9069 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9070
9071 +#ifdef CONFIG_PAX_ASLR
9072 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9073 +
9074 +#define PAX_DELTA_MMAP_LEN 16
9075 +#define PAX_DELTA_STACK_LEN 16
9076 +#endif
9077 +
9078 /* This yields a mask that user programs can use to figure out what
9079 instruction set this cpu supports. This can NOT be done in userspace
9080 on Sparc. */
9081 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9082 index 370ca1e..d4f4a98 100644
9083 --- a/arch/sparc/include/asm/elf_64.h
9084 +++ b/arch/sparc/include/asm/elf_64.h
9085 @@ -189,6 +189,13 @@ typedef struct {
9086 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9087 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9088
9089 +#ifdef CONFIG_PAX_ASLR
9090 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9091 +
9092 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9093 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9094 +#endif
9095 +
9096 extern unsigned long sparc64_elf_hwcap;
9097 #define ELF_HWCAP sparc64_elf_hwcap
9098
9099 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9100 index 9b1c36d..209298b 100644
9101 --- a/arch/sparc/include/asm/pgalloc_32.h
9102 +++ b/arch/sparc/include/asm/pgalloc_32.h
9103 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9104 }
9105
9106 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9107 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9108
9109 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9110 unsigned long address)
9111 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9112 index bcfe063..b333142 100644
9113 --- a/arch/sparc/include/asm/pgalloc_64.h
9114 +++ b/arch/sparc/include/asm/pgalloc_64.h
9115 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9116 }
9117
9118 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9119 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9120
9121 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9122 {
9123 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9124 index 502f632..da1917f 100644
9125 --- a/arch/sparc/include/asm/pgtable_32.h
9126 +++ b/arch/sparc/include/asm/pgtable_32.h
9127 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9128 #define PAGE_SHARED SRMMU_PAGE_SHARED
9129 #define PAGE_COPY SRMMU_PAGE_COPY
9130 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9131 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9132 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9133 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9134 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9135
9136 /* Top-level page directory - dummy used by init-mm.
9137 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9138
9139 /* xwr */
9140 #define __P000 PAGE_NONE
9141 -#define __P001 PAGE_READONLY
9142 -#define __P010 PAGE_COPY
9143 -#define __P011 PAGE_COPY
9144 +#define __P001 PAGE_READONLY_NOEXEC
9145 +#define __P010 PAGE_COPY_NOEXEC
9146 +#define __P011 PAGE_COPY_NOEXEC
9147 #define __P100 PAGE_READONLY
9148 #define __P101 PAGE_READONLY
9149 #define __P110 PAGE_COPY
9150 #define __P111 PAGE_COPY
9151
9152 #define __S000 PAGE_NONE
9153 -#define __S001 PAGE_READONLY
9154 -#define __S010 PAGE_SHARED
9155 -#define __S011 PAGE_SHARED
9156 +#define __S001 PAGE_READONLY_NOEXEC
9157 +#define __S010 PAGE_SHARED_NOEXEC
9158 +#define __S011 PAGE_SHARED_NOEXEC
9159 #define __S100 PAGE_READONLY
9160 #define __S101 PAGE_READONLY
9161 #define __S110 PAGE_SHARED
9162 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9163 index 79da178..c2eede8 100644
9164 --- a/arch/sparc/include/asm/pgtsrmmu.h
9165 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9166 @@ -115,6 +115,11 @@
9167 SRMMU_EXEC | SRMMU_REF)
9168 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9169 SRMMU_EXEC | SRMMU_REF)
9170 +
9171 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9172 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9173 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9174 +
9175 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9176 SRMMU_DIRTY | SRMMU_REF)
9177
9178 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9179 index 9689176..63c18ea 100644
9180 --- a/arch/sparc/include/asm/spinlock_64.h
9181 +++ b/arch/sparc/include/asm/spinlock_64.h
9182 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9183
9184 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9185
9186 -static void inline arch_read_lock(arch_rwlock_t *lock)
9187 +static inline void arch_read_lock(arch_rwlock_t *lock)
9188 {
9189 unsigned long tmp1, tmp2;
9190
9191 __asm__ __volatile__ (
9192 "1: ldsw [%2], %0\n"
9193 " brlz,pn %0, 2f\n"
9194 -"4: add %0, 1, %1\n"
9195 +"4: addcc %0, 1, %1\n"
9196 +
9197 +#ifdef CONFIG_PAX_REFCOUNT
9198 +" tvs %%icc, 6\n"
9199 +#endif
9200 +
9201 " cas [%2], %0, %1\n"
9202 " cmp %0, %1\n"
9203 " bne,pn %%icc, 1b\n"
9204 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9205 " .previous"
9206 : "=&r" (tmp1), "=&r" (tmp2)
9207 : "r" (lock)
9208 - : "memory");
9209 + : "memory", "cc");
9210 }
9211
9212 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9213 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9214 {
9215 int tmp1, tmp2;
9216
9217 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9218 "1: ldsw [%2], %0\n"
9219 " brlz,a,pn %0, 2f\n"
9220 " mov 0, %0\n"
9221 -" add %0, 1, %1\n"
9222 +" addcc %0, 1, %1\n"
9223 +
9224 +#ifdef CONFIG_PAX_REFCOUNT
9225 +" tvs %%icc, 6\n"
9226 +#endif
9227 +
9228 " cas [%2], %0, %1\n"
9229 " cmp %0, %1\n"
9230 " bne,pn %%icc, 1b\n"
9231 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9232 return tmp1;
9233 }
9234
9235 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9237 {
9238 unsigned long tmp1, tmp2;
9239
9240 __asm__ __volatile__(
9241 "1: lduw [%2], %0\n"
9242 -" sub %0, 1, %1\n"
9243 +" subcc %0, 1, %1\n"
9244 +
9245 +#ifdef CONFIG_PAX_REFCOUNT
9246 +" tvs %%icc, 6\n"
9247 +#endif
9248 +
9249 " cas [%2], %0, %1\n"
9250 " cmp %0, %1\n"
9251 " bne,pn %%xcc, 1b\n"
9252 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9253 : "memory");
9254 }
9255
9256 -static void inline arch_write_lock(arch_rwlock_t *lock)
9257 +static inline void arch_write_lock(arch_rwlock_t *lock)
9258 {
9259 unsigned long mask, tmp1, tmp2;
9260
9261 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9262 : "memory");
9263 }
9264
9265 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9266 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9267 {
9268 __asm__ __volatile__(
9269 " stw %%g0, [%0]"
9270 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9271 : "memory");
9272 }
9273
9274 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9275 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9276 {
9277 unsigned long mask, tmp1, tmp2, result;
9278
9279 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9280 index dd38075..e7cac83 100644
9281 --- a/arch/sparc/include/asm/thread_info_32.h
9282 +++ b/arch/sparc/include/asm/thread_info_32.h
9283 @@ -49,6 +49,8 @@ struct thread_info {
9284 unsigned long w_saved;
9285
9286 struct restart_block restart_block;
9287 +
9288 + unsigned long lowest_stack;
9289 };
9290
9291 /*
9292 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9293 index d5e5042..9bfee76 100644
9294 --- a/arch/sparc/include/asm/thread_info_64.h
9295 +++ b/arch/sparc/include/asm/thread_info_64.h
9296 @@ -63,6 +63,8 @@ struct thread_info {
9297 struct pt_regs *kern_una_regs;
9298 unsigned int kern_una_insn;
9299
9300 + unsigned long lowest_stack;
9301 +
9302 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9303 };
9304
9305 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9306 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9307 /* flag bit 6 is available */
9308 #define TIF_32BIT 7 /* 32-bit binary */
9309 -/* flag bit 8 is available */
9310 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9311 #define TIF_SECCOMP 9 /* secure computing */
9312 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9313 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9314 +
9315 /* NOTE: Thread flags >= 12 should be ones we have no interest
9316 * in using in assembly, else we can't use the mask as
9317 * an immediate value in instructions such as andcc.
9318 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9319 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9320 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9321 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9322 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9323
9324 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9325 _TIF_DO_NOTIFY_RESUME_MASK | \
9326 _TIF_NEED_RESCHED)
9327 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9328
9329 +#define _TIF_WORK_SYSCALL \
9330 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9331 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9332 +
9333 +
9334 /*
9335 * Thread-synchronous status.
9336 *
9337 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9338 index 0167d26..767bb0c 100644
9339 --- a/arch/sparc/include/asm/uaccess.h
9340 +++ b/arch/sparc/include/asm/uaccess.h
9341 @@ -1,5 +1,6 @@
9342 #ifndef ___ASM_SPARC_UACCESS_H
9343 #define ___ASM_SPARC_UACCESS_H
9344 +
9345 #if defined(__sparc__) && defined(__arch64__)
9346 #include <asm/uaccess_64.h>
9347 #else
9348 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9349 index 53a28dd..50c38c3 100644
9350 --- a/arch/sparc/include/asm/uaccess_32.h
9351 +++ b/arch/sparc/include/asm/uaccess_32.h
9352 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9353
9354 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9355 {
9356 - if (n && __access_ok((unsigned long) to, n))
9357 + if ((long)n < 0)
9358 + return n;
9359 +
9360 + if (n && __access_ok((unsigned long) to, n)) {
9361 + if (!__builtin_constant_p(n))
9362 + check_object_size(from, n, true);
9363 return __copy_user(to, (__force void __user *) from, n);
9364 - else
9365 + } else
9366 return n;
9367 }
9368
9369 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9370 {
9371 + if ((long)n < 0)
9372 + return n;
9373 +
9374 + if (!__builtin_constant_p(n))
9375 + check_object_size(from, n, true);
9376 +
9377 return __copy_user(to, (__force void __user *) from, n);
9378 }
9379
9380 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9381 {
9382 - if (n && __access_ok((unsigned long) from, n))
9383 + if ((long)n < 0)
9384 + return n;
9385 +
9386 + if (n && __access_ok((unsigned long) from, n)) {
9387 + if (!__builtin_constant_p(n))
9388 + check_object_size(to, n, false);
9389 return __copy_user((__force void __user *) to, from, n);
9390 - else
9391 + } else
9392 return n;
9393 }
9394
9395 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9396 {
9397 + if ((long)n < 0)
9398 + return n;
9399 +
9400 return __copy_user((__force void __user *) to, from, n);
9401 }
9402
9403 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9404 index e562d3c..191f176 100644
9405 --- a/arch/sparc/include/asm/uaccess_64.h
9406 +++ b/arch/sparc/include/asm/uaccess_64.h
9407 @@ -10,6 +10,7 @@
9408 #include <linux/compiler.h>
9409 #include <linux/string.h>
9410 #include <linux/thread_info.h>
9411 +#include <linux/kernel.h>
9412 #include <asm/asi.h>
9413 #include <asm/spitfire.h>
9414 #include <asm-generic/uaccess-unaligned.h>
9415 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9416 static inline unsigned long __must_check
9417 copy_from_user(void *to, const void __user *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_from_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(to, size, false);
9427 +
9428 + ret = ___copy_from_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_from_user_fixup(to, from, size);
9431
9432 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9433 static inline unsigned long __must_check
9434 copy_to_user(void __user *to, const void *from, unsigned long size)
9435 {
9436 - unsigned long ret = ___copy_to_user(to, from, size);
9437 + unsigned long ret;
9438
9439 + if ((long)size < 0 || size > INT_MAX)
9440 + return size;
9441 +
9442 + if (!__builtin_constant_p(size))
9443 + check_object_size(from, size, true);
9444 +
9445 + ret = ___copy_to_user(to, from, size);
9446 if (unlikely(ret))
9447 ret = copy_to_user_fixup(to, from, size);
9448 return ret;
9449 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9450 index d15cc17..d0ae796 100644
9451 --- a/arch/sparc/kernel/Makefile
9452 +++ b/arch/sparc/kernel/Makefile
9453 @@ -4,7 +4,7 @@
9454 #
9455
9456 asflags-y := -ansi
9457 -ccflags-y := -Werror
9458 +#ccflags-y := -Werror
9459
9460 extra-y := head_$(BITS).o
9461
9462 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9463 index fdd819d..5af08c8 100644
9464 --- a/arch/sparc/kernel/process_32.c
9465 +++ b/arch/sparc/kernel/process_32.c
9466 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9467
9468 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9469 r->psr, r->pc, r->npc, r->y, print_tainted());
9470 - printk("PC: <%pS>\n", (void *) r->pc);
9471 + printk("PC: <%pA>\n", (void *) r->pc);
9472 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9473 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9474 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9475 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9476 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9477 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9478 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9479 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9480
9481 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9482 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9483 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9484 rw = (struct reg_window32 *) fp;
9485 pc = rw->ins[7];
9486 printk("[%08lx : ", pc);
9487 - printk("%pS ] ", (void *) pc);
9488 + printk("%pA ] ", (void *) pc);
9489 fp = rw->ins[6];
9490 } while (++count < 16);
9491 printk("\n");
9492 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9493 index baebab2..9cd13b1 100644
9494 --- a/arch/sparc/kernel/process_64.c
9495 +++ b/arch/sparc/kernel/process_64.c
9496 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9497 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9498 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9499 if (regs->tstate & TSTATE_PRIV)
9500 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9501 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9502 }
9503
9504 void show_regs(struct pt_regs *regs)
9505 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9506
9507 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9508 regs->tpc, regs->tnpc, regs->y, print_tainted());
9509 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9510 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9511 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9512 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9513 regs->u_regs[3]);
9514 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9515 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9516 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9517 regs->u_regs[15]);
9518 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9519 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9520 show_regwindow(regs);
9521 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9522 }
9523 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9524 ((tp && tp->task) ? tp->task->pid : -1));
9525
9526 if (gp->tstate & TSTATE_PRIV) {
9527 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9528 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9529 (void *) gp->tpc,
9530 (void *) gp->o7,
9531 (void *) gp->i7,
9532 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9533 index 79cc0d1..ec62734 100644
9534 --- a/arch/sparc/kernel/prom_common.c
9535 +++ b/arch/sparc/kernel/prom_common.c
9536 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9537
9538 unsigned int prom_early_allocated __initdata;
9539
9540 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9541 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9542 .nextprop = prom_common_nextprop,
9543 .getproplen = prom_getproplen,
9544 .getproperty = prom_getproperty,
9545 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9546 index 773c1f2..a8bdd87 100644
9547 --- a/arch/sparc/kernel/ptrace_64.c
9548 +++ b/arch/sparc/kernel/ptrace_64.c
9549 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9550 return ret;
9551 }
9552
9553 +#ifdef CONFIG_GRKERNSEC_SETXID
9554 +extern void gr_delayed_cred_worker(void);
9555 +#endif
9556 +
9557 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9558 {
9559 int ret = 0;
9560 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9561 /* do the secure computing check first */
9562 secure_computing_strict(regs->u_regs[UREG_G1]);
9563
9564 +#ifdef CONFIG_GRKERNSEC_SETXID
9565 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9566 + gr_delayed_cred_worker();
9567 +#endif
9568 +
9569 if (test_thread_flag(TIF_SYSCALL_TRACE))
9570 ret = tracehook_report_syscall_entry(regs);
9571
9572 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9573
9574 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9575 {
9576 +#ifdef CONFIG_GRKERNSEC_SETXID
9577 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9578 + gr_delayed_cred_worker();
9579 +#endif
9580 +
9581 audit_syscall_exit(regs);
9582
9583 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9584 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9585 index e142545..fd29654 100644
9586 --- a/arch/sparc/kernel/smp_64.c
9587 +++ b/arch/sparc/kernel/smp_64.c
9588 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9589 extern unsigned long xcall_flush_dcache_page_spitfire;
9590
9591 #ifdef CONFIG_DEBUG_DCFLUSH
9592 -extern atomic_t dcpage_flushes;
9593 -extern atomic_t dcpage_flushes_xcall;
9594 +extern atomic_unchecked_t dcpage_flushes;
9595 +extern atomic_unchecked_t dcpage_flushes_xcall;
9596 #endif
9597
9598 static inline void __local_flush_dcache_page(struct page *page)
9599 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9600 return;
9601
9602 #ifdef CONFIG_DEBUG_DCFLUSH
9603 - atomic_inc(&dcpage_flushes);
9604 + atomic_inc_unchecked(&dcpage_flushes);
9605 #endif
9606
9607 this_cpu = get_cpu();
9608 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9609 xcall_deliver(data0, __pa(pg_addr),
9610 (u64) pg_addr, cpumask_of(cpu));
9611 #ifdef CONFIG_DEBUG_DCFLUSH
9612 - atomic_inc(&dcpage_flushes_xcall);
9613 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9614 #endif
9615 }
9616 }
9617 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9618 preempt_disable();
9619
9620 #ifdef CONFIG_DEBUG_DCFLUSH
9621 - atomic_inc(&dcpage_flushes);
9622 + atomic_inc_unchecked(&dcpage_flushes);
9623 #endif
9624 data0 = 0;
9625 pg_addr = page_address(page);
9626 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9627 xcall_deliver(data0, __pa(pg_addr),
9628 (u64) pg_addr, cpu_online_mask);
9629 #ifdef CONFIG_DEBUG_DCFLUSH
9630 - atomic_inc(&dcpage_flushes_xcall);
9631 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9632 #endif
9633 }
9634 __local_flush_dcache_page(page);
9635 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9636 index 3a8d184..49498a8 100644
9637 --- a/arch/sparc/kernel/sys_sparc_32.c
9638 +++ b/arch/sparc/kernel/sys_sparc_32.c
9639 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9640 if (len > TASK_SIZE - PAGE_SIZE)
9641 return -ENOMEM;
9642 if (!addr)
9643 - addr = TASK_UNMAPPED_BASE;
9644 + addr = current->mm->mmap_base;
9645
9646 info.flags = 0;
9647 info.length = len;
9648 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9649 index 51561b8..8256764 100644
9650 --- a/arch/sparc/kernel/sys_sparc_64.c
9651 +++ b/arch/sparc/kernel/sys_sparc_64.c
9652 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9653 struct vm_area_struct * vma;
9654 unsigned long task_size = TASK_SIZE;
9655 int do_color_align;
9656 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9657 struct vm_unmapped_area_info info;
9658
9659 if (flags & MAP_FIXED) {
9660 /* We do not accept a shared mapping if it would violate
9661 * cache aliasing constraints.
9662 */
9663 - if ((flags & MAP_SHARED) &&
9664 + if ((filp || (flags & MAP_SHARED)) &&
9665 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9666 return -EINVAL;
9667 return addr;
9668 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9669 if (filp || (flags & MAP_SHARED))
9670 do_color_align = 1;
9671
9672 +#ifdef CONFIG_PAX_RANDMMAP
9673 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9674 +#endif
9675 +
9676 if (addr) {
9677 if (do_color_align)
9678 addr = COLOR_ALIGN(addr, pgoff);
9679 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9680 addr = PAGE_ALIGN(addr);
9681
9682 vma = find_vma(mm, addr);
9683 - if (task_size - len >= addr &&
9684 - (!vma || addr + len <= vma->vm_start))
9685 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9686 return addr;
9687 }
9688
9689 info.flags = 0;
9690 info.length = len;
9691 - info.low_limit = TASK_UNMAPPED_BASE;
9692 + info.low_limit = mm->mmap_base;
9693 info.high_limit = min(task_size, VA_EXCLUDE_START);
9694 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9695 info.align_offset = pgoff << PAGE_SHIFT;
9696 + info.threadstack_offset = offset;
9697 addr = vm_unmapped_area(&info);
9698
9699 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9700 VM_BUG_ON(addr != -ENOMEM);
9701 info.low_limit = VA_EXCLUDE_END;
9702 +
9703 +#ifdef CONFIG_PAX_RANDMMAP
9704 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9705 + info.low_limit += mm->delta_mmap;
9706 +#endif
9707 +
9708 info.high_limit = task_size;
9709 addr = vm_unmapped_area(&info);
9710 }
9711 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 unsigned long task_size = STACK_TOP32;
9713 unsigned long addr = addr0;
9714 int do_color_align;
9715 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9716 struct vm_unmapped_area_info info;
9717
9718 /* This should only ever run for 32-bit processes. */
9719 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9720 /* We do not accept a shared mapping if it would violate
9721 * cache aliasing constraints.
9722 */
9723 - if ((flags & MAP_SHARED) &&
9724 + if ((filp || (flags & MAP_SHARED)) &&
9725 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9726 return -EINVAL;
9727 return addr;
9728 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9729 if (filp || (flags & MAP_SHARED))
9730 do_color_align = 1;
9731
9732 +#ifdef CONFIG_PAX_RANDMMAP
9733 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9734 +#endif
9735 +
9736 /* requesting a specific address */
9737 if (addr) {
9738 if (do_color_align)
9739 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9740 addr = PAGE_ALIGN(addr);
9741
9742 vma = find_vma(mm, addr);
9743 - if (task_size - len >= addr &&
9744 - (!vma || addr + len <= vma->vm_start))
9745 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9746 return addr;
9747 }
9748
9749 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9750 info.high_limit = mm->mmap_base;
9751 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9752 info.align_offset = pgoff << PAGE_SHIFT;
9753 + info.threadstack_offset = offset;
9754 addr = vm_unmapped_area(&info);
9755
9756 /*
9757 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9758 VM_BUG_ON(addr != -ENOMEM);
9759 info.flags = 0;
9760 info.low_limit = TASK_UNMAPPED_BASE;
9761 +
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9764 + info.low_limit += mm->delta_mmap;
9765 +#endif
9766 +
9767 info.high_limit = STACK_TOP32;
9768 addr = vm_unmapped_area(&info);
9769 }
9770 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9771 EXPORT_SYMBOL(get_fb_unmapped_area);
9772
9773 /* Essentially the same as PowerPC. */
9774 -static unsigned long mmap_rnd(void)
9775 +static unsigned long mmap_rnd(struct mm_struct *mm)
9776 {
9777 unsigned long rnd = 0UL;
9778
9779 +#ifdef CONFIG_PAX_RANDMMAP
9780 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9781 +#endif
9782 +
9783 if (current->flags & PF_RANDOMIZE) {
9784 unsigned long val = get_random_int();
9785 if (test_thread_flag(TIF_32BIT))
9786 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9787
9788 void arch_pick_mmap_layout(struct mm_struct *mm)
9789 {
9790 - unsigned long random_factor = mmap_rnd();
9791 + unsigned long random_factor = mmap_rnd(mm);
9792 unsigned long gap;
9793
9794 /*
9795 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9796 gap == RLIM_INFINITY ||
9797 sysctl_legacy_va_layout) {
9798 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9799 +
9800 +#ifdef CONFIG_PAX_RANDMMAP
9801 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9802 + mm->mmap_base += mm->delta_mmap;
9803 +#endif
9804 +
9805 mm->get_unmapped_area = arch_get_unmapped_area;
9806 } else {
9807 /* We know it's 32-bit */
9808 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9809 gap = (task_size / 6 * 5);
9810
9811 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9812 +
9813 +#ifdef CONFIG_PAX_RANDMMAP
9814 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9815 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9816 +#endif
9817 +
9818 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9819 }
9820 }
9821 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9822 index d950197..192f9d8 100644
9823 --- a/arch/sparc/kernel/syscalls.S
9824 +++ b/arch/sparc/kernel/syscalls.S
9825 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9826 #endif
9827 .align 32
9828 1: ldx [%g6 + TI_FLAGS], %l5
9829 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9830 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9831 be,pt %icc, rtrap
9832 nop
9833 call syscall_trace_leave
9834 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9835
9836 srl %i3, 0, %o3 ! IEU0
9837 srl %i2, 0, %o2 ! IEU0 Group
9838 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9839 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9840 bne,pn %icc, linux_syscall_trace32 ! CTI
9841 mov %i0, %l5 ! IEU1
9842 5: call %l7 ! CTI Group brk forced
9843 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9844
9845 mov %i3, %o3 ! IEU1
9846 mov %i4, %o4 ! IEU0 Group
9847 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9848 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9849 bne,pn %icc, linux_syscall_trace ! CTI Group
9850 mov %i0, %l5 ! IEU0
9851 2: call %l7 ! CTI Group brk forced
9852 @@ -223,7 +223,7 @@ ret_sys_call:
9853
9854 cmp %o0, -ERESTART_RESTARTBLOCK
9855 bgeu,pn %xcc, 1f
9856 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9857 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9858 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9859
9860 2:
9861 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9862 index 6629829..036032d 100644
9863 --- a/arch/sparc/kernel/traps_32.c
9864 +++ b/arch/sparc/kernel/traps_32.c
9865 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9866 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9867 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9868
9869 +extern void gr_handle_kernel_exploit(void);
9870 +
9871 void die_if_kernel(char *str, struct pt_regs *regs)
9872 {
9873 static int die_counter;
9874 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9875 count++ < 30 &&
9876 (((unsigned long) rw) >= PAGE_OFFSET) &&
9877 !(((unsigned long) rw) & 0x7)) {
9878 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9879 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9880 (void *) rw->ins[7]);
9881 rw = (struct reg_window32 *)rw->ins[6];
9882 }
9883 }
9884 printk("Instruction DUMP:");
9885 instruction_dump ((unsigned long *) regs->pc);
9886 - if(regs->psr & PSR_PS)
9887 + if(regs->psr & PSR_PS) {
9888 + gr_handle_kernel_exploit();
9889 do_exit(SIGKILL);
9890 + }
9891 do_exit(SIGSEGV);
9892 }
9893
9894 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9895 index b3f833a..f485f80 100644
9896 --- a/arch/sparc/kernel/traps_64.c
9897 +++ b/arch/sparc/kernel/traps_64.c
9898 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9899 i + 1,
9900 p->trapstack[i].tstate, p->trapstack[i].tpc,
9901 p->trapstack[i].tnpc, p->trapstack[i].tt);
9902 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9903 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9904 }
9905 }
9906
9907 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9908
9909 lvl -= 0x100;
9910 if (regs->tstate & TSTATE_PRIV) {
9911 +
9912 +#ifdef CONFIG_PAX_REFCOUNT
9913 + if (lvl == 6)
9914 + pax_report_refcount_overflow(regs);
9915 +#endif
9916 +
9917 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9918 die_if_kernel(buffer, regs);
9919 }
9920 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9921 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9922 {
9923 char buffer[32];
9924 -
9925 +
9926 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9927 0, lvl, SIGTRAP) == NOTIFY_STOP)
9928 return;
9929
9930 +#ifdef CONFIG_PAX_REFCOUNT
9931 + if (lvl == 6)
9932 + pax_report_refcount_overflow(regs);
9933 +#endif
9934 +
9935 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9936
9937 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9938 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9939 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9940 printk("%s" "ERROR(%d): ",
9941 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9942 - printk("TPC<%pS>\n", (void *) regs->tpc);
9943 + printk("TPC<%pA>\n", (void *) regs->tpc);
9944 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9945 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9946 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9947 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9948 smp_processor_id(),
9949 (type & 0x1) ? 'I' : 'D',
9950 regs->tpc);
9951 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9952 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9953 panic("Irrecoverable Cheetah+ parity error.");
9954 }
9955
9956 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9957 smp_processor_id(),
9958 (type & 0x1) ? 'I' : 'D',
9959 regs->tpc);
9960 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9961 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9962 }
9963
9964 struct sun4v_error_entry {
9965 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9966 /*0x38*/u64 reserved_5;
9967 };
9968
9969 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9970 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9971 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9972 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9973
9974 static const char *sun4v_err_type_to_str(u8 type)
9975 {
9976 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9977 }
9978
9979 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9980 - int cpu, const char *pfx, atomic_t *ocnt)
9981 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9982 {
9983 u64 *raw_ptr = (u64 *) ent;
9984 u32 attrs;
9985 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9986
9987 show_regs(regs);
9988
9989 - if ((cnt = atomic_read(ocnt)) != 0) {
9990 - atomic_set(ocnt, 0);
9991 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9992 + atomic_set_unchecked(ocnt, 0);
9993 wmb();
9994 printk("%s: Queue overflowed %d times.\n",
9995 pfx, cnt);
9996 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9997 */
9998 void sun4v_resum_overflow(struct pt_regs *regs)
9999 {
10000 - atomic_inc(&sun4v_resum_oflow_cnt);
10001 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10002 }
10003
10004 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10005 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10006 /* XXX Actually even this can make not that much sense. Perhaps
10007 * XXX we should just pull the plug and panic directly from here?
10008 */
10009 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10010 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10011 }
10012
10013 unsigned long sun4v_err_itlb_vaddr;
10014 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10015
10016 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10017 regs->tpc, tl);
10018 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10019 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10020 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10021 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10022 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10023 (void *) regs->u_regs[UREG_I7]);
10024 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10025 "pte[%lx] error[%lx]\n",
10026 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10027
10028 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10029 regs->tpc, tl);
10030 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10031 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10032 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10033 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10034 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10035 (void *) regs->u_regs[UREG_I7]);
10036 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10037 "pte[%lx] error[%lx]\n",
10038 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10039 fp = (unsigned long)sf->fp + STACK_BIAS;
10040 }
10041
10042 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10043 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10044 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10045 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10046 int index = tsk->curr_ret_stack;
10047 if (tsk->ret_stack && index >= graph) {
10048 pc = tsk->ret_stack[index - graph].ret;
10049 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10050 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10051 graph++;
10052 }
10053 }
10054 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10055 return (struct reg_window *) (fp + STACK_BIAS);
10056 }
10057
10058 +extern void gr_handle_kernel_exploit(void);
10059 +
10060 void die_if_kernel(char *str, struct pt_regs *regs)
10061 {
10062 static int die_counter;
10063 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10064 while (rw &&
10065 count++ < 30 &&
10066 kstack_valid(tp, (unsigned long) rw)) {
10067 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10068 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10069 (void *) rw->ins[7]);
10070
10071 rw = kernel_stack_up(rw);
10072 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10073 }
10074 user_instruction_dump ((unsigned int __user *) regs->tpc);
10075 }
10076 - if (regs->tstate & TSTATE_PRIV)
10077 + if (regs->tstate & TSTATE_PRIV) {
10078 + gr_handle_kernel_exploit();
10079 do_exit(SIGKILL);
10080 + }
10081 do_exit(SIGSEGV);
10082 }
10083 EXPORT_SYMBOL(die_if_kernel);
10084 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10085 index 8201c25e..072a2a7 100644
10086 --- a/arch/sparc/kernel/unaligned_64.c
10087 +++ b/arch/sparc/kernel/unaligned_64.c
10088 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10089 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10090
10091 if (__ratelimit(&ratelimit)) {
10092 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10093 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10094 regs->tpc, (void *) regs->tpc);
10095 }
10096 }
10097 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10098 index dbe119b..089c7c1 100644
10099 --- a/arch/sparc/lib/Makefile
10100 +++ b/arch/sparc/lib/Makefile
10101 @@ -2,7 +2,7 @@
10102 #
10103
10104 asflags-y := -ansi -DST_DIV0=0x02
10105 -ccflags-y := -Werror
10106 +#ccflags-y := -Werror
10107
10108 lib-$(CONFIG_SPARC32) += ashrdi3.o
10109 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10110 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10111 index 85c233d..68500e0 100644
10112 --- a/arch/sparc/lib/atomic_64.S
10113 +++ b/arch/sparc/lib/atomic_64.S
10114 @@ -17,7 +17,12 @@
10115 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10116 BACKOFF_SETUP(%o2)
10117 1: lduw [%o1], %g1
10118 - add %g1, %o0, %g7
10119 + addcc %g1, %o0, %g7
10120 +
10121 +#ifdef CONFIG_PAX_REFCOUNT
10122 + tvs %icc, 6
10123 +#endif
10124 +
10125 cas [%o1], %g1, %g7
10126 cmp %g1, %g7
10127 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10128 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10129 2: BACKOFF_SPIN(%o2, %o3, 1b)
10130 ENDPROC(atomic_add)
10131
10132 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10133 + BACKOFF_SETUP(%o2)
10134 +1: lduw [%o1], %g1
10135 + add %g1, %o0, %g7
10136 + cas [%o1], %g1, %g7
10137 + cmp %g1, %g7
10138 + bne,pn %icc, 2f
10139 + nop
10140 + retl
10141 + nop
10142 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 +ENDPROC(atomic_add_unchecked)
10144 +
10145 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10146 BACKOFF_SETUP(%o2)
10147 1: lduw [%o1], %g1
10148 - sub %g1, %o0, %g7
10149 + subcc %g1, %o0, %g7
10150 +
10151 +#ifdef CONFIG_PAX_REFCOUNT
10152 + tvs %icc, 6
10153 +#endif
10154 +
10155 cas [%o1], %g1, %g7
10156 cmp %g1, %g7
10157 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10158 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10159 2: BACKOFF_SPIN(%o2, %o3, 1b)
10160 ENDPROC(atomic_sub)
10161
10162 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10163 + BACKOFF_SETUP(%o2)
10164 +1: lduw [%o1], %g1
10165 + sub %g1, %o0, %g7
10166 + cas [%o1], %g1, %g7
10167 + cmp %g1, %g7
10168 + bne,pn %icc, 2f
10169 + nop
10170 + retl
10171 + nop
10172 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 +ENDPROC(atomic_sub_unchecked)
10174 +
10175 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10176 BACKOFF_SETUP(%o2)
10177 1: lduw [%o1], %g1
10178 - add %g1, %o0, %g7
10179 + addcc %g1, %o0, %g7
10180 +
10181 +#ifdef CONFIG_PAX_REFCOUNT
10182 + tvs %icc, 6
10183 +#endif
10184 +
10185 cas [%o1], %g1, %g7
10186 cmp %g1, %g7
10187 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10188 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10189 2: BACKOFF_SPIN(%o2, %o3, 1b)
10190 ENDPROC(atomic_add_ret)
10191
10192 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10193 + BACKOFF_SETUP(%o2)
10194 +1: lduw [%o1], %g1
10195 + addcc %g1, %o0, %g7
10196 + cas [%o1], %g1, %g7
10197 + cmp %g1, %g7
10198 + bne,pn %icc, 2f
10199 + add %g7, %o0, %g7
10200 + sra %g7, 0, %o0
10201 + retl
10202 + nop
10203 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10204 +ENDPROC(atomic_add_ret_unchecked)
10205 +
10206 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10207 BACKOFF_SETUP(%o2)
10208 1: lduw [%o1], %g1
10209 - sub %g1, %o0, %g7
10210 + subcc %g1, %o0, %g7
10211 +
10212 +#ifdef CONFIG_PAX_REFCOUNT
10213 + tvs %icc, 6
10214 +#endif
10215 +
10216 cas [%o1], %g1, %g7
10217 cmp %g1, %g7
10218 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10219 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10220 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10221 BACKOFF_SETUP(%o2)
10222 1: ldx [%o1], %g1
10223 - add %g1, %o0, %g7
10224 + addcc %g1, %o0, %g7
10225 +
10226 +#ifdef CONFIG_PAX_REFCOUNT
10227 + tvs %xcc, 6
10228 +#endif
10229 +
10230 casx [%o1], %g1, %g7
10231 cmp %g1, %g7
10232 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10233 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10234 2: BACKOFF_SPIN(%o2, %o3, 1b)
10235 ENDPROC(atomic64_add)
10236
10237 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10238 + BACKOFF_SETUP(%o2)
10239 +1: ldx [%o1], %g1
10240 + addcc %g1, %o0, %g7
10241 + casx [%o1], %g1, %g7
10242 + cmp %g1, %g7
10243 + bne,pn %xcc, 2f
10244 + nop
10245 + retl
10246 + nop
10247 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 +ENDPROC(atomic64_add_unchecked)
10249 +
10250 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10251 BACKOFF_SETUP(%o2)
10252 1: ldx [%o1], %g1
10253 - sub %g1, %o0, %g7
10254 + subcc %g1, %o0, %g7
10255 +
10256 +#ifdef CONFIG_PAX_REFCOUNT
10257 + tvs %xcc, 6
10258 +#endif
10259 +
10260 casx [%o1], %g1, %g7
10261 cmp %g1, %g7
10262 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10263 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10264 2: BACKOFF_SPIN(%o2, %o3, 1b)
10265 ENDPROC(atomic64_sub)
10266
10267 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10268 + BACKOFF_SETUP(%o2)
10269 +1: ldx [%o1], %g1
10270 + subcc %g1, %o0, %g7
10271 + casx [%o1], %g1, %g7
10272 + cmp %g1, %g7
10273 + bne,pn %xcc, 2f
10274 + nop
10275 + retl
10276 + nop
10277 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 +ENDPROC(atomic64_sub_unchecked)
10279 +
10280 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10281 BACKOFF_SETUP(%o2)
10282 1: ldx [%o1], %g1
10283 - add %g1, %o0, %g7
10284 + addcc %g1, %o0, %g7
10285 +
10286 +#ifdef CONFIG_PAX_REFCOUNT
10287 + tvs %xcc, 6
10288 +#endif
10289 +
10290 casx [%o1], %g1, %g7
10291 cmp %g1, %g7
10292 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10293 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10294 2: BACKOFF_SPIN(%o2, %o3, 1b)
10295 ENDPROC(atomic64_add_ret)
10296
10297 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10298 + BACKOFF_SETUP(%o2)
10299 +1: ldx [%o1], %g1
10300 + addcc %g1, %o0, %g7
10301 + casx [%o1], %g1, %g7
10302 + cmp %g1, %g7
10303 + bne,pn %xcc, 2f
10304 + add %g7, %o0, %g7
10305 + mov %g7, %o0
10306 + retl
10307 + nop
10308 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10309 +ENDPROC(atomic64_add_ret_unchecked)
10310 +
10311 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10312 BACKOFF_SETUP(%o2)
10313 1: ldx [%o1], %g1
10314 - sub %g1, %o0, %g7
10315 + subcc %g1, %o0, %g7
10316 +
10317 +#ifdef CONFIG_PAX_REFCOUNT
10318 + tvs %xcc, 6
10319 +#endif
10320 +
10321 casx [%o1], %g1, %g7
10322 cmp %g1, %g7
10323 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10324 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10325 index 323335b..ed85ea2 100644
10326 --- a/arch/sparc/lib/ksyms.c
10327 +++ b/arch/sparc/lib/ksyms.c
10328 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10329
10330 /* Atomic counter implementation. */
10331 EXPORT_SYMBOL(atomic_add);
10332 +EXPORT_SYMBOL(atomic_add_unchecked);
10333 EXPORT_SYMBOL(atomic_add_ret);
10334 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10335 EXPORT_SYMBOL(atomic_sub);
10336 +EXPORT_SYMBOL(atomic_sub_unchecked);
10337 EXPORT_SYMBOL(atomic_sub_ret);
10338 EXPORT_SYMBOL(atomic64_add);
10339 +EXPORT_SYMBOL(atomic64_add_unchecked);
10340 EXPORT_SYMBOL(atomic64_add_ret);
10341 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10342 EXPORT_SYMBOL(atomic64_sub);
10343 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10344 EXPORT_SYMBOL(atomic64_sub_ret);
10345 EXPORT_SYMBOL(atomic64_dec_if_positive);
10346
10347 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10348 index 30c3ecc..736f015 100644
10349 --- a/arch/sparc/mm/Makefile
10350 +++ b/arch/sparc/mm/Makefile
10351 @@ -2,7 +2,7 @@
10352 #
10353
10354 asflags-y := -ansi
10355 -ccflags-y := -Werror
10356 +#ccflags-y := -Werror
10357
10358 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10359 obj-y += fault_$(BITS).o
10360 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10361 index 59dbd46..1dd7f5e 100644
10362 --- a/arch/sparc/mm/fault_32.c
10363 +++ b/arch/sparc/mm/fault_32.c
10364 @@ -21,6 +21,9 @@
10365 #include <linux/perf_event.h>
10366 #include <linux/interrupt.h>
10367 #include <linux/kdebug.h>
10368 +#include <linux/slab.h>
10369 +#include <linux/pagemap.h>
10370 +#include <linux/compiler.h>
10371
10372 #include <asm/page.h>
10373 #include <asm/pgtable.h>
10374 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10375 return safe_compute_effective_address(regs, insn);
10376 }
10377
10378 +#ifdef CONFIG_PAX_PAGEEXEC
10379 +#ifdef CONFIG_PAX_DLRESOLVE
10380 +static void pax_emuplt_close(struct vm_area_struct *vma)
10381 +{
10382 + vma->vm_mm->call_dl_resolve = 0UL;
10383 +}
10384 +
10385 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10386 +{
10387 + unsigned int *kaddr;
10388 +
10389 + vmf->page = alloc_page(GFP_HIGHUSER);
10390 + if (!vmf->page)
10391 + return VM_FAULT_OOM;
10392 +
10393 + kaddr = kmap(vmf->page);
10394 + memset(kaddr, 0, PAGE_SIZE);
10395 + kaddr[0] = 0x9DE3BFA8U; /* save */
10396 + flush_dcache_page(vmf->page);
10397 + kunmap(vmf->page);
10398 + return VM_FAULT_MAJOR;
10399 +}
10400 +
10401 +static const struct vm_operations_struct pax_vm_ops = {
10402 + .close = pax_emuplt_close,
10403 + .fault = pax_emuplt_fault
10404 +};
10405 +
10406 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10407 +{
10408 + int ret;
10409 +
10410 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10411 + vma->vm_mm = current->mm;
10412 + vma->vm_start = addr;
10413 + vma->vm_end = addr + PAGE_SIZE;
10414 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10415 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10416 + vma->vm_ops = &pax_vm_ops;
10417 +
10418 + ret = insert_vm_struct(current->mm, vma);
10419 + if (ret)
10420 + return ret;
10421 +
10422 + ++current->mm->total_vm;
10423 + return 0;
10424 +}
10425 +#endif
10426 +
10427 +/*
10428 + * PaX: decide what to do with offenders (regs->pc = fault address)
10429 + *
10430 + * returns 1 when task should be killed
10431 + * 2 when patched PLT trampoline was detected
10432 + * 3 when unpatched PLT trampoline was detected
10433 + */
10434 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10435 +{
10436 +
10437 +#ifdef CONFIG_PAX_EMUPLT
10438 + int err;
10439 +
10440 + do { /* PaX: patched PLT emulation #1 */
10441 + unsigned int sethi1, sethi2, jmpl;
10442 +
10443 + err = get_user(sethi1, (unsigned int *)regs->pc);
10444 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10445 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10446 +
10447 + if (err)
10448 + break;
10449 +
10450 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10451 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10452 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10453 + {
10454 + unsigned int addr;
10455 +
10456 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10457 + addr = regs->u_regs[UREG_G1];
10458 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10459 + regs->pc = addr;
10460 + regs->npc = addr+4;
10461 + return 2;
10462 + }
10463 + } while (0);
10464 +
10465 + do { /* PaX: patched PLT emulation #2 */
10466 + unsigned int ba;
10467 +
10468 + err = get_user(ba, (unsigned int *)regs->pc);
10469 +
10470 + if (err)
10471 + break;
10472 +
10473 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10474 + unsigned int addr;
10475 +
10476 + if ((ba & 0xFFC00000U) == 0x30800000U)
10477 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10478 + else
10479 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10480 + regs->pc = addr;
10481 + regs->npc = addr+4;
10482 + return 2;
10483 + }
10484 + } while (0);
10485 +
10486 + do { /* PaX: patched PLT emulation #3 */
10487 + unsigned int sethi, bajmpl, nop;
10488 +
10489 + err = get_user(sethi, (unsigned int *)regs->pc);
10490 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10491 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10492 +
10493 + if (err)
10494 + break;
10495 +
10496 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10497 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10498 + nop == 0x01000000U)
10499 + {
10500 + unsigned int addr;
10501 +
10502 + addr = (sethi & 0x003FFFFFU) << 10;
10503 + regs->u_regs[UREG_G1] = addr;
10504 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10505 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10506 + else
10507 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10508 + regs->pc = addr;
10509 + regs->npc = addr+4;
10510 + return 2;
10511 + }
10512 + } while (0);
10513 +
10514 + do { /* PaX: unpatched PLT emulation step 1 */
10515 + unsigned int sethi, ba, nop;
10516 +
10517 + err = get_user(sethi, (unsigned int *)regs->pc);
10518 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10519 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10520 +
10521 + if (err)
10522 + break;
10523 +
10524 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10525 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10526 + nop == 0x01000000U)
10527 + {
10528 + unsigned int addr, save, call;
10529 +
10530 + if ((ba & 0xFFC00000U) == 0x30800000U)
10531 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10532 + else
10533 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10534 +
10535 + err = get_user(save, (unsigned int *)addr);
10536 + err |= get_user(call, (unsigned int *)(addr+4));
10537 + err |= get_user(nop, (unsigned int *)(addr+8));
10538 + if (err)
10539 + break;
10540 +
10541 +#ifdef CONFIG_PAX_DLRESOLVE
10542 + if (save == 0x9DE3BFA8U &&
10543 + (call & 0xC0000000U) == 0x40000000U &&
10544 + nop == 0x01000000U)
10545 + {
10546 + struct vm_area_struct *vma;
10547 + unsigned long call_dl_resolve;
10548 +
10549 + down_read(&current->mm->mmap_sem);
10550 + call_dl_resolve = current->mm->call_dl_resolve;
10551 + up_read(&current->mm->mmap_sem);
10552 + if (likely(call_dl_resolve))
10553 + goto emulate;
10554 +
10555 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10556 +
10557 + down_write(&current->mm->mmap_sem);
10558 + if (current->mm->call_dl_resolve) {
10559 + call_dl_resolve = current->mm->call_dl_resolve;
10560 + up_write(&current->mm->mmap_sem);
10561 + if (vma)
10562 + kmem_cache_free(vm_area_cachep, vma);
10563 + goto emulate;
10564 + }
10565 +
10566 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10567 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10568 + up_write(&current->mm->mmap_sem);
10569 + if (vma)
10570 + kmem_cache_free(vm_area_cachep, vma);
10571 + return 1;
10572 + }
10573 +
10574 + if (pax_insert_vma(vma, call_dl_resolve)) {
10575 + up_write(&current->mm->mmap_sem);
10576 + kmem_cache_free(vm_area_cachep, vma);
10577 + return 1;
10578 + }
10579 +
10580 + current->mm->call_dl_resolve = call_dl_resolve;
10581 + up_write(&current->mm->mmap_sem);
10582 +
10583 +emulate:
10584 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10585 + regs->pc = call_dl_resolve;
10586 + regs->npc = addr+4;
10587 + return 3;
10588 + }
10589 +#endif
10590 +
10591 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10592 + if ((save & 0xFFC00000U) == 0x05000000U &&
10593 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10594 + nop == 0x01000000U)
10595 + {
10596 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10597 + regs->u_regs[UREG_G2] = addr + 4;
10598 + addr = (save & 0x003FFFFFU) << 10;
10599 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10600 + regs->pc = addr;
10601 + regs->npc = addr+4;
10602 + return 3;
10603 + }
10604 + }
10605 + } while (0);
10606 +
10607 + do { /* PaX: unpatched PLT emulation step 2 */
10608 + unsigned int save, call, nop;
10609 +
10610 + err = get_user(save, (unsigned int *)(regs->pc-4));
10611 + err |= get_user(call, (unsigned int *)regs->pc);
10612 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10613 + if (err)
10614 + break;
10615 +
10616 + if (save == 0x9DE3BFA8U &&
10617 + (call & 0xC0000000U) == 0x40000000U &&
10618 + nop == 0x01000000U)
10619 + {
10620 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10621 +
10622 + regs->u_regs[UREG_RETPC] = regs->pc;
10623 + regs->pc = dl_resolve;
10624 + regs->npc = dl_resolve+4;
10625 + return 3;
10626 + }
10627 + } while (0);
10628 +#endif
10629 +
10630 + return 1;
10631 +}
10632 +
10633 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10634 +{
10635 + unsigned long i;
10636 +
10637 + printk(KERN_ERR "PAX: bytes at PC: ");
10638 + for (i = 0; i < 8; i++) {
10639 + unsigned int c;
10640 + if (get_user(c, (unsigned int *)pc+i))
10641 + printk(KERN_CONT "???????? ");
10642 + else
10643 + printk(KERN_CONT "%08x ", c);
10644 + }
10645 + printk("\n");
10646 +}
10647 +#endif
10648 +
10649 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10650 int text_fault)
10651 {
10652 @@ -229,6 +503,24 @@ good_area:
10653 if (!(vma->vm_flags & VM_WRITE))
10654 goto bad_area;
10655 } else {
10656 +
10657 +#ifdef CONFIG_PAX_PAGEEXEC
10658 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10659 + up_read(&mm->mmap_sem);
10660 + switch (pax_handle_fetch_fault(regs)) {
10661 +
10662 +#ifdef CONFIG_PAX_EMUPLT
10663 + case 2:
10664 + case 3:
10665 + return;
10666 +#endif
10667 +
10668 + }
10669 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10670 + do_group_exit(SIGKILL);
10671 + }
10672 +#endif
10673 +
10674 /* Allow reads even for write-only mappings */
10675 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10676 goto bad_area;
10677 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10678 index 2ebec26..b212598 100644
10679 --- a/arch/sparc/mm/fault_64.c
10680 +++ b/arch/sparc/mm/fault_64.c
10681 @@ -21,6 +21,9 @@
10682 #include <linux/kprobes.h>
10683 #include <linux/kdebug.h>
10684 #include <linux/percpu.h>
10685 +#include <linux/slab.h>
10686 +#include <linux/pagemap.h>
10687 +#include <linux/compiler.h>
10688
10689 #include <asm/page.h>
10690 #include <asm/pgtable.h>
10691 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10692 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10693 regs->tpc);
10694 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10695 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10696 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10697 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10698 dump_stack();
10699 unhandled_fault(regs->tpc, current, regs);
10700 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10701 show_regs(regs);
10702 }
10703
10704 +#ifdef CONFIG_PAX_PAGEEXEC
10705 +#ifdef CONFIG_PAX_DLRESOLVE
10706 +static void pax_emuplt_close(struct vm_area_struct *vma)
10707 +{
10708 + vma->vm_mm->call_dl_resolve = 0UL;
10709 +}
10710 +
10711 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10712 +{
10713 + unsigned int *kaddr;
10714 +
10715 + vmf->page = alloc_page(GFP_HIGHUSER);
10716 + if (!vmf->page)
10717 + return VM_FAULT_OOM;
10718 +
10719 + kaddr = kmap(vmf->page);
10720 + memset(kaddr, 0, PAGE_SIZE);
10721 + kaddr[0] = 0x9DE3BFA8U; /* save */
10722 + flush_dcache_page(vmf->page);
10723 + kunmap(vmf->page);
10724 + return VM_FAULT_MAJOR;
10725 +}
10726 +
10727 +static const struct vm_operations_struct pax_vm_ops = {
10728 + .close = pax_emuplt_close,
10729 + .fault = pax_emuplt_fault
10730 +};
10731 +
10732 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10733 +{
10734 + int ret;
10735 +
10736 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10737 + vma->vm_mm = current->mm;
10738 + vma->vm_start = addr;
10739 + vma->vm_end = addr + PAGE_SIZE;
10740 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10741 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10742 + vma->vm_ops = &pax_vm_ops;
10743 +
10744 + ret = insert_vm_struct(current->mm, vma);
10745 + if (ret)
10746 + return ret;
10747 +
10748 + ++current->mm->total_vm;
10749 + return 0;
10750 +}
10751 +#endif
10752 +
10753 +/*
10754 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10755 + *
10756 + * returns 1 when task should be killed
10757 + * 2 when patched PLT trampoline was detected
10758 + * 3 when unpatched PLT trampoline was detected
10759 + */
10760 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10761 +{
10762 +
10763 +#ifdef CONFIG_PAX_EMUPLT
10764 + int err;
10765 +
10766 + do { /* PaX: patched PLT emulation #1 */
10767 + unsigned int sethi1, sethi2, jmpl;
10768 +
10769 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10770 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10771 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10772 +
10773 + if (err)
10774 + break;
10775 +
10776 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10777 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10778 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10779 + {
10780 + unsigned long addr;
10781 +
10782 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10783 + addr = regs->u_regs[UREG_G1];
10784 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10785 +
10786 + if (test_thread_flag(TIF_32BIT))
10787 + addr &= 0xFFFFFFFFUL;
10788 +
10789 + regs->tpc = addr;
10790 + regs->tnpc = addr+4;
10791 + return 2;
10792 + }
10793 + } while (0);
10794 +
10795 + do { /* PaX: patched PLT emulation #2 */
10796 + unsigned int ba;
10797 +
10798 + err = get_user(ba, (unsigned int *)regs->tpc);
10799 +
10800 + if (err)
10801 + break;
10802 +
10803 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10804 + unsigned long addr;
10805 +
10806 + if ((ba & 0xFFC00000U) == 0x30800000U)
10807 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10808 + else
10809 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10810 +
10811 + if (test_thread_flag(TIF_32BIT))
10812 + addr &= 0xFFFFFFFFUL;
10813 +
10814 + regs->tpc = addr;
10815 + regs->tnpc = addr+4;
10816 + return 2;
10817 + }
10818 + } while (0);
10819 +
10820 + do { /* PaX: patched PLT emulation #3 */
10821 + unsigned int sethi, bajmpl, nop;
10822 +
10823 + err = get_user(sethi, (unsigned int *)regs->tpc);
10824 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10825 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10826 +
10827 + if (err)
10828 + break;
10829 +
10830 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10831 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10832 + nop == 0x01000000U)
10833 + {
10834 + unsigned long addr;
10835 +
10836 + addr = (sethi & 0x003FFFFFU) << 10;
10837 + regs->u_regs[UREG_G1] = addr;
10838 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10839 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10840 + else
10841 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10842 +
10843 + if (test_thread_flag(TIF_32BIT))
10844 + addr &= 0xFFFFFFFFUL;
10845 +
10846 + regs->tpc = addr;
10847 + regs->tnpc = addr+4;
10848 + return 2;
10849 + }
10850 + } while (0);
10851 +
10852 + do { /* PaX: patched PLT emulation #4 */
10853 + unsigned int sethi, mov1, call, mov2;
10854 +
10855 + err = get_user(sethi, (unsigned int *)regs->tpc);
10856 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10857 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10858 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10859 +
10860 + if (err)
10861 + break;
10862 +
10863 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10864 + mov1 == 0x8210000FU &&
10865 + (call & 0xC0000000U) == 0x40000000U &&
10866 + mov2 == 0x9E100001U)
10867 + {
10868 + unsigned long addr;
10869 +
10870 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10871 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10872 +
10873 + if (test_thread_flag(TIF_32BIT))
10874 + addr &= 0xFFFFFFFFUL;
10875 +
10876 + regs->tpc = addr;
10877 + regs->tnpc = addr+4;
10878 + return 2;
10879 + }
10880 + } while (0);
10881 +
10882 + do { /* PaX: patched PLT emulation #5 */
10883 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10884 +
10885 + err = get_user(sethi, (unsigned int *)regs->tpc);
10886 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10887 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10888 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10889 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10890 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10891 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10892 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10893 +
10894 + if (err)
10895 + break;
10896 +
10897 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10898 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10899 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10900 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10901 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10902 + sllx == 0x83287020U &&
10903 + jmpl == 0x81C04005U &&
10904 + nop == 0x01000000U)
10905 + {
10906 + unsigned long addr;
10907 +
10908 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10909 + regs->u_regs[UREG_G1] <<= 32;
10910 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10911 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10912 + regs->tpc = addr;
10913 + regs->tnpc = addr+4;
10914 + return 2;
10915 + }
10916 + } while (0);
10917 +
10918 + do { /* PaX: patched PLT emulation #6 */
10919 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10920 +
10921 + err = get_user(sethi, (unsigned int *)regs->tpc);
10922 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10923 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10924 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10925 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10926 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10927 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10928 +
10929 + if (err)
10930 + break;
10931 +
10932 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10933 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10934 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10935 + sllx == 0x83287020U &&
10936 + (or & 0xFFFFE000U) == 0x8A116000U &&
10937 + jmpl == 0x81C04005U &&
10938 + nop == 0x01000000U)
10939 + {
10940 + unsigned long addr;
10941 +
10942 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10943 + regs->u_regs[UREG_G1] <<= 32;
10944 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10945 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10946 + regs->tpc = addr;
10947 + regs->tnpc = addr+4;
10948 + return 2;
10949 + }
10950 + } while (0);
10951 +
10952 + do { /* PaX: unpatched PLT emulation step 1 */
10953 + unsigned int sethi, ba, nop;
10954 +
10955 + err = get_user(sethi, (unsigned int *)regs->tpc);
10956 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10957 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10958 +
10959 + if (err)
10960 + break;
10961 +
10962 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10963 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10964 + nop == 0x01000000U)
10965 + {
10966 + unsigned long addr;
10967 + unsigned int save, call;
10968 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10969 +
10970 + if ((ba & 0xFFC00000U) == 0x30800000U)
10971 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10972 + else
10973 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10974 +
10975 + if (test_thread_flag(TIF_32BIT))
10976 + addr &= 0xFFFFFFFFUL;
10977 +
10978 + err = get_user(save, (unsigned int *)addr);
10979 + err |= get_user(call, (unsigned int *)(addr+4));
10980 + err |= get_user(nop, (unsigned int *)(addr+8));
10981 + if (err)
10982 + break;
10983 +
10984 +#ifdef CONFIG_PAX_DLRESOLVE
10985 + if (save == 0x9DE3BFA8U &&
10986 + (call & 0xC0000000U) == 0x40000000U &&
10987 + nop == 0x01000000U)
10988 + {
10989 + struct vm_area_struct *vma;
10990 + unsigned long call_dl_resolve;
10991 +
10992 + down_read(&current->mm->mmap_sem);
10993 + call_dl_resolve = current->mm->call_dl_resolve;
10994 + up_read(&current->mm->mmap_sem);
10995 + if (likely(call_dl_resolve))
10996 + goto emulate;
10997 +
10998 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10999 +
11000 + down_write(&current->mm->mmap_sem);
11001 + if (current->mm->call_dl_resolve) {
11002 + call_dl_resolve = current->mm->call_dl_resolve;
11003 + up_write(&current->mm->mmap_sem);
11004 + if (vma)
11005 + kmem_cache_free(vm_area_cachep, vma);
11006 + goto emulate;
11007 + }
11008 +
11009 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11010 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11011 + up_write(&current->mm->mmap_sem);
11012 + if (vma)
11013 + kmem_cache_free(vm_area_cachep, vma);
11014 + return 1;
11015 + }
11016 +
11017 + if (pax_insert_vma(vma, call_dl_resolve)) {
11018 + up_write(&current->mm->mmap_sem);
11019 + kmem_cache_free(vm_area_cachep, vma);
11020 + return 1;
11021 + }
11022 +
11023 + current->mm->call_dl_resolve = call_dl_resolve;
11024 + up_write(&current->mm->mmap_sem);
11025 +
11026 +emulate:
11027 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11028 + regs->tpc = call_dl_resolve;
11029 + regs->tnpc = addr+4;
11030 + return 3;
11031 + }
11032 +#endif
11033 +
11034 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11035 + if ((save & 0xFFC00000U) == 0x05000000U &&
11036 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11037 + nop == 0x01000000U)
11038 + {
11039 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11040 + regs->u_regs[UREG_G2] = addr + 4;
11041 + addr = (save & 0x003FFFFFU) << 10;
11042 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11043 +
11044 + if (test_thread_flag(TIF_32BIT))
11045 + addr &= 0xFFFFFFFFUL;
11046 +
11047 + regs->tpc = addr;
11048 + regs->tnpc = addr+4;
11049 + return 3;
11050 + }
11051 +
11052 + /* PaX: 64-bit PLT stub */
11053 + err = get_user(sethi1, (unsigned int *)addr);
11054 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11055 + err |= get_user(or1, (unsigned int *)(addr+8));
11056 + err |= get_user(or2, (unsigned int *)(addr+12));
11057 + err |= get_user(sllx, (unsigned int *)(addr+16));
11058 + err |= get_user(add, (unsigned int *)(addr+20));
11059 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11060 + err |= get_user(nop, (unsigned int *)(addr+28));
11061 + if (err)
11062 + break;
11063 +
11064 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11065 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11066 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11067 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11068 + sllx == 0x89293020U &&
11069 + add == 0x8A010005U &&
11070 + jmpl == 0x89C14000U &&
11071 + nop == 0x01000000U)
11072 + {
11073 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11074 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11075 + regs->u_regs[UREG_G4] <<= 32;
11076 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11077 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11078 + regs->u_regs[UREG_G4] = addr + 24;
11079 + addr = regs->u_regs[UREG_G5];
11080 + regs->tpc = addr;
11081 + regs->tnpc = addr+4;
11082 + return 3;
11083 + }
11084 + }
11085 + } while (0);
11086 +
11087 +#ifdef CONFIG_PAX_DLRESOLVE
11088 + do { /* PaX: unpatched PLT emulation step 2 */
11089 + unsigned int save, call, nop;
11090 +
11091 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11092 + err |= get_user(call, (unsigned int *)regs->tpc);
11093 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11094 + if (err)
11095 + break;
11096 +
11097 + if (save == 0x9DE3BFA8U &&
11098 + (call & 0xC0000000U) == 0x40000000U &&
11099 + nop == 0x01000000U)
11100 + {
11101 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11102 +
11103 + if (test_thread_flag(TIF_32BIT))
11104 + dl_resolve &= 0xFFFFFFFFUL;
11105 +
11106 + regs->u_regs[UREG_RETPC] = regs->tpc;
11107 + regs->tpc = dl_resolve;
11108 + regs->tnpc = dl_resolve+4;
11109 + return 3;
11110 + }
11111 + } while (0);
11112 +#endif
11113 +
11114 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11115 + unsigned int sethi, ba, nop;
11116 +
11117 + err = get_user(sethi, (unsigned int *)regs->tpc);
11118 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11119 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11120 +
11121 + if (err)
11122 + break;
11123 +
11124 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11125 + (ba & 0xFFF00000U) == 0x30600000U &&
11126 + nop == 0x01000000U)
11127 + {
11128 + unsigned long addr;
11129 +
11130 + addr = (sethi & 0x003FFFFFU) << 10;
11131 + regs->u_regs[UREG_G1] = addr;
11132 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11133 +
11134 + if (test_thread_flag(TIF_32BIT))
11135 + addr &= 0xFFFFFFFFUL;
11136 +
11137 + regs->tpc = addr;
11138 + regs->tnpc = addr+4;
11139 + return 2;
11140 + }
11141 + } while (0);
11142 +
11143 +#endif
11144 +
11145 + return 1;
11146 +}
11147 +
11148 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11149 +{
11150 + unsigned long i;
11151 +
11152 + printk(KERN_ERR "PAX: bytes at PC: ");
11153 + for (i = 0; i < 8; i++) {
11154 + unsigned int c;
11155 + if (get_user(c, (unsigned int *)pc+i))
11156 + printk(KERN_CONT "???????? ");
11157 + else
11158 + printk(KERN_CONT "%08x ", c);
11159 + }
11160 + printk("\n");
11161 +}
11162 +#endif
11163 +
11164 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11165 {
11166 struct mm_struct *mm = current->mm;
11167 @@ -342,6 +805,29 @@ retry:
11168 if (!vma)
11169 goto bad_area;
11170
11171 +#ifdef CONFIG_PAX_PAGEEXEC
11172 + /* PaX: detect ITLB misses on non-exec pages */
11173 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11174 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11175 + {
11176 + if (address != regs->tpc)
11177 + goto good_area;
11178 +
11179 + up_read(&mm->mmap_sem);
11180 + switch (pax_handle_fetch_fault(regs)) {
11181 +
11182 +#ifdef CONFIG_PAX_EMUPLT
11183 + case 2:
11184 + case 3:
11185 + return;
11186 +#endif
11187 +
11188 + }
11189 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11190 + do_group_exit(SIGKILL);
11191 + }
11192 +#endif
11193 +
11194 /* Pure DTLB misses do not tell us whether the fault causing
11195 * load/store/atomic was a write or not, it only says that there
11196 * was no match. So in such a case we (carefully) read the
11197 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11198 index 9639964..806cd0c 100644
11199 --- a/arch/sparc/mm/hugetlbpage.c
11200 +++ b/arch/sparc/mm/hugetlbpage.c
11201 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11202 unsigned long addr,
11203 unsigned long len,
11204 unsigned long pgoff,
11205 - unsigned long flags)
11206 + unsigned long flags,
11207 + unsigned long offset)
11208 {
11209 unsigned long task_size = TASK_SIZE;
11210 struct vm_unmapped_area_info info;
11211 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11212
11213 info.flags = 0;
11214 info.length = len;
11215 - info.low_limit = TASK_UNMAPPED_BASE;
11216 + info.low_limit = mm->mmap_base;
11217 info.high_limit = min(task_size, VA_EXCLUDE_START);
11218 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11219 info.align_offset = 0;
11220 + info.threadstack_offset = offset;
11221 addr = vm_unmapped_area(&info);
11222
11223 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11224 VM_BUG_ON(addr != -ENOMEM);
11225 info.low_limit = VA_EXCLUDE_END;
11226 +
11227 +#ifdef CONFIG_PAX_RANDMMAP
11228 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11229 + info.low_limit += mm->delta_mmap;
11230 +#endif
11231 +
11232 info.high_limit = task_size;
11233 addr = vm_unmapped_area(&info);
11234 }
11235 @@ -58,7 +66,8 @@ static unsigned long
11236 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 const unsigned long len,
11238 const unsigned long pgoff,
11239 - const unsigned long flags)
11240 + const unsigned long flags,
11241 + const unsigned long offset)
11242 {
11243 struct mm_struct *mm = current->mm;
11244 unsigned long addr = addr0;
11245 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11246 info.high_limit = mm->mmap_base;
11247 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11248 info.align_offset = 0;
11249 + info.threadstack_offset = offset;
11250 addr = vm_unmapped_area(&info);
11251
11252 /*
11253 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11254 VM_BUG_ON(addr != -ENOMEM);
11255 info.flags = 0;
11256 info.low_limit = TASK_UNMAPPED_BASE;
11257 +
11258 +#ifdef CONFIG_PAX_RANDMMAP
11259 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11260 + info.low_limit += mm->delta_mmap;
11261 +#endif
11262 +
11263 info.high_limit = STACK_TOP32;
11264 addr = vm_unmapped_area(&info);
11265 }
11266 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11267 struct mm_struct *mm = current->mm;
11268 struct vm_area_struct *vma;
11269 unsigned long task_size = TASK_SIZE;
11270 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11271
11272 if (test_thread_flag(TIF_32BIT))
11273 task_size = STACK_TOP32;
11274 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11275 return addr;
11276 }
11277
11278 +#ifdef CONFIG_PAX_RANDMMAP
11279 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11280 +#endif
11281 +
11282 if (addr) {
11283 addr = ALIGN(addr, HPAGE_SIZE);
11284 vma = find_vma(mm, addr);
11285 - if (task_size - len >= addr &&
11286 - (!vma || addr + len <= vma->vm_start))
11287 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11288 return addr;
11289 }
11290 if (mm->get_unmapped_area == arch_get_unmapped_area)
11291 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11292 - pgoff, flags);
11293 + pgoff, flags, offset);
11294 else
11295 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11296 - pgoff, flags);
11297 + pgoff, flags, offset);
11298 }
11299
11300 pte_t *huge_pte_alloc(struct mm_struct *mm,
11301 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11302 index ed82eda..0d80e77 100644
11303 --- a/arch/sparc/mm/init_64.c
11304 +++ b/arch/sparc/mm/init_64.c
11305 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11306 int num_kernel_image_mappings;
11307
11308 #ifdef CONFIG_DEBUG_DCFLUSH
11309 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11310 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11311 #ifdef CONFIG_SMP
11312 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11313 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11314 #endif
11315 #endif
11316
11317 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11318 {
11319 BUG_ON(tlb_type == hypervisor);
11320 #ifdef CONFIG_DEBUG_DCFLUSH
11321 - atomic_inc(&dcpage_flushes);
11322 + atomic_inc_unchecked(&dcpage_flushes);
11323 #endif
11324
11325 #ifdef DCACHE_ALIASING_POSSIBLE
11326 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11327
11328 #ifdef CONFIG_DEBUG_DCFLUSH
11329 seq_printf(m, "DCPageFlushes\t: %d\n",
11330 - atomic_read(&dcpage_flushes));
11331 + atomic_read_unchecked(&dcpage_flushes));
11332 #ifdef CONFIG_SMP
11333 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11334 - atomic_read(&dcpage_flushes_xcall));
11335 + atomic_read_unchecked(&dcpage_flushes_xcall));
11336 #endif /* CONFIG_SMP */
11337 #endif /* CONFIG_DEBUG_DCFLUSH */
11338 }
11339 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11340 index ad220ee..2f537b3 100644
11341 --- a/arch/tile/include/asm/atomic_64.h
11342 +++ b/arch/tile/include/asm/atomic_64.h
11343 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11344
11345 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11346
11347 +#define atomic64_read_unchecked(v) atomic64_read(v)
11348 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11349 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11350 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11351 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11352 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11353 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11354 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11355 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11356 +
11357 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11358 #define smp_mb__before_atomic_dec() smp_mb()
11359 #define smp_mb__after_atomic_dec() smp_mb()
11360 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11361 index 6160761..00cac88 100644
11362 --- a/arch/tile/include/asm/cache.h
11363 +++ b/arch/tile/include/asm/cache.h
11364 @@ -15,11 +15,12 @@
11365 #ifndef _ASM_TILE_CACHE_H
11366 #define _ASM_TILE_CACHE_H
11367
11368 +#include <linux/const.h>
11369 #include <arch/chip.h>
11370
11371 /* bytes per L1 data cache line */
11372 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11373 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11374 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11375
11376 /* bytes per L2 cache line */
11377 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11378 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11379 index b6cde32..c0cb736 100644
11380 --- a/arch/tile/include/asm/uaccess.h
11381 +++ b/arch/tile/include/asm/uaccess.h
11382 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11383 const void __user *from,
11384 unsigned long n)
11385 {
11386 - int sz = __compiletime_object_size(to);
11387 + size_t sz = __compiletime_object_size(to);
11388
11389 - if (likely(sz == -1 || sz >= n))
11390 + if (likely(sz == (size_t)-1 || sz >= n))
11391 n = _copy_from_user(to, from, n);
11392 else
11393 copy_from_user_overflow();
11394 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11395 index 0cb3bba..7338b2d 100644
11396 --- a/arch/tile/mm/hugetlbpage.c
11397 +++ b/arch/tile/mm/hugetlbpage.c
11398 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11399 info.high_limit = TASK_SIZE;
11400 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11401 info.align_offset = 0;
11402 + info.threadstack_offset = 0;
11403 return vm_unmapped_area(&info);
11404 }
11405
11406 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11407 info.high_limit = current->mm->mmap_base;
11408 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11409 info.align_offset = 0;
11410 + info.threadstack_offset = 0;
11411 addr = vm_unmapped_area(&info);
11412
11413 /*
11414 diff --git a/arch/um/Makefile b/arch/um/Makefile
11415 index 133f7de..1d6f2f1 100644
11416 --- a/arch/um/Makefile
11417 +++ b/arch/um/Makefile
11418 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11419 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11420 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11421
11422 +ifdef CONSTIFY_PLUGIN
11423 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11424 +endif
11425 +
11426 #This will adjust *FLAGS accordingly to the platform.
11427 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11428
11429 diff --git a/arch/um/defconfig b/arch/um/defconfig
11430 index 2665e6b..3e3822b 100644
11431 --- a/arch/um/defconfig
11432 +++ b/arch/um/defconfig
11433 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11434 CONFIG_X86_L1_CACHE_SHIFT=5
11435 CONFIG_X86_XADD=y
11436 CONFIG_X86_PPRO_FENCE=y
11437 -CONFIG_X86_WP_WORKS_OK=y
11438 CONFIG_X86_INVLPG=y
11439 CONFIG_X86_BSWAP=y
11440 CONFIG_X86_POPAD_OK=y
11441 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11442 index 19e1bdd..3665b77 100644
11443 --- a/arch/um/include/asm/cache.h
11444 +++ b/arch/um/include/asm/cache.h
11445 @@ -1,6 +1,7 @@
11446 #ifndef __UM_CACHE_H
11447 #define __UM_CACHE_H
11448
11449 +#include <linux/const.h>
11450
11451 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11452 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11453 @@ -12,6 +13,6 @@
11454 # define L1_CACHE_SHIFT 5
11455 #endif
11456
11457 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11458 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11459
11460 #endif
11461 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11462 index 2e0a6b1..a64d0f5 100644
11463 --- a/arch/um/include/asm/kmap_types.h
11464 +++ b/arch/um/include/asm/kmap_types.h
11465 @@ -8,6 +8,6 @@
11466
11467 /* No more #include "asm/arch/kmap_types.h" ! */
11468
11469 -#define KM_TYPE_NR 14
11470 +#define KM_TYPE_NR 15
11471
11472 #endif
11473 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11474 index 5ff53d9..5850cdf 100644
11475 --- a/arch/um/include/asm/page.h
11476 +++ b/arch/um/include/asm/page.h
11477 @@ -14,6 +14,9 @@
11478 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11479 #define PAGE_MASK (~(PAGE_SIZE-1))
11480
11481 +#define ktla_ktva(addr) (addr)
11482 +#define ktva_ktla(addr) (addr)
11483 +
11484 #ifndef __ASSEMBLY__
11485
11486 struct page;
11487 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11488 index 0032f92..cd151e0 100644
11489 --- a/arch/um/include/asm/pgtable-3level.h
11490 +++ b/arch/um/include/asm/pgtable-3level.h
11491 @@ -58,6 +58,7 @@
11492 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11493 #define pud_populate(mm, pud, pmd) \
11494 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11495 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11496
11497 #ifdef CONFIG_64BIT
11498 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11499 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11500 index bbcef52..6a2a483 100644
11501 --- a/arch/um/kernel/process.c
11502 +++ b/arch/um/kernel/process.c
11503 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11504 return 2;
11505 }
11506
11507 -/*
11508 - * Only x86 and x86_64 have an arch_align_stack().
11509 - * All other arches have "#define arch_align_stack(x) (x)"
11510 - * in their asm/system.h
11511 - * As this is included in UML from asm-um/system-generic.h,
11512 - * we can use it to behave as the subarch does.
11513 - */
11514 -#ifndef arch_align_stack
11515 -unsigned long arch_align_stack(unsigned long sp)
11516 -{
11517 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11518 - sp -= get_random_int() % 8192;
11519 - return sp & ~0xf;
11520 -}
11521 -#endif
11522 -
11523 unsigned long get_wchan(struct task_struct *p)
11524 {
11525 unsigned long stack_page, sp, ip;
11526 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11527 index ad8f795..2c7eec6 100644
11528 --- a/arch/unicore32/include/asm/cache.h
11529 +++ b/arch/unicore32/include/asm/cache.h
11530 @@ -12,8 +12,10 @@
11531 #ifndef __UNICORE_CACHE_H__
11532 #define __UNICORE_CACHE_H__
11533
11534 -#define L1_CACHE_SHIFT (5)
11535 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11536 +#include <linux/const.h>
11537 +
11538 +#define L1_CACHE_SHIFT 5
11539 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11540
11541 /*
11542 * Memory returned by kmalloc() may be used for DMA, so we must make
11543 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11544 index f67e839..419b5f7 100644
11545 --- a/arch/x86/Kconfig
11546 +++ b/arch/x86/Kconfig
11547 @@ -247,7 +247,7 @@ config X86_HT
11548
11549 config X86_32_LAZY_GS
11550 def_bool y
11551 - depends on X86_32 && !CC_STACKPROTECTOR
11552 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11553
11554 config ARCH_HWEIGHT_CFLAGS
11555 string
11556 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11557
11558 config X86_MSR
11559 tristate "/dev/cpu/*/msr - Model-specific register support"
11560 + depends on !GRKERNSEC_KMEM
11561 ---help---
11562 This device gives privileged processes access to the x86
11563 Model-Specific Registers (MSRs). It is a character device with
11564 @@ -1122,7 +1123,7 @@ choice
11565
11566 config NOHIGHMEM
11567 bool "off"
11568 - depends on !X86_NUMAQ
11569 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11570 ---help---
11571 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11572 However, the address space of 32-bit x86 processors is only 4
11573 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11574
11575 config HIGHMEM4G
11576 bool "4GB"
11577 - depends on !X86_NUMAQ
11578 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11579 ---help---
11580 Select this if you have a 32-bit processor and between 1 and 4
11581 gigabytes of physical RAM.
11582 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11583 hex
11584 default 0xB0000000 if VMSPLIT_3G_OPT
11585 default 0x80000000 if VMSPLIT_2G
11586 - default 0x78000000 if VMSPLIT_2G_OPT
11587 + default 0x70000000 if VMSPLIT_2G_OPT
11588 default 0x40000000 if VMSPLIT_1G
11589 default 0xC0000000
11590 depends on X86_32
11591 @@ -1614,6 +1615,7 @@ config SECCOMP
11592
11593 config CC_STACKPROTECTOR
11594 bool "Enable -fstack-protector buffer overflow detection"
11595 + depends on X86_64 || !PAX_MEMORY_UDEREF
11596 ---help---
11597 This option turns on the -fstack-protector GCC feature. This
11598 feature puts, at the beginning of functions, a canary value on
11599 @@ -1733,6 +1735,8 @@ config X86_NEED_RELOCS
11600 config PHYSICAL_ALIGN
11601 hex "Alignment value to which kernel should be aligned"
11602 default "0x1000000"
11603 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11604 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11605 range 0x2000 0x1000000 if X86_32
11606 range 0x200000 0x1000000 if X86_64
11607 ---help---
11608 @@ -1812,9 +1816,10 @@ config DEBUG_HOTPLUG_CPU0
11609 If unsure, say N.
11610
11611 config COMPAT_VDSO
11612 - def_bool y
11613 + def_bool n
11614 prompt "Compat VDSO support"
11615 depends on X86_32 || IA32_EMULATION
11616 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11617 ---help---
11618 Map the 32-bit VDSO to the predictable old-style address too.
11619
11620 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11621 index c026cca..14657ae 100644
11622 --- a/arch/x86/Kconfig.cpu
11623 +++ b/arch/x86/Kconfig.cpu
11624 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11625
11626 config X86_F00F_BUG
11627 def_bool y
11628 - depends on M586MMX || M586TSC || M586 || M486
11629 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11630
11631 config X86_INVD_BUG
11632 def_bool y
11633 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11634
11635 config X86_ALIGNMENT_16
11636 def_bool y
11637 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11638 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11639
11640 config X86_INTEL_USERCOPY
11641 def_bool y
11642 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11643 # generates cmov.
11644 config X86_CMOV
11645 def_bool y
11646 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11647 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11648
11649 config X86_MINIMUM_CPU_FAMILY
11650 int
11651 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11652 index 78d91af..8ceb94b 100644
11653 --- a/arch/x86/Kconfig.debug
11654 +++ b/arch/x86/Kconfig.debug
11655 @@ -74,7 +74,7 @@ config X86_PTDUMP
11656 config DEBUG_RODATA
11657 bool "Write protect kernel read-only data structures"
11658 default y
11659 - depends on DEBUG_KERNEL
11660 + depends on DEBUG_KERNEL && BROKEN
11661 ---help---
11662 Mark the kernel read-only data as write-protected in the pagetables,
11663 in order to catch accidental (and incorrect) writes to such const
11664 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11665
11666 config DEBUG_SET_MODULE_RONX
11667 bool "Set loadable kernel module data as NX and text as RO"
11668 - depends on MODULES
11669 + depends on MODULES && BROKEN
11670 ---help---
11671 This option helps catch unintended modifications to loadable
11672 kernel module's text and read-only data. It also prevents execution
11673 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11674 index 41250fb..863762e 100644
11675 --- a/arch/x86/Makefile
11676 +++ b/arch/x86/Makefile
11677 @@ -46,14 +46,12 @@ ifeq ($(CONFIG_X86_32),y)
11678 # CPU-specific tuning. Anything which can be shared with UML should go here.
11679 include $(srctree)/arch/x86/Makefile_32.cpu
11680 KBUILD_CFLAGS += $(cflags-y)
11681 -
11682 - # temporary until string.h is fixed
11683 - KBUILD_CFLAGS += -ffreestanding
11684 else
11685 BITS := 64
11686 UTS_MACHINE := x86_64
11687 CHECKFLAGS += -D__x86_64__ -m64
11688
11689 + biarch := $(call cc-option,-m64)
11690 KBUILD_AFLAGS += -m64
11691 KBUILD_CFLAGS += -m64
11692
11693 @@ -83,6 +81,9 @@ else
11694 KBUILD_CFLAGS += -maccumulate-outgoing-args
11695 endif
11696
11697 +# temporary until string.h is fixed
11698 +KBUILD_CFLAGS += -ffreestanding
11699 +
11700 ifdef CONFIG_CC_STACKPROTECTOR
11701 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11702 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11703 @@ -241,3 +242,12 @@ define archhelp
11704 echo ' FDINITRD=file initrd for the booted kernel'
11705 echo ' kvmconfig - Enable additional options for guest kernel support'
11706 endef
11707 +
11708 +define OLD_LD
11709 +
11710 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11711 +*** Please upgrade your binutils to 2.18 or newer
11712 +endef
11713 +
11714 +archprepare:
11715 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11716 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11717 index 379814b..add62ce 100644
11718 --- a/arch/x86/boot/Makefile
11719 +++ b/arch/x86/boot/Makefile
11720 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11721 $(call cc-option, -fno-stack-protector) \
11722 $(call cc-option, -mpreferred-stack-boundary=2)
11723 KBUILD_CFLAGS += $(call cc-option, -m32)
11724 +ifdef CONSTIFY_PLUGIN
11725 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11726 +endif
11727 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11728 GCOV_PROFILE := n
11729
11730 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11731 index 878e4b9..20537ab 100644
11732 --- a/arch/x86/boot/bitops.h
11733 +++ b/arch/x86/boot/bitops.h
11734 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11735 u8 v;
11736 const u32 *p = (const u32 *)addr;
11737
11738 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11739 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11740 return v;
11741 }
11742
11743 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11744
11745 static inline void set_bit(int nr, void *addr)
11746 {
11747 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11748 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11749 }
11750
11751 #endif /* BOOT_BITOPS_H */
11752 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11753 index ef72bae..353a184 100644
11754 --- a/arch/x86/boot/boot.h
11755 +++ b/arch/x86/boot/boot.h
11756 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11757 static inline u16 ds(void)
11758 {
11759 u16 seg;
11760 - asm("movw %%ds,%0" : "=rm" (seg));
11761 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11762 return seg;
11763 }
11764
11765 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11766 static inline int memcmp(const void *s1, const void *s2, size_t len)
11767 {
11768 u8 diff;
11769 - asm("repe; cmpsb; setnz %0"
11770 + asm volatile("repe; cmpsb; setnz %0"
11771 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11772 return diff;
11773 }
11774 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11775 index dcd90df..c830d7d 100644
11776 --- a/arch/x86/boot/compressed/Makefile
11777 +++ b/arch/x86/boot/compressed/Makefile
11778 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11779 KBUILD_CFLAGS += $(cflags-y)
11780 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11781 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11782 +ifdef CONSTIFY_PLUGIN
11783 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11784 +endif
11785
11786 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11787 GCOV_PROFILE := n
11788 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11789 index b7388a4..03844ec 100644
11790 --- a/arch/x86/boot/compressed/eboot.c
11791 +++ b/arch/x86/boot/compressed/eboot.c
11792 @@ -150,7 +150,6 @@ again:
11793 *addr = max_addr;
11794 }
11795
11796 -free_pool:
11797 efi_call_phys1(sys_table->boottime->free_pool, map);
11798
11799 fail:
11800 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11801 if (i == map_size / desc_size)
11802 status = EFI_NOT_FOUND;
11803
11804 -free_pool:
11805 efi_call_phys1(sys_table->boottime->free_pool, map);
11806 fail:
11807 return status;
11808 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11809 index a53440e..c3dbf1e 100644
11810 --- a/arch/x86/boot/compressed/efi_stub_32.S
11811 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11812 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11813 * parameter 2, ..., param n. To make things easy, we save the return
11814 * address of efi_call_phys in a global variable.
11815 */
11816 - popl %ecx
11817 - movl %ecx, saved_return_addr(%edx)
11818 - /* get the function pointer into ECX*/
11819 - popl %ecx
11820 - movl %ecx, efi_rt_function_ptr(%edx)
11821 + popl saved_return_addr(%edx)
11822 + popl efi_rt_function_ptr(%edx)
11823
11824 /*
11825 * 3. Call the physical function.
11826 */
11827 - call *%ecx
11828 + call *efi_rt_function_ptr(%edx)
11829
11830 /*
11831 * 4. Balance the stack. And because EAX contain the return value,
11832 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11833 1: popl %edx
11834 subl $1b, %edx
11835
11836 - movl efi_rt_function_ptr(%edx), %ecx
11837 - pushl %ecx
11838 + pushl efi_rt_function_ptr(%edx)
11839
11840 /*
11841 * 10. Push the saved return address onto the stack and return.
11842 */
11843 - movl saved_return_addr(%edx), %ecx
11844 - pushl %ecx
11845 - ret
11846 + jmpl *saved_return_addr(%edx)
11847 ENDPROC(efi_call_phys)
11848 .previous
11849
11850 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11851 index 5d6f689..9d06730 100644
11852 --- a/arch/x86/boot/compressed/head_32.S
11853 +++ b/arch/x86/boot/compressed/head_32.S
11854 @@ -118,7 +118,7 @@ preferred_addr:
11855 notl %eax
11856 andl %eax, %ebx
11857 #else
11858 - movl $LOAD_PHYSICAL_ADDR, %ebx
11859 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11860 #endif
11861
11862 /* Target address to relocate to for decompression */
11863 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11864 index c337422..2c5be72 100644
11865 --- a/arch/x86/boot/compressed/head_64.S
11866 +++ b/arch/x86/boot/compressed/head_64.S
11867 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11868 notl %eax
11869 andl %eax, %ebx
11870 #else
11871 - movl $LOAD_PHYSICAL_ADDR, %ebx
11872 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11873 #endif
11874
11875 /* Target address to relocate to for decompression */
11876 @@ -270,7 +270,7 @@ preferred_addr:
11877 notq %rax
11878 andq %rax, %rbp
11879 #else
11880 - movq $LOAD_PHYSICAL_ADDR, %rbp
11881 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11882 #endif
11883
11884 /* Target address to relocate to for decompression */
11885 @@ -362,8 +362,8 @@ gdt:
11886 .long gdt
11887 .word 0
11888 .quad 0x0000000000000000 /* NULL descriptor */
11889 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11890 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11891 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11892 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11893 .quad 0x0080890000000000 /* TS descriptor */
11894 .quad 0x0000000000000000 /* TS continued */
11895 gdt_end:
11896 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11897 index 434f077..b6b4b38 100644
11898 --- a/arch/x86/boot/compressed/misc.c
11899 +++ b/arch/x86/boot/compressed/misc.c
11900 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11901 * Calculate the delta between where vmlinux was linked to load
11902 * and where it was actually loaded.
11903 */
11904 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11905 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11906 if (!delta) {
11907 debug_putstr("No relocation needed... ");
11908 return;
11909 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
11910 case PT_LOAD:
11911 #ifdef CONFIG_RELOCATABLE
11912 dest = output;
11913 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11914 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11915 #else
11916 dest = (void *)(phdr->p_paddr);
11917 #endif
11918 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11919 error("Destination address too large");
11920 #endif
11921 #ifndef CONFIG_RELOCATABLE
11922 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11923 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11924 error("Wrong destination address");
11925 #endif
11926
11927 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11928 index 4d3ff03..e4972ff 100644
11929 --- a/arch/x86/boot/cpucheck.c
11930 +++ b/arch/x86/boot/cpucheck.c
11931 @@ -74,7 +74,7 @@ static int has_fpu(void)
11932 u16 fcw = -1, fsw = -1;
11933 u32 cr0;
11934
11935 - asm("movl %%cr0,%0" : "=r" (cr0));
11936 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11937 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11938 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11939 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11940 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11941 {
11942 u32 f0, f1;
11943
11944 - asm("pushfl ; "
11945 + asm volatile("pushfl ; "
11946 "pushfl ; "
11947 "popl %0 ; "
11948 "movl %0,%1 ; "
11949 @@ -115,7 +115,7 @@ static void get_flags(void)
11950 set_bit(X86_FEATURE_FPU, cpu.flags);
11951
11952 if (has_eflag(X86_EFLAGS_ID)) {
11953 - asm("cpuid"
11954 + asm volatile("cpuid"
11955 : "=a" (max_intel_level),
11956 "=b" (cpu_vendor[0]),
11957 "=d" (cpu_vendor[1]),
11958 @@ -124,7 +124,7 @@ static void get_flags(void)
11959
11960 if (max_intel_level >= 0x00000001 &&
11961 max_intel_level <= 0x0000ffff) {
11962 - asm("cpuid"
11963 + asm volatile("cpuid"
11964 : "=a" (tfms),
11965 "=c" (cpu.flags[4]),
11966 "=d" (cpu.flags[0])
11967 @@ -136,7 +136,7 @@ static void get_flags(void)
11968 cpu.model += ((tfms >> 16) & 0xf) << 4;
11969 }
11970
11971 - asm("cpuid"
11972 + asm volatile("cpuid"
11973 : "=a" (max_amd_level)
11974 : "a" (0x80000000)
11975 : "ebx", "ecx", "edx");
11976 @@ -144,7 +144,7 @@ static void get_flags(void)
11977 if (max_amd_level >= 0x80000001 &&
11978 max_amd_level <= 0x8000ffff) {
11979 u32 eax = 0x80000001;
11980 - asm("cpuid"
11981 + asm volatile("cpuid"
11982 : "+a" (eax),
11983 "=c" (cpu.flags[6]),
11984 "=d" (cpu.flags[1])
11985 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11986 u32 ecx = MSR_K7_HWCR;
11987 u32 eax, edx;
11988
11989 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11990 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11991 eax &= ~(1 << 15);
11992 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11993 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11994
11995 get_flags(); /* Make sure it really did something */
11996 err = check_flags();
11997 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11998 u32 ecx = MSR_VIA_FCR;
11999 u32 eax, edx;
12000
12001 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12002 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12003 eax |= (1<<1)|(1<<7);
12004 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12005 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12006
12007 set_bit(X86_FEATURE_CX8, cpu.flags);
12008 err = check_flags();
12009 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12010 u32 eax, edx;
12011 u32 level = 1;
12012
12013 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12014 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12015 - asm("cpuid"
12016 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12017 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12018 + asm volatile("cpuid"
12019 : "+a" (level), "=d" (cpu.flags[0])
12020 : : "ecx", "ebx");
12021 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12022 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12023
12024 err = check_flags();
12025 }
12026 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12027 index 9ec06a1..2c25e79 100644
12028 --- a/arch/x86/boot/header.S
12029 +++ b/arch/x86/boot/header.S
12030 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12031 # single linked list of
12032 # struct setup_data
12033
12034 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12035 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12036
12037 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12039 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12040 +#else
12041 #define VO_INIT_SIZE (VO__end - VO__text)
12042 +#endif
12043 #if ZO_INIT_SIZE > VO_INIT_SIZE
12044 #define INIT_SIZE ZO_INIT_SIZE
12045 #else
12046 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12047 index db75d07..8e6d0af 100644
12048 --- a/arch/x86/boot/memory.c
12049 +++ b/arch/x86/boot/memory.c
12050 @@ -19,7 +19,7 @@
12051
12052 static int detect_memory_e820(void)
12053 {
12054 - int count = 0;
12055 + unsigned int count = 0;
12056 struct biosregs ireg, oreg;
12057 struct e820entry *desc = boot_params.e820_map;
12058 static struct e820entry buf; /* static so it is zeroed */
12059 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12060 index 11e8c6e..fdbb1ed 100644
12061 --- a/arch/x86/boot/video-vesa.c
12062 +++ b/arch/x86/boot/video-vesa.c
12063 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12064
12065 boot_params.screen_info.vesapm_seg = oreg.es;
12066 boot_params.screen_info.vesapm_off = oreg.di;
12067 + boot_params.screen_info.vesapm_size = oreg.cx;
12068 }
12069
12070 /*
12071 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12072 index 43eda28..5ab5fdb 100644
12073 --- a/arch/x86/boot/video.c
12074 +++ b/arch/x86/boot/video.c
12075 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12076 static unsigned int get_entry(void)
12077 {
12078 char entry_buf[4];
12079 - int i, len = 0;
12080 + unsigned int i, len = 0;
12081 int key;
12082 unsigned int v;
12083
12084 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12085 index 9105655..5e37f27 100644
12086 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12087 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12088 @@ -8,6 +8,8 @@
12089 * including this sentence is retained in full.
12090 */
12091
12092 +#include <asm/alternative-asm.h>
12093 +
12094 .extern crypto_ft_tab
12095 .extern crypto_it_tab
12096 .extern crypto_fl_tab
12097 @@ -70,6 +72,8 @@
12098 je B192; \
12099 leaq 32(r9),r9;
12100
12101 +#define ret pax_force_retaddr 0, 1; ret
12102 +
12103 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12104 movq r1,r2; \
12105 movq r3,r4; \
12106 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12107 index 477e9d7..3ab339f 100644
12108 --- a/arch/x86/crypto/aesni-intel_asm.S
12109 +++ b/arch/x86/crypto/aesni-intel_asm.S
12110 @@ -31,6 +31,7 @@
12111
12112 #include <linux/linkage.h>
12113 #include <asm/inst.h>
12114 +#include <asm/alternative-asm.h>
12115
12116 #ifdef __x86_64__
12117 .data
12118 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12119 pop %r14
12120 pop %r13
12121 pop %r12
12122 + pax_force_retaddr 0, 1
12123 ret
12124 ENDPROC(aesni_gcm_dec)
12125
12126 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12127 pop %r14
12128 pop %r13
12129 pop %r12
12130 + pax_force_retaddr 0, 1
12131 ret
12132 ENDPROC(aesni_gcm_enc)
12133
12134 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12135 pxor %xmm1, %xmm0
12136 movaps %xmm0, (TKEYP)
12137 add $0x10, TKEYP
12138 + pax_force_retaddr_bts
12139 ret
12140 ENDPROC(_key_expansion_128)
12141 ENDPROC(_key_expansion_256a)
12142 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12143 shufps $0b01001110, %xmm2, %xmm1
12144 movaps %xmm1, 0x10(TKEYP)
12145 add $0x20, TKEYP
12146 + pax_force_retaddr_bts
12147 ret
12148 ENDPROC(_key_expansion_192a)
12149
12150 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12151
12152 movaps %xmm0, (TKEYP)
12153 add $0x10, TKEYP
12154 + pax_force_retaddr_bts
12155 ret
12156 ENDPROC(_key_expansion_192b)
12157
12158 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12159 pxor %xmm1, %xmm2
12160 movaps %xmm2, (TKEYP)
12161 add $0x10, TKEYP
12162 + pax_force_retaddr_bts
12163 ret
12164 ENDPROC(_key_expansion_256b)
12165
12166 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12167 #ifndef __x86_64__
12168 popl KEYP
12169 #endif
12170 + pax_force_retaddr 0, 1
12171 ret
12172 ENDPROC(aesni_set_key)
12173
12174 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12175 popl KLEN
12176 popl KEYP
12177 #endif
12178 + pax_force_retaddr 0, 1
12179 ret
12180 ENDPROC(aesni_enc)
12181
12182 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12183 AESENC KEY STATE
12184 movaps 0x70(TKEYP), KEY
12185 AESENCLAST KEY STATE
12186 + pax_force_retaddr_bts
12187 ret
12188 ENDPROC(_aesni_enc1)
12189
12190 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12191 AESENCLAST KEY STATE2
12192 AESENCLAST KEY STATE3
12193 AESENCLAST KEY STATE4
12194 + pax_force_retaddr_bts
12195 ret
12196 ENDPROC(_aesni_enc4)
12197
12198 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12199 popl KLEN
12200 popl KEYP
12201 #endif
12202 + pax_force_retaddr 0, 1
12203 ret
12204 ENDPROC(aesni_dec)
12205
12206 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12207 AESDEC KEY STATE
12208 movaps 0x70(TKEYP), KEY
12209 AESDECLAST KEY STATE
12210 + pax_force_retaddr_bts
12211 ret
12212 ENDPROC(_aesni_dec1)
12213
12214 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12215 AESDECLAST KEY STATE2
12216 AESDECLAST KEY STATE3
12217 AESDECLAST KEY STATE4
12218 + pax_force_retaddr_bts
12219 ret
12220 ENDPROC(_aesni_dec4)
12221
12222 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12223 popl KEYP
12224 popl LEN
12225 #endif
12226 + pax_force_retaddr 0, 1
12227 ret
12228 ENDPROC(aesni_ecb_enc)
12229
12230 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12231 popl KEYP
12232 popl LEN
12233 #endif
12234 + pax_force_retaddr 0, 1
12235 ret
12236 ENDPROC(aesni_ecb_dec)
12237
12238 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12239 popl LEN
12240 popl IVP
12241 #endif
12242 + pax_force_retaddr 0, 1
12243 ret
12244 ENDPROC(aesni_cbc_enc)
12245
12246 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12247 popl LEN
12248 popl IVP
12249 #endif
12250 + pax_force_retaddr 0, 1
12251 ret
12252 ENDPROC(aesni_cbc_dec)
12253
12254 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12255 mov $1, TCTR_LOW
12256 MOVQ_R64_XMM TCTR_LOW INC
12257 MOVQ_R64_XMM CTR TCTR_LOW
12258 + pax_force_retaddr_bts
12259 ret
12260 ENDPROC(_aesni_inc_init)
12261
12262 @@ -2579,6 +2598,7 @@ _aesni_inc:
12263 .Linc_low:
12264 movaps CTR, IV
12265 PSHUFB_XMM BSWAP_MASK IV
12266 + pax_force_retaddr_bts
12267 ret
12268 ENDPROC(_aesni_inc)
12269
12270 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12271 .Lctr_enc_ret:
12272 movups IV, (IVP)
12273 .Lctr_enc_just_ret:
12274 + pax_force_retaddr 0, 1
12275 ret
12276 ENDPROC(aesni_ctr_enc)
12277
12278 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12279 pxor INC, STATE4
12280 movdqu STATE4, 0x70(OUTP)
12281
12282 + pax_force_retaddr 0, 1
12283 ret
12284 ENDPROC(aesni_xts_crypt8)
12285
12286 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12287 index 246c670..4d1ed00 100644
12288 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12289 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12290 @@ -21,6 +21,7 @@
12291 */
12292
12293 #include <linux/linkage.h>
12294 +#include <asm/alternative-asm.h>
12295
12296 .file "blowfish-x86_64-asm.S"
12297 .text
12298 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12299 jnz .L__enc_xor;
12300
12301 write_block();
12302 + pax_force_retaddr 0, 1
12303 ret;
12304 .L__enc_xor:
12305 xor_block();
12306 + pax_force_retaddr 0, 1
12307 ret;
12308 ENDPROC(__blowfish_enc_blk)
12309
12310 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12311
12312 movq %r11, %rbp;
12313
12314 + pax_force_retaddr 0, 1
12315 ret;
12316 ENDPROC(blowfish_dec_blk)
12317
12318 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12319
12320 popq %rbx;
12321 popq %rbp;
12322 + pax_force_retaddr 0, 1
12323 ret;
12324
12325 .L__enc_xor4:
12326 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12327
12328 popq %rbx;
12329 popq %rbp;
12330 + pax_force_retaddr 0, 1
12331 ret;
12332 ENDPROC(__blowfish_enc_blk_4way)
12333
12334 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12335 popq %rbx;
12336 popq %rbp;
12337
12338 + pax_force_retaddr 0, 1
12339 ret;
12340 ENDPROC(blowfish_dec_blk_4way)
12341 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12342 index ce71f92..2dd5b1e 100644
12343 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12344 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12345 @@ -16,6 +16,7 @@
12346 */
12347
12348 #include <linux/linkage.h>
12349 +#include <asm/alternative-asm.h>
12350
12351 #define CAMELLIA_TABLE_BYTE_LEN 272
12352
12353 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12354 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12355 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12356 %rcx, (%r9));
12357 + pax_force_retaddr_bts
12358 ret;
12359 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12360
12361 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12362 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12363 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12364 %rax, (%r9));
12365 + pax_force_retaddr_bts
12366 ret;
12367 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12368
12369 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12370 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12371 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12372
12373 + pax_force_retaddr_bts
12374 ret;
12375
12376 .align 8
12377 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12378 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12379 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12380
12381 + pax_force_retaddr_bts
12382 ret;
12383
12384 .align 8
12385 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12386 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12387 %xmm8, %rsi);
12388
12389 + pax_force_retaddr 0, 1
12390 ret;
12391 ENDPROC(camellia_ecb_enc_16way)
12392
12393 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12394 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12395 %xmm8, %rsi);
12396
12397 + pax_force_retaddr 0, 1
12398 ret;
12399 ENDPROC(camellia_ecb_dec_16way)
12400
12401 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12402 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12403 %xmm8, %rsi);
12404
12405 + pax_force_retaddr 0, 1
12406 ret;
12407 ENDPROC(camellia_cbc_dec_16way)
12408
12409 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12410 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12411 %xmm8, %rsi);
12412
12413 + pax_force_retaddr 0, 1
12414 ret;
12415 ENDPROC(camellia_ctr_16way)
12416
12417 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12418 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12419 %xmm8, %rsi);
12420
12421 + pax_force_retaddr 0, 1
12422 ret;
12423 ENDPROC(camellia_xts_crypt_16way)
12424
12425 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12426 index 0e0b886..8fc756a 100644
12427 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12428 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12429 @@ -11,6 +11,7 @@
12430 */
12431
12432 #include <linux/linkage.h>
12433 +#include <asm/alternative-asm.h>
12434
12435 #define CAMELLIA_TABLE_BYTE_LEN 272
12436
12437 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12438 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12439 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12440 %rcx, (%r9));
12441 + pax_force_retaddr_bts
12442 ret;
12443 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12444
12445 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12446 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12447 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12448 %rax, (%r9));
12449 + pax_force_retaddr_bts
12450 ret;
12451 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12452
12453 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12454 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12455 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12456
12457 + pax_force_retaddr_bts
12458 ret;
12459
12460 .align 8
12461 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12462 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12463 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12464
12465 + pax_force_retaddr_bts
12466 ret;
12467
12468 .align 8
12469 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12470
12471 vzeroupper;
12472
12473 + pax_force_retaddr 0, 1
12474 ret;
12475 ENDPROC(camellia_ecb_enc_32way)
12476
12477 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12478
12479 vzeroupper;
12480
12481 + pax_force_retaddr 0, 1
12482 ret;
12483 ENDPROC(camellia_ecb_dec_32way)
12484
12485 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12486
12487 vzeroupper;
12488
12489 + pax_force_retaddr 0, 1
12490 ret;
12491 ENDPROC(camellia_cbc_dec_32way)
12492
12493 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12494
12495 vzeroupper;
12496
12497 + pax_force_retaddr 0, 1
12498 ret;
12499 ENDPROC(camellia_ctr_32way)
12500
12501 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12502
12503 vzeroupper;
12504
12505 + pax_force_retaddr 0, 1
12506 ret;
12507 ENDPROC(camellia_xts_crypt_32way)
12508
12509 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12510 index 310319c..ce174a4 100644
12511 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12512 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12513 @@ -21,6 +21,7 @@
12514 */
12515
12516 #include <linux/linkage.h>
12517 +#include <asm/alternative-asm.h>
12518
12519 .file "camellia-x86_64-asm_64.S"
12520 .text
12521 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12522 enc_outunpack(mov, RT1);
12523
12524 movq RRBP, %rbp;
12525 + pax_force_retaddr 0, 1
12526 ret;
12527
12528 .L__enc_xor:
12529 enc_outunpack(xor, RT1);
12530
12531 movq RRBP, %rbp;
12532 + pax_force_retaddr 0, 1
12533 ret;
12534 ENDPROC(__camellia_enc_blk)
12535
12536 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12537 dec_outunpack();
12538
12539 movq RRBP, %rbp;
12540 + pax_force_retaddr 0, 1
12541 ret;
12542 ENDPROC(camellia_dec_blk)
12543
12544 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12545
12546 movq RRBP, %rbp;
12547 popq %rbx;
12548 + pax_force_retaddr 0, 1
12549 ret;
12550
12551 .L__enc2_xor:
12552 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12553
12554 movq RRBP, %rbp;
12555 popq %rbx;
12556 + pax_force_retaddr 0, 1
12557 ret;
12558 ENDPROC(__camellia_enc_blk_2way)
12559
12560 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12561
12562 movq RRBP, %rbp;
12563 movq RXOR, %rbx;
12564 + pax_force_retaddr 0, 1
12565 ret;
12566 ENDPROC(camellia_dec_blk_2way)
12567 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12568 index c35fd5d..c1ee236 100644
12569 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12570 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12571 @@ -24,6 +24,7 @@
12572 */
12573
12574 #include <linux/linkage.h>
12575 +#include <asm/alternative-asm.h>
12576
12577 .file "cast5-avx-x86_64-asm_64.S"
12578
12579 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12580 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12581 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12582
12583 + pax_force_retaddr 0, 1
12584 ret;
12585 ENDPROC(__cast5_enc_blk16)
12586
12587 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12588 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12589 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12590
12591 + pax_force_retaddr 0, 1
12592 ret;
12593
12594 .L__skip_dec:
12595 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12596 vmovdqu RR4, (6*4*4)(%r11);
12597 vmovdqu RL4, (7*4*4)(%r11);
12598
12599 + pax_force_retaddr
12600 ret;
12601 ENDPROC(cast5_ecb_enc_16way)
12602
12603 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12604 vmovdqu RR4, (6*4*4)(%r11);
12605 vmovdqu RL4, (7*4*4)(%r11);
12606
12607 + pax_force_retaddr
12608 ret;
12609 ENDPROC(cast5_ecb_dec_16way)
12610
12611 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12612
12613 popq %r12;
12614
12615 + pax_force_retaddr
12616 ret;
12617 ENDPROC(cast5_cbc_dec_16way)
12618
12619 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12620
12621 popq %r12;
12622
12623 + pax_force_retaddr
12624 ret;
12625 ENDPROC(cast5_ctr_16way)
12626 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12627 index e3531f8..18ded3a 100644
12628 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12629 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12630 @@ -24,6 +24,7 @@
12631 */
12632
12633 #include <linux/linkage.h>
12634 +#include <asm/alternative-asm.h>
12635 #include "glue_helper-asm-avx.S"
12636
12637 .file "cast6-avx-x86_64-asm_64.S"
12638 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12639 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12640 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12641
12642 + pax_force_retaddr 0, 1
12643 ret;
12644 ENDPROC(__cast6_enc_blk8)
12645
12646 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12647 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12648 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12649
12650 + pax_force_retaddr 0, 1
12651 ret;
12652 ENDPROC(__cast6_dec_blk8)
12653
12654 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12655
12656 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12657
12658 + pax_force_retaddr
12659 ret;
12660 ENDPROC(cast6_ecb_enc_8way)
12661
12662 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12663
12664 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12665
12666 + pax_force_retaddr
12667 ret;
12668 ENDPROC(cast6_ecb_dec_8way)
12669
12670 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12671
12672 popq %r12;
12673
12674 + pax_force_retaddr
12675 ret;
12676 ENDPROC(cast6_cbc_dec_8way)
12677
12678 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12679
12680 popq %r12;
12681
12682 + pax_force_retaddr
12683 ret;
12684 ENDPROC(cast6_ctr_8way)
12685
12686 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12687 /* dst <= regs xor IVs(in dst) */
12688 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12689
12690 + pax_force_retaddr
12691 ret;
12692 ENDPROC(cast6_xts_enc_8way)
12693
12694 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12695 /* dst <= regs xor IVs(in dst) */
12696 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12697
12698 + pax_force_retaddr
12699 ret;
12700 ENDPROC(cast6_xts_dec_8way)
12701 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12702 index dbc4339..3d868c5 100644
12703 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12704 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12705 @@ -45,6 +45,7 @@
12706
12707 #include <asm/inst.h>
12708 #include <linux/linkage.h>
12709 +#include <asm/alternative-asm.h>
12710
12711 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12712
12713 @@ -312,6 +313,7 @@ do_return:
12714 popq %rsi
12715 popq %rdi
12716 popq %rbx
12717 + pax_force_retaddr 0, 1
12718 ret
12719
12720 ################################################################
12721 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12722 index 586f41a..d02851e 100644
12723 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12724 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12725 @@ -18,6 +18,7 @@
12726
12727 #include <linux/linkage.h>
12728 #include <asm/inst.h>
12729 +#include <asm/alternative-asm.h>
12730
12731 .data
12732
12733 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12734 psrlq $1, T2
12735 pxor T2, T1
12736 pxor T1, DATA
12737 + pax_force_retaddr
12738 ret
12739 ENDPROC(__clmul_gf128mul_ble)
12740
12741 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12742 call __clmul_gf128mul_ble
12743 PSHUFB_XMM BSWAP DATA
12744 movups DATA, (%rdi)
12745 + pax_force_retaddr
12746 ret
12747 ENDPROC(clmul_ghash_mul)
12748
12749 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12750 PSHUFB_XMM BSWAP DATA
12751 movups DATA, (%rdi)
12752 .Lupdate_just_ret:
12753 + pax_force_retaddr
12754 ret
12755 ENDPROC(clmul_ghash_update)
12756
12757 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12758 pand .Lpoly, %xmm1
12759 pxor %xmm1, %xmm0
12760 movups %xmm0, (%rdi)
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(clmul_ghash_setkey)
12764 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12765 index 9279e0b..9270820 100644
12766 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12767 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12768 @@ -1,4 +1,5 @@
12769 #include <linux/linkage.h>
12770 +#include <asm/alternative-asm.h>
12771
12772 # enter salsa20_encrypt_bytes
12773 ENTRY(salsa20_encrypt_bytes)
12774 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12775 add %r11,%rsp
12776 mov %rdi,%rax
12777 mov %rsi,%rdx
12778 + pax_force_retaddr 0, 1
12779 ret
12780 # bytesatleast65:
12781 ._bytesatleast65:
12782 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12783 add %r11,%rsp
12784 mov %rdi,%rax
12785 mov %rsi,%rdx
12786 + pax_force_retaddr
12787 ret
12788 ENDPROC(salsa20_keysetup)
12789
12790 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12791 add %r11,%rsp
12792 mov %rdi,%rax
12793 mov %rsi,%rdx
12794 + pax_force_retaddr
12795 ret
12796 ENDPROC(salsa20_ivsetup)
12797 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12798 index 2f202f4..d9164d6 100644
12799 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12800 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12801 @@ -24,6 +24,7 @@
12802 */
12803
12804 #include <linux/linkage.h>
12805 +#include <asm/alternative-asm.h>
12806 #include "glue_helper-asm-avx.S"
12807
12808 .file "serpent-avx-x86_64-asm_64.S"
12809 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12810 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12811 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12812
12813 + pax_force_retaddr
12814 ret;
12815 ENDPROC(__serpent_enc_blk8_avx)
12816
12817 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12818 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12819 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12820
12821 + pax_force_retaddr
12822 ret;
12823 ENDPROC(__serpent_dec_blk8_avx)
12824
12825 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12826
12827 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12828
12829 + pax_force_retaddr
12830 ret;
12831 ENDPROC(serpent_ecb_enc_8way_avx)
12832
12833 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12834
12835 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12836
12837 + pax_force_retaddr
12838 ret;
12839 ENDPROC(serpent_ecb_dec_8way_avx)
12840
12841 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12842
12843 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12844
12845 + pax_force_retaddr
12846 ret;
12847 ENDPROC(serpent_cbc_dec_8way_avx)
12848
12849 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12850
12851 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12852
12853 + pax_force_retaddr
12854 ret;
12855 ENDPROC(serpent_ctr_8way_avx)
12856
12857 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12858 /* dst <= regs xor IVs(in dst) */
12859 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12860
12861 + pax_force_retaddr
12862 ret;
12863 ENDPROC(serpent_xts_enc_8way_avx)
12864
12865 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12866 /* dst <= regs xor IVs(in dst) */
12867 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12868
12869 + pax_force_retaddr
12870 ret;
12871 ENDPROC(serpent_xts_dec_8way_avx)
12872 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12873 index b222085..abd483c 100644
12874 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12875 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12876 @@ -15,6 +15,7 @@
12877 */
12878
12879 #include <linux/linkage.h>
12880 +#include <asm/alternative-asm.h>
12881 #include "glue_helper-asm-avx2.S"
12882
12883 .file "serpent-avx2-asm_64.S"
12884 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12885 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12886 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12887
12888 + pax_force_retaddr
12889 ret;
12890 ENDPROC(__serpent_enc_blk16)
12891
12892 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12893 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12894 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12895
12896 + pax_force_retaddr
12897 ret;
12898 ENDPROC(__serpent_dec_blk16)
12899
12900 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12901
12902 vzeroupper;
12903
12904 + pax_force_retaddr
12905 ret;
12906 ENDPROC(serpent_ecb_enc_16way)
12907
12908 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12909
12910 vzeroupper;
12911
12912 + pax_force_retaddr
12913 ret;
12914 ENDPROC(serpent_ecb_dec_16way)
12915
12916 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12917
12918 vzeroupper;
12919
12920 + pax_force_retaddr
12921 ret;
12922 ENDPROC(serpent_cbc_dec_16way)
12923
12924 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12925
12926 vzeroupper;
12927
12928 + pax_force_retaddr
12929 ret;
12930 ENDPROC(serpent_ctr_16way)
12931
12932 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12933
12934 vzeroupper;
12935
12936 + pax_force_retaddr
12937 ret;
12938 ENDPROC(serpent_xts_enc_16way)
12939
12940 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12941
12942 vzeroupper;
12943
12944 + pax_force_retaddr
12945 ret;
12946 ENDPROC(serpent_xts_dec_16way)
12947 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12948 index acc066c..1559cc4 100644
12949 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12950 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12951 @@ -25,6 +25,7 @@
12952 */
12953
12954 #include <linux/linkage.h>
12955 +#include <asm/alternative-asm.h>
12956
12957 .file "serpent-sse2-x86_64-asm_64.S"
12958 .text
12959 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12960 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12961 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12962
12963 + pax_force_retaddr
12964 ret;
12965
12966 .L__enc_xor8:
12967 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12968 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12969
12970 + pax_force_retaddr
12971 ret;
12972 ENDPROC(__serpent_enc_blk_8way)
12973
12974 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12975 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12976 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12977
12978 + pax_force_retaddr
12979 ret;
12980 ENDPROC(serpent_dec_blk_8way)
12981 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12982 index a410950..3356d42 100644
12983 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12984 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12985 @@ -29,6 +29,7 @@
12986 */
12987
12988 #include <linux/linkage.h>
12989 +#include <asm/alternative-asm.h>
12990
12991 #define CTX %rdi // arg1
12992 #define BUF %rsi // arg2
12993 @@ -104,6 +105,7 @@
12994 pop %r12
12995 pop %rbp
12996 pop %rbx
12997 + pax_force_retaddr 0, 1
12998 ret
12999
13000 ENDPROC(\name)
13001 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13002 index 642f156..4ab07b9 100644
13003 --- a/arch/x86/crypto/sha256-avx-asm.S
13004 +++ b/arch/x86/crypto/sha256-avx-asm.S
13005 @@ -49,6 +49,7 @@
13006
13007 #ifdef CONFIG_AS_AVX
13008 #include <linux/linkage.h>
13009 +#include <asm/alternative-asm.h>
13010
13011 ## assume buffers not aligned
13012 #define VMOVDQ vmovdqu
13013 @@ -460,6 +461,7 @@ done_hash:
13014 popq %r13
13015 popq %rbp
13016 popq %rbx
13017 + pax_force_retaddr 0, 1
13018 ret
13019 ENDPROC(sha256_transform_avx)
13020
13021 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13022 index 9e86944..2e7f95a 100644
13023 --- a/arch/x86/crypto/sha256-avx2-asm.S
13024 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13025 @@ -50,6 +50,7 @@
13026
13027 #ifdef CONFIG_AS_AVX2
13028 #include <linux/linkage.h>
13029 +#include <asm/alternative-asm.h>
13030
13031 ## assume buffers not aligned
13032 #define VMOVDQ vmovdqu
13033 @@ -720,6 +721,7 @@ done_hash:
13034 popq %r12
13035 popq %rbp
13036 popq %rbx
13037 + pax_force_retaddr 0, 1
13038 ret
13039 ENDPROC(sha256_transform_rorx)
13040
13041 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13042 index f833b74..c36ed14 100644
13043 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13044 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13045 @@ -47,6 +47,7 @@
13046 ########################################################################
13047
13048 #include <linux/linkage.h>
13049 +#include <asm/alternative-asm.h>
13050
13051 ## assume buffers not aligned
13052 #define MOVDQ movdqu
13053 @@ -471,6 +472,7 @@ done_hash:
13054 popq %rbp
13055 popq %rbx
13056
13057 + pax_force_retaddr 0, 1
13058 ret
13059 ENDPROC(sha256_transform_ssse3)
13060
13061 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13062 index 974dde9..4533d34 100644
13063 --- a/arch/x86/crypto/sha512-avx-asm.S
13064 +++ b/arch/x86/crypto/sha512-avx-asm.S
13065 @@ -49,6 +49,7 @@
13066
13067 #ifdef CONFIG_AS_AVX
13068 #include <linux/linkage.h>
13069 +#include <asm/alternative-asm.h>
13070
13071 .text
13072
13073 @@ -364,6 +365,7 @@ updateblock:
13074 mov frame_RSPSAVE(%rsp), %rsp
13075
13076 nowork:
13077 + pax_force_retaddr 0, 1
13078 ret
13079 ENDPROC(sha512_transform_avx)
13080
13081 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13082 index 568b961..061ef1d 100644
13083 --- a/arch/x86/crypto/sha512-avx2-asm.S
13084 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13085 @@ -51,6 +51,7 @@
13086
13087 #ifdef CONFIG_AS_AVX2
13088 #include <linux/linkage.h>
13089 +#include <asm/alternative-asm.h>
13090
13091 .text
13092
13093 @@ -678,6 +679,7 @@ done_hash:
13094
13095 # Restore Stack Pointer
13096 mov frame_RSPSAVE(%rsp), %rsp
13097 + pax_force_retaddr 0, 1
13098 ret
13099 ENDPROC(sha512_transform_rorx)
13100
13101 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13102 index fb56855..e23914f 100644
13103 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13104 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13105 @@ -48,6 +48,7 @@
13106 ########################################################################
13107
13108 #include <linux/linkage.h>
13109 +#include <asm/alternative-asm.h>
13110
13111 .text
13112
13113 @@ -363,6 +364,7 @@ updateblock:
13114 mov frame_RSPSAVE(%rsp), %rsp
13115
13116 nowork:
13117 + pax_force_retaddr 0, 1
13118 ret
13119 ENDPROC(sha512_transform_ssse3)
13120
13121 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13122 index 0505813..63b1d00 100644
13123 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13124 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13125 @@ -24,6 +24,7 @@
13126 */
13127
13128 #include <linux/linkage.h>
13129 +#include <asm/alternative-asm.h>
13130 #include "glue_helper-asm-avx.S"
13131
13132 .file "twofish-avx-x86_64-asm_64.S"
13133 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13134 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13135 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13136
13137 + pax_force_retaddr 0, 1
13138 ret;
13139 ENDPROC(__twofish_enc_blk8)
13140
13141 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13142 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13143 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13144
13145 + pax_force_retaddr 0, 1
13146 ret;
13147 ENDPROC(__twofish_dec_blk8)
13148
13149 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13150
13151 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13152
13153 + pax_force_retaddr 0, 1
13154 ret;
13155 ENDPROC(twofish_ecb_enc_8way)
13156
13157 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13158
13159 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13160
13161 + pax_force_retaddr 0, 1
13162 ret;
13163 ENDPROC(twofish_ecb_dec_8way)
13164
13165 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13166
13167 popq %r12;
13168
13169 + pax_force_retaddr 0, 1
13170 ret;
13171 ENDPROC(twofish_cbc_dec_8way)
13172
13173 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13174
13175 popq %r12;
13176
13177 + pax_force_retaddr 0, 1
13178 ret;
13179 ENDPROC(twofish_ctr_8way)
13180
13181 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13182 /* dst <= regs xor IVs(in dst) */
13183 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13184
13185 + pax_force_retaddr 0, 1
13186 ret;
13187 ENDPROC(twofish_xts_enc_8way)
13188
13189 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13190 /* dst <= regs xor IVs(in dst) */
13191 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13192
13193 + pax_force_retaddr 0, 1
13194 ret;
13195 ENDPROC(twofish_xts_dec_8way)
13196 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13197 index 1c3b7ce..b365c5e 100644
13198 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13199 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13200 @@ -21,6 +21,7 @@
13201 */
13202
13203 #include <linux/linkage.h>
13204 +#include <asm/alternative-asm.h>
13205
13206 .file "twofish-x86_64-asm-3way.S"
13207 .text
13208 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13209 popq %r13;
13210 popq %r14;
13211 popq %r15;
13212 + pax_force_retaddr 0, 1
13213 ret;
13214
13215 .L__enc_xor3:
13216 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13217 popq %r13;
13218 popq %r14;
13219 popq %r15;
13220 + pax_force_retaddr 0, 1
13221 ret;
13222 ENDPROC(__twofish_enc_blk_3way)
13223
13224 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13225 popq %r13;
13226 popq %r14;
13227 popq %r15;
13228 + pax_force_retaddr 0, 1
13229 ret;
13230 ENDPROC(twofish_dec_blk_3way)
13231 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13232 index a039d21..29e7615 100644
13233 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13234 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13235 @@ -22,6 +22,7 @@
13236
13237 #include <linux/linkage.h>
13238 #include <asm/asm-offsets.h>
13239 +#include <asm/alternative-asm.h>
13240
13241 #define a_offset 0
13242 #define b_offset 4
13243 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13244
13245 popq R1
13246 movq $1,%rax
13247 + pax_force_retaddr 0, 1
13248 ret
13249 ENDPROC(twofish_enc_blk)
13250
13251 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13252
13253 popq R1
13254 movq $1,%rax
13255 + pax_force_retaddr 0, 1
13256 ret
13257 ENDPROC(twofish_dec_blk)
13258 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13259 index bae3aba..c1788c1 100644
13260 --- a/arch/x86/ia32/ia32_aout.c
13261 +++ b/arch/x86/ia32/ia32_aout.c
13262 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13263 unsigned long dump_start, dump_size;
13264 struct user32 dump;
13265
13266 + memset(&dump, 0, sizeof(dump));
13267 +
13268 fs = get_fs();
13269 set_fs(KERNEL_DS);
13270 has_dumped = 1;
13271 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13272 index 665a730..8e7a67a 100644
13273 --- a/arch/x86/ia32/ia32_signal.c
13274 +++ b/arch/x86/ia32/ia32_signal.c
13275 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13276 sp -= frame_size;
13277 /* Align the stack pointer according to the i386 ABI,
13278 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13279 - sp = ((sp + 4) & -16ul) - 4;
13280 + sp = ((sp - 12) & -16ul) - 4;
13281 return (void __user *) sp;
13282 }
13283
13284 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13285 * These are actually not used anymore, but left because some
13286 * gdb versions depend on them as a marker.
13287 */
13288 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13289 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13290 } put_user_catch(err);
13291
13292 if (err)
13293 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13294 0xb8,
13295 __NR_ia32_rt_sigreturn,
13296 0x80cd,
13297 - 0,
13298 + 0
13299 };
13300
13301 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13302 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13303
13304 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13305 restorer = ksig->ka.sa.sa_restorer;
13306 + else if (current->mm->context.vdso)
13307 + /* Return stub is in 32bit vsyscall page */
13308 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13309 else
13310 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13311 - rt_sigreturn);
13312 + restorer = &frame->retcode;
13313 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13314
13315 /*
13316 * Not actually used anymore, but left because some gdb
13317 * versions need it.
13318 */
13319 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13320 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13321 } put_user_catch(err);
13322
13323 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13324 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13325 index 4299eb0..904b82a 100644
13326 --- a/arch/x86/ia32/ia32entry.S
13327 +++ b/arch/x86/ia32/ia32entry.S
13328 @@ -15,8 +15,10 @@
13329 #include <asm/irqflags.h>
13330 #include <asm/asm.h>
13331 #include <asm/smap.h>
13332 +#include <asm/pgtable.h>
13333 #include <linux/linkage.h>
13334 #include <linux/err.h>
13335 +#include <asm/alternative-asm.h>
13336
13337 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13338 #include <linux/elf-em.h>
13339 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13340 ENDPROC(native_irq_enable_sysexit)
13341 #endif
13342
13343 + .macro pax_enter_kernel_user
13344 + pax_set_fptr_mask
13345 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13346 + call pax_enter_kernel_user
13347 +#endif
13348 + .endm
13349 +
13350 + .macro pax_exit_kernel_user
13351 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13352 + call pax_exit_kernel_user
13353 +#endif
13354 +#ifdef CONFIG_PAX_RANDKSTACK
13355 + pushq %rax
13356 + pushq %r11
13357 + call pax_randomize_kstack
13358 + popq %r11
13359 + popq %rax
13360 +#endif
13361 + .endm
13362 +
13363 + .macro pax_erase_kstack
13364 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13365 + call pax_erase_kstack
13366 +#endif
13367 + .endm
13368 +
13369 /*
13370 * 32bit SYSENTER instruction entry.
13371 *
13372 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13373 CFI_REGISTER rsp,rbp
13374 SWAPGS_UNSAFE_STACK
13375 movq PER_CPU_VAR(kernel_stack), %rsp
13376 - addq $(KERNEL_STACK_OFFSET),%rsp
13377 - /*
13378 - * No need to follow this irqs on/off section: the syscall
13379 - * disabled irqs, here we enable it straight after entry:
13380 - */
13381 - ENABLE_INTERRUPTS(CLBR_NONE)
13382 movl %ebp,%ebp /* zero extension */
13383 pushq_cfi $__USER32_DS
13384 /*CFI_REL_OFFSET ss,0*/
13385 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13386 CFI_REL_OFFSET rsp,0
13387 pushfq_cfi
13388 /*CFI_REL_OFFSET rflags,0*/
13389 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13390 - CFI_REGISTER rip,r10
13391 + orl $X86_EFLAGS_IF,(%rsp)
13392 + GET_THREAD_INFO(%r11)
13393 + movl TI_sysenter_return(%r11), %r11d
13394 + CFI_REGISTER rip,r11
13395 pushq_cfi $__USER32_CS
13396 /*CFI_REL_OFFSET cs,0*/
13397 movl %eax, %eax
13398 - pushq_cfi %r10
13399 + pushq_cfi %r11
13400 CFI_REL_OFFSET rip,0
13401 pushq_cfi %rax
13402 cld
13403 SAVE_ARGS 0,1,0
13404 + pax_enter_kernel_user
13405 +
13406 +#ifdef CONFIG_PAX_RANDKSTACK
13407 + pax_erase_kstack
13408 +#endif
13409 +
13410 + /*
13411 + * No need to follow this irqs on/off section: the syscall
13412 + * disabled irqs, here we enable it straight after entry:
13413 + */
13414 + ENABLE_INTERRUPTS(CLBR_NONE)
13415 /* no need to do an access_ok check here because rbp has been
13416 32bit zero extended */
13417 +
13418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13419 + addq pax_user_shadow_base,%rbp
13420 + ASM_PAX_OPEN_USERLAND
13421 +#endif
13422 +
13423 ASM_STAC
13424 1: movl (%rbp),%ebp
13425 _ASM_EXTABLE(1b,ia32_badarg)
13426 ASM_CLAC
13427 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13428 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13429 +
13430 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13431 + ASM_PAX_CLOSE_USERLAND
13432 +#endif
13433 +
13434 + GET_THREAD_INFO(%r11)
13435 + orl $TS_COMPAT,TI_status(%r11)
13436 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13437 CFI_REMEMBER_STATE
13438 jnz sysenter_tracesys
13439 cmpq $(IA32_NR_syscalls-1),%rax
13440 @@ -162,12 +209,15 @@ sysenter_do_call:
13441 sysenter_dispatch:
13442 call *ia32_sys_call_table(,%rax,8)
13443 movq %rax,RAX-ARGOFFSET(%rsp)
13444 + GET_THREAD_INFO(%r11)
13445 DISABLE_INTERRUPTS(CLBR_NONE)
13446 TRACE_IRQS_OFF
13447 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13449 jnz sysexit_audit
13450 sysexit_from_sys_call:
13451 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13452 + pax_exit_kernel_user
13453 + pax_erase_kstack
13454 + andl $~TS_COMPAT,TI_status(%r11)
13455 /* clear IF, that popfq doesn't enable interrupts early */
13456 andl $~0x200,EFLAGS-R11(%rsp)
13457 movl RIP-R11(%rsp),%edx /* User %eip */
13458 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13459 movl %eax,%esi /* 2nd arg: syscall number */
13460 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13461 call __audit_syscall_entry
13462 +
13463 + pax_erase_kstack
13464 +
13465 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13466 cmpq $(IA32_NR_syscalls-1),%rax
13467 ja ia32_badsys
13468 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13469 .endm
13470
13471 .macro auditsys_exit exit
13472 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13473 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13474 jnz ia32_ret_from_sys_call
13475 TRACE_IRQS_ON
13476 ENABLE_INTERRUPTS(CLBR_NONE)
13477 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13478 1: setbe %al /* 1 if error, 0 if not */
13479 movzbl %al,%edi /* zero-extend that into %edi */
13480 call __audit_syscall_exit
13481 + GET_THREAD_INFO(%r11)
13482 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13483 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13484 DISABLE_INTERRUPTS(CLBR_NONE)
13485 TRACE_IRQS_OFF
13486 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13487 + testl %edi,TI_flags(%r11)
13488 jz \exit
13489 CLEAR_RREGS -ARGOFFSET
13490 jmp int_with_check
13491 @@ -237,7 +291,7 @@ sysexit_audit:
13492
13493 sysenter_tracesys:
13494 #ifdef CONFIG_AUDITSYSCALL
13495 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13496 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13497 jz sysenter_auditsys
13498 #endif
13499 SAVE_REST
13500 @@ -249,6 +303,9 @@ sysenter_tracesys:
13501 RESTORE_REST
13502 cmpq $(IA32_NR_syscalls-1),%rax
13503 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13504 +
13505 + pax_erase_kstack
13506 +
13507 jmp sysenter_do_call
13508 CFI_ENDPROC
13509 ENDPROC(ia32_sysenter_target)
13510 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13511 ENTRY(ia32_cstar_target)
13512 CFI_STARTPROC32 simple
13513 CFI_SIGNAL_FRAME
13514 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13515 + CFI_DEF_CFA rsp,0
13516 CFI_REGISTER rip,rcx
13517 /*CFI_REGISTER rflags,r11*/
13518 SWAPGS_UNSAFE_STACK
13519 movl %esp,%r8d
13520 CFI_REGISTER rsp,r8
13521 movq PER_CPU_VAR(kernel_stack),%rsp
13522 + SAVE_ARGS 8*6,0,0
13523 + pax_enter_kernel_user
13524 +
13525 +#ifdef CONFIG_PAX_RANDKSTACK
13526 + pax_erase_kstack
13527 +#endif
13528 +
13529 /*
13530 * No need to follow this irqs on/off section: the syscall
13531 * disabled irqs and here we enable it straight after entry:
13532 */
13533 ENABLE_INTERRUPTS(CLBR_NONE)
13534 - SAVE_ARGS 8,0,0
13535 movl %eax,%eax /* zero extension */
13536 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13537 movq %rcx,RIP-ARGOFFSET(%rsp)
13538 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13539 /* no need to do an access_ok check here because r8 has been
13540 32bit zero extended */
13541 /* hardware stack frame is complete now */
13542 +
13543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13544 + ASM_PAX_OPEN_USERLAND
13545 + movq pax_user_shadow_base,%r8
13546 + addq RSP-ARGOFFSET(%rsp),%r8
13547 +#endif
13548 +
13549 ASM_STAC
13550 1: movl (%r8),%r9d
13551 _ASM_EXTABLE(1b,ia32_badarg)
13552 ASM_CLAC
13553 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13554 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13555 +
13556 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13557 + ASM_PAX_CLOSE_USERLAND
13558 +#endif
13559 +
13560 + GET_THREAD_INFO(%r11)
13561 + orl $TS_COMPAT,TI_status(%r11)
13562 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13563 CFI_REMEMBER_STATE
13564 jnz cstar_tracesys
13565 cmpq $IA32_NR_syscalls-1,%rax
13566 @@ -319,12 +395,15 @@ cstar_do_call:
13567 cstar_dispatch:
13568 call *ia32_sys_call_table(,%rax,8)
13569 movq %rax,RAX-ARGOFFSET(%rsp)
13570 + GET_THREAD_INFO(%r11)
13571 DISABLE_INTERRUPTS(CLBR_NONE)
13572 TRACE_IRQS_OFF
13573 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13574 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13575 jnz sysretl_audit
13576 sysretl_from_sys_call:
13577 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13578 + pax_exit_kernel_user
13579 + pax_erase_kstack
13580 + andl $~TS_COMPAT,TI_status(%r11)
13581 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13582 movl RIP-ARGOFFSET(%rsp),%ecx
13583 CFI_REGISTER rip,rcx
13584 @@ -352,7 +431,7 @@ sysretl_audit:
13585
13586 cstar_tracesys:
13587 #ifdef CONFIG_AUDITSYSCALL
13588 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13589 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13590 jz cstar_auditsys
13591 #endif
13592 xchgl %r9d,%ebp
13593 @@ -366,11 +445,19 @@ cstar_tracesys:
13594 xchgl %ebp,%r9d
13595 cmpq $(IA32_NR_syscalls-1),%rax
13596 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13597 +
13598 + pax_erase_kstack
13599 +
13600 jmp cstar_do_call
13601 END(ia32_cstar_target)
13602
13603 ia32_badarg:
13604 ASM_CLAC
13605 +
13606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13607 + ASM_PAX_CLOSE_USERLAND
13608 +#endif
13609 +
13610 movq $-EFAULT,%rax
13611 jmp ia32_sysret
13612 CFI_ENDPROC
13613 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13614 CFI_REL_OFFSET rip,RIP-RIP
13615 PARAVIRT_ADJUST_EXCEPTION_FRAME
13616 SWAPGS
13617 - /*
13618 - * No need to follow this irqs on/off section: the syscall
13619 - * disabled irqs and here we enable it straight after entry:
13620 - */
13621 - ENABLE_INTERRUPTS(CLBR_NONE)
13622 movl %eax,%eax
13623 pushq_cfi %rax
13624 cld
13625 /* note the registers are not zero extended to the sf.
13626 this could be a problem. */
13627 SAVE_ARGS 0,1,0
13628 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13629 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13630 + pax_enter_kernel_user
13631 +
13632 +#ifdef CONFIG_PAX_RANDKSTACK
13633 + pax_erase_kstack
13634 +#endif
13635 +
13636 + /*
13637 + * No need to follow this irqs on/off section: the syscall
13638 + * disabled irqs and here we enable it straight after entry:
13639 + */
13640 + ENABLE_INTERRUPTS(CLBR_NONE)
13641 + GET_THREAD_INFO(%r11)
13642 + orl $TS_COMPAT,TI_status(%r11)
13643 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13644 jnz ia32_tracesys
13645 cmpq $(IA32_NR_syscalls-1),%rax
13646 ja ia32_badsys
13647 @@ -442,6 +536,9 @@ ia32_tracesys:
13648 RESTORE_REST
13649 cmpq $(IA32_NR_syscalls-1),%rax
13650 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13651 +
13652 + pax_erase_kstack
13653 +
13654 jmp ia32_do_call
13655 END(ia32_syscall)
13656
13657 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13658 index 8e0ceec..af13504 100644
13659 --- a/arch/x86/ia32/sys_ia32.c
13660 +++ b/arch/x86/ia32/sys_ia32.c
13661 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13662 */
13663 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13664 {
13665 - typeof(ubuf->st_uid) uid = 0;
13666 - typeof(ubuf->st_gid) gid = 0;
13667 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13668 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13669 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13670 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13671 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13672 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13673 index 372231c..a5aa1a1 100644
13674 --- a/arch/x86/include/asm/alternative-asm.h
13675 +++ b/arch/x86/include/asm/alternative-asm.h
13676 @@ -18,6 +18,45 @@
13677 .endm
13678 #endif
13679
13680 +#ifdef KERNEXEC_PLUGIN
13681 + .macro pax_force_retaddr_bts rip=0
13682 + btsq $63,\rip(%rsp)
13683 + .endm
13684 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13685 + .macro pax_force_retaddr rip=0, reload=0
13686 + btsq $63,\rip(%rsp)
13687 + .endm
13688 + .macro pax_force_fptr ptr
13689 + btsq $63,\ptr
13690 + .endm
13691 + .macro pax_set_fptr_mask
13692 + .endm
13693 +#endif
13694 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13695 + .macro pax_force_retaddr rip=0, reload=0
13696 + .if \reload
13697 + pax_set_fptr_mask
13698 + .endif
13699 + orq %r10,\rip(%rsp)
13700 + .endm
13701 + .macro pax_force_fptr ptr
13702 + orq %r10,\ptr
13703 + .endm
13704 + .macro pax_set_fptr_mask
13705 + movabs $0x8000000000000000,%r10
13706 + .endm
13707 +#endif
13708 +#else
13709 + .macro pax_force_retaddr rip=0, reload=0
13710 + .endm
13711 + .macro pax_force_fptr ptr
13712 + .endm
13713 + .macro pax_force_retaddr_bts rip=0
13714 + .endm
13715 + .macro pax_set_fptr_mask
13716 + .endm
13717 +#endif
13718 +
13719 .macro altinstruction_entry orig alt feature orig_len alt_len
13720 .long \orig - .
13721 .long \alt - .
13722 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13723 index 0a3f9c9..c9d081d 100644
13724 --- a/arch/x86/include/asm/alternative.h
13725 +++ b/arch/x86/include/asm/alternative.h
13726 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13727 ".pushsection .discard,\"aw\",@progbits\n" \
13728 DISCARD_ENTRY(1) \
13729 ".popsection\n" \
13730 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13731 + ".pushsection .altinstr_replacement, \"a\"\n" \
13732 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13733 ".popsection"
13734
13735 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13736 DISCARD_ENTRY(1) \
13737 DISCARD_ENTRY(2) \
13738 ".popsection\n" \
13739 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13740 + ".pushsection .altinstr_replacement, \"a\"\n" \
13741 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13742 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13743 ".popsection"
13744 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13745 index 1d2091a..f5074c1 100644
13746 --- a/arch/x86/include/asm/apic.h
13747 +++ b/arch/x86/include/asm/apic.h
13748 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13749
13750 #ifdef CONFIG_X86_LOCAL_APIC
13751
13752 -extern unsigned int apic_verbosity;
13753 +extern int apic_verbosity;
13754 extern int local_apic_timer_c2_ok;
13755
13756 extern int disable_apic;
13757 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13758 index 20370c6..a2eb9b0 100644
13759 --- a/arch/x86/include/asm/apm.h
13760 +++ b/arch/x86/include/asm/apm.h
13761 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13762 __asm__ __volatile__(APM_DO_ZERO_SEGS
13763 "pushl %%edi\n\t"
13764 "pushl %%ebp\n\t"
13765 - "lcall *%%cs:apm_bios_entry\n\t"
13766 + "lcall *%%ss:apm_bios_entry\n\t"
13767 "setc %%al\n\t"
13768 "popl %%ebp\n\t"
13769 "popl %%edi\n\t"
13770 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13771 __asm__ __volatile__(APM_DO_ZERO_SEGS
13772 "pushl %%edi\n\t"
13773 "pushl %%ebp\n\t"
13774 - "lcall *%%cs:apm_bios_entry\n\t"
13775 + "lcall *%%ss:apm_bios_entry\n\t"
13776 "setc %%bl\n\t"
13777 "popl %%ebp\n\t"
13778 "popl %%edi\n\t"
13779 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13780 index 722aa3b..3a0bb27 100644
13781 --- a/arch/x86/include/asm/atomic.h
13782 +++ b/arch/x86/include/asm/atomic.h
13783 @@ -22,7 +22,18 @@
13784 */
13785 static inline int atomic_read(const atomic_t *v)
13786 {
13787 - return (*(volatile int *)&(v)->counter);
13788 + return (*(volatile const int *)&(v)->counter);
13789 +}
13790 +
13791 +/**
13792 + * atomic_read_unchecked - read atomic variable
13793 + * @v: pointer of type atomic_unchecked_t
13794 + *
13795 + * Atomically reads the value of @v.
13796 + */
13797 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13798 +{
13799 + return (*(volatile const int *)&(v)->counter);
13800 }
13801
13802 /**
13803 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13804 }
13805
13806 /**
13807 + * atomic_set_unchecked - set atomic variable
13808 + * @v: pointer of type atomic_unchecked_t
13809 + * @i: required value
13810 + *
13811 + * Atomically sets the value of @v to @i.
13812 + */
13813 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13814 +{
13815 + v->counter = i;
13816 +}
13817 +
13818 +/**
13819 * atomic_add - add integer to atomic variable
13820 * @i: integer value to add
13821 * @v: pointer of type atomic_t
13822 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13823 */
13824 static inline void atomic_add(int i, atomic_t *v)
13825 {
13826 - asm volatile(LOCK_PREFIX "addl %1,%0"
13827 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13828 +
13829 +#ifdef CONFIG_PAX_REFCOUNT
13830 + "jno 0f\n"
13831 + LOCK_PREFIX "subl %1,%0\n"
13832 + "int $4\n0:\n"
13833 + _ASM_EXTABLE(0b, 0b)
13834 +#endif
13835 +
13836 + : "+m" (v->counter)
13837 + : "ir" (i));
13838 +}
13839 +
13840 +/**
13841 + * atomic_add_unchecked - add integer to atomic variable
13842 + * @i: integer value to add
13843 + * @v: pointer of type atomic_unchecked_t
13844 + *
13845 + * Atomically adds @i to @v.
13846 + */
13847 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13848 +{
13849 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13850 : "+m" (v->counter)
13851 : "ir" (i));
13852 }
13853 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13854 */
13855 static inline void atomic_sub(int i, atomic_t *v)
13856 {
13857 - asm volatile(LOCK_PREFIX "subl %1,%0"
13858 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13859 +
13860 +#ifdef CONFIG_PAX_REFCOUNT
13861 + "jno 0f\n"
13862 + LOCK_PREFIX "addl %1,%0\n"
13863 + "int $4\n0:\n"
13864 + _ASM_EXTABLE(0b, 0b)
13865 +#endif
13866 +
13867 + : "+m" (v->counter)
13868 + : "ir" (i));
13869 +}
13870 +
13871 +/**
13872 + * atomic_sub_unchecked - subtract integer from atomic variable
13873 + * @i: integer value to subtract
13874 + * @v: pointer of type atomic_unchecked_t
13875 + *
13876 + * Atomically subtracts @i from @v.
13877 + */
13878 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13879 +{
13880 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13881 : "+m" (v->counter)
13882 : "ir" (i));
13883 }
13884 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13885 {
13886 unsigned char c;
13887
13888 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13889 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13890 +
13891 +#ifdef CONFIG_PAX_REFCOUNT
13892 + "jno 0f\n"
13893 + LOCK_PREFIX "addl %2,%0\n"
13894 + "int $4\n0:\n"
13895 + _ASM_EXTABLE(0b, 0b)
13896 +#endif
13897 +
13898 + "sete %1\n"
13899 : "+m" (v->counter), "=qm" (c)
13900 : "ir" (i) : "memory");
13901 return c;
13902 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13903 */
13904 static inline void atomic_inc(atomic_t *v)
13905 {
13906 - asm volatile(LOCK_PREFIX "incl %0"
13907 + asm volatile(LOCK_PREFIX "incl %0\n"
13908 +
13909 +#ifdef CONFIG_PAX_REFCOUNT
13910 + "jno 0f\n"
13911 + LOCK_PREFIX "decl %0\n"
13912 + "int $4\n0:\n"
13913 + _ASM_EXTABLE(0b, 0b)
13914 +#endif
13915 +
13916 + : "+m" (v->counter));
13917 +}
13918 +
13919 +/**
13920 + * atomic_inc_unchecked - increment atomic variable
13921 + * @v: pointer of type atomic_unchecked_t
13922 + *
13923 + * Atomically increments @v by 1.
13924 + */
13925 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13926 +{
13927 + asm volatile(LOCK_PREFIX "incl %0\n"
13928 : "+m" (v->counter));
13929 }
13930
13931 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13932 */
13933 static inline void atomic_dec(atomic_t *v)
13934 {
13935 - asm volatile(LOCK_PREFIX "decl %0"
13936 + asm volatile(LOCK_PREFIX "decl %0\n"
13937 +
13938 +#ifdef CONFIG_PAX_REFCOUNT
13939 + "jno 0f\n"
13940 + LOCK_PREFIX "incl %0\n"
13941 + "int $4\n0:\n"
13942 + _ASM_EXTABLE(0b, 0b)
13943 +#endif
13944 +
13945 + : "+m" (v->counter));
13946 +}
13947 +
13948 +/**
13949 + * atomic_dec_unchecked - decrement atomic variable
13950 + * @v: pointer of type atomic_unchecked_t
13951 + *
13952 + * Atomically decrements @v by 1.
13953 + */
13954 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13955 +{
13956 + asm volatile(LOCK_PREFIX "decl %0\n"
13957 : "+m" (v->counter));
13958 }
13959
13960 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13961 {
13962 unsigned char c;
13963
13964 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13965 + asm volatile(LOCK_PREFIX "decl %0\n"
13966 +
13967 +#ifdef CONFIG_PAX_REFCOUNT
13968 + "jno 0f\n"
13969 + LOCK_PREFIX "incl %0\n"
13970 + "int $4\n0:\n"
13971 + _ASM_EXTABLE(0b, 0b)
13972 +#endif
13973 +
13974 + "sete %1\n"
13975 : "+m" (v->counter), "=qm" (c)
13976 : : "memory");
13977 return c != 0;
13978 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13979 {
13980 unsigned char c;
13981
13982 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13983 + asm volatile(LOCK_PREFIX "incl %0\n"
13984 +
13985 +#ifdef CONFIG_PAX_REFCOUNT
13986 + "jno 0f\n"
13987 + LOCK_PREFIX "decl %0\n"
13988 + "int $4\n0:\n"
13989 + _ASM_EXTABLE(0b, 0b)
13990 +#endif
13991 +
13992 + "sete %1\n"
13993 + : "+m" (v->counter), "=qm" (c)
13994 + : : "memory");
13995 + return c != 0;
13996 +}
13997 +
13998 +/**
13999 + * atomic_inc_and_test_unchecked - increment and test
14000 + * @v: pointer of type atomic_unchecked_t
14001 + *
14002 + * Atomically increments @v by 1
14003 + * and returns true if the result is zero, or false for all
14004 + * other cases.
14005 + */
14006 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14007 +{
14008 + unsigned char c;
14009 +
14010 + asm volatile(LOCK_PREFIX "incl %0\n"
14011 + "sete %1\n"
14012 : "+m" (v->counter), "=qm" (c)
14013 : : "memory");
14014 return c != 0;
14015 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14016 {
14017 unsigned char c;
14018
14019 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14020 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14021 +
14022 +#ifdef CONFIG_PAX_REFCOUNT
14023 + "jno 0f\n"
14024 + LOCK_PREFIX "subl %2,%0\n"
14025 + "int $4\n0:\n"
14026 + _ASM_EXTABLE(0b, 0b)
14027 +#endif
14028 +
14029 + "sets %1\n"
14030 : "+m" (v->counter), "=qm" (c)
14031 : "ir" (i) : "memory");
14032 return c;
14033 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14034 */
14035 static inline int atomic_add_return(int i, atomic_t *v)
14036 {
14037 + return i + xadd_check_overflow(&v->counter, i);
14038 +}
14039 +
14040 +/**
14041 + * atomic_add_return_unchecked - add integer and return
14042 + * @i: integer value to add
14043 + * @v: pointer of type atomic_unchecked_t
14044 + *
14045 + * Atomically adds @i to @v and returns @i + @v
14046 + */
14047 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14048 +{
14049 return i + xadd(&v->counter, i);
14050 }
14051
14052 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14053 }
14054
14055 #define atomic_inc_return(v) (atomic_add_return(1, v))
14056 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14057 +{
14058 + return atomic_add_return_unchecked(1, v);
14059 +}
14060 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14061
14062 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14063 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14064 return cmpxchg(&v->counter, old, new);
14065 }
14066
14067 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14068 +{
14069 + return cmpxchg(&v->counter, old, new);
14070 +}
14071 +
14072 static inline int atomic_xchg(atomic_t *v, int new)
14073 {
14074 return xchg(&v->counter, new);
14075 }
14076
14077 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14078 +{
14079 + return xchg(&v->counter, new);
14080 +}
14081 +
14082 /**
14083 * __atomic_add_unless - add unless the number is already a given value
14084 * @v: pointer of type atomic_t
14085 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14086 */
14087 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14088 {
14089 - int c, old;
14090 + int c, old, new;
14091 c = atomic_read(v);
14092 for (;;) {
14093 - if (unlikely(c == (u)))
14094 + if (unlikely(c == u))
14095 break;
14096 - old = atomic_cmpxchg((v), c, c + (a));
14097 +
14098 + asm volatile("addl %2,%0\n"
14099 +
14100 +#ifdef CONFIG_PAX_REFCOUNT
14101 + "jno 0f\n"
14102 + "subl %2,%0\n"
14103 + "int $4\n0:\n"
14104 + _ASM_EXTABLE(0b, 0b)
14105 +#endif
14106 +
14107 + : "=r" (new)
14108 + : "0" (c), "ir" (a));
14109 +
14110 + old = atomic_cmpxchg(v, c, new);
14111 if (likely(old == c))
14112 break;
14113 c = old;
14114 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14115 }
14116
14117 /**
14118 + * atomic_inc_not_zero_hint - increment if not null
14119 + * @v: pointer of type atomic_t
14120 + * @hint: probable value of the atomic before the increment
14121 + *
14122 + * This version of atomic_inc_not_zero() gives a hint of probable
14123 + * value of the atomic. This helps processor to not read the memory
14124 + * before doing the atomic read/modify/write cycle, lowering
14125 + * number of bus transactions on some arches.
14126 + *
14127 + * Returns: 0 if increment was not done, 1 otherwise.
14128 + */
14129 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14130 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14131 +{
14132 + int val, c = hint, new;
14133 +
14134 + /* sanity test, should be removed by compiler if hint is a constant */
14135 + if (!hint)
14136 + return __atomic_add_unless(v, 1, 0);
14137 +
14138 + do {
14139 + asm volatile("incl %0\n"
14140 +
14141 +#ifdef CONFIG_PAX_REFCOUNT
14142 + "jno 0f\n"
14143 + "decl %0\n"
14144 + "int $4\n0:\n"
14145 + _ASM_EXTABLE(0b, 0b)
14146 +#endif
14147 +
14148 + : "=r" (new)
14149 + : "0" (c));
14150 +
14151 + val = atomic_cmpxchg(v, c, new);
14152 + if (val == c)
14153 + return 1;
14154 + c = val;
14155 + } while (c);
14156 +
14157 + return 0;
14158 +}
14159 +
14160 +/**
14161 * atomic_inc_short - increment of a short integer
14162 * @v: pointer to type int
14163 *
14164 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14165 #endif
14166
14167 /* These are x86-specific, used by some header files */
14168 -#define atomic_clear_mask(mask, addr) \
14169 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14170 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14171 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14172 +{
14173 + asm volatile(LOCK_PREFIX "andl %1,%0"
14174 + : "+m" (v->counter)
14175 + : "r" (~(mask))
14176 + : "memory");
14177 +}
14178
14179 -#define atomic_set_mask(mask, addr) \
14180 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14181 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14182 - : "memory")
14183 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14184 +{
14185 + asm volatile(LOCK_PREFIX "andl %1,%0"
14186 + : "+m" (v->counter)
14187 + : "r" (~(mask))
14188 + : "memory");
14189 +}
14190 +
14191 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14192 +{
14193 + asm volatile(LOCK_PREFIX "orl %1,%0"
14194 + : "+m" (v->counter)
14195 + : "r" (mask)
14196 + : "memory");
14197 +}
14198 +
14199 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14200 +{
14201 + asm volatile(LOCK_PREFIX "orl %1,%0"
14202 + : "+m" (v->counter)
14203 + : "r" (mask)
14204 + : "memory");
14205 +}
14206
14207 /* Atomic operations are already serializing on x86 */
14208 #define smp_mb__before_atomic_dec() barrier()
14209 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14210 index b154de7..aadebd8 100644
14211 --- a/arch/x86/include/asm/atomic64_32.h
14212 +++ b/arch/x86/include/asm/atomic64_32.h
14213 @@ -12,6 +12,14 @@ typedef struct {
14214 u64 __aligned(8) counter;
14215 } atomic64_t;
14216
14217 +#ifdef CONFIG_PAX_REFCOUNT
14218 +typedef struct {
14219 + u64 __aligned(8) counter;
14220 +} atomic64_unchecked_t;
14221 +#else
14222 +typedef atomic64_t atomic64_unchecked_t;
14223 +#endif
14224 +
14225 #define ATOMIC64_INIT(val) { (val) }
14226
14227 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14228 @@ -37,21 +45,31 @@ typedef struct {
14229 ATOMIC64_DECL_ONE(sym##_386)
14230
14231 ATOMIC64_DECL_ONE(add_386);
14232 +ATOMIC64_DECL_ONE(add_unchecked_386);
14233 ATOMIC64_DECL_ONE(sub_386);
14234 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14235 ATOMIC64_DECL_ONE(inc_386);
14236 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14237 ATOMIC64_DECL_ONE(dec_386);
14238 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14239 #endif
14240
14241 #define alternative_atomic64(f, out, in...) \
14242 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14243
14244 ATOMIC64_DECL(read);
14245 +ATOMIC64_DECL(read_unchecked);
14246 ATOMIC64_DECL(set);
14247 +ATOMIC64_DECL(set_unchecked);
14248 ATOMIC64_DECL(xchg);
14249 ATOMIC64_DECL(add_return);
14250 +ATOMIC64_DECL(add_return_unchecked);
14251 ATOMIC64_DECL(sub_return);
14252 +ATOMIC64_DECL(sub_return_unchecked);
14253 ATOMIC64_DECL(inc_return);
14254 +ATOMIC64_DECL(inc_return_unchecked);
14255 ATOMIC64_DECL(dec_return);
14256 +ATOMIC64_DECL(dec_return_unchecked);
14257 ATOMIC64_DECL(dec_if_positive);
14258 ATOMIC64_DECL(inc_not_zero);
14259 ATOMIC64_DECL(add_unless);
14260 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14261 }
14262
14263 /**
14264 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14265 + * @p: pointer to type atomic64_unchecked_t
14266 + * @o: expected value
14267 + * @n: new value
14268 + *
14269 + * Atomically sets @v to @n if it was equal to @o and returns
14270 + * the old value.
14271 + */
14272 +
14273 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14274 +{
14275 + return cmpxchg64(&v->counter, o, n);
14276 +}
14277 +
14278 +/**
14279 * atomic64_xchg - xchg atomic64 variable
14280 * @v: pointer to type atomic64_t
14281 * @n: value to assign
14282 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14283 }
14284
14285 /**
14286 + * atomic64_set_unchecked - set atomic64 variable
14287 + * @v: pointer to type atomic64_unchecked_t
14288 + * @n: value to assign
14289 + *
14290 + * Atomically sets the value of @v to @n.
14291 + */
14292 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14293 +{
14294 + unsigned high = (unsigned)(i >> 32);
14295 + unsigned low = (unsigned)i;
14296 + alternative_atomic64(set, /* no output */,
14297 + "S" (v), "b" (low), "c" (high)
14298 + : "eax", "edx", "memory");
14299 +}
14300 +
14301 +/**
14302 * atomic64_read - read atomic64 variable
14303 * @v: pointer to type atomic64_t
14304 *
14305 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14306 }
14307
14308 /**
14309 + * atomic64_read_unchecked - read atomic64 variable
14310 + * @v: pointer to type atomic64_unchecked_t
14311 + *
14312 + * Atomically reads the value of @v and returns it.
14313 + */
14314 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14315 +{
14316 + long long r;
14317 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14318 + return r;
14319 + }
14320 +
14321 +/**
14322 * atomic64_add_return - add and return
14323 * @i: integer value to add
14324 * @v: pointer to type atomic64_t
14325 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14326 return i;
14327 }
14328
14329 +/**
14330 + * atomic64_add_return_unchecked - add and return
14331 + * @i: integer value to add
14332 + * @v: pointer to type atomic64_unchecked_t
14333 + *
14334 + * Atomically adds @i to @v and returns @i + *@v
14335 + */
14336 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14337 +{
14338 + alternative_atomic64(add_return_unchecked,
14339 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14340 + ASM_NO_INPUT_CLOBBER("memory"));
14341 + return i;
14342 +}
14343 +
14344 /*
14345 * Other variants with different arithmetic operators:
14346 */
14347 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14348 return a;
14349 }
14350
14351 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14352 +{
14353 + long long a;
14354 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14355 + "S" (v) : "memory", "ecx");
14356 + return a;
14357 +}
14358 +
14359 static inline long long atomic64_dec_return(atomic64_t *v)
14360 {
14361 long long a;
14362 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14363 }
14364
14365 /**
14366 + * atomic64_add_unchecked - add integer to atomic64 variable
14367 + * @i: integer value to add
14368 + * @v: pointer to type atomic64_unchecked_t
14369 + *
14370 + * Atomically adds @i to @v.
14371 + */
14372 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14373 +{
14374 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14375 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14376 + ASM_NO_INPUT_CLOBBER("memory"));
14377 + return i;
14378 +}
14379 +
14380 +/**
14381 * atomic64_sub - subtract the atomic64 variable
14382 * @i: integer value to subtract
14383 * @v: pointer to type atomic64_t
14384 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14385 index 0e1cbfc..5623683 100644
14386 --- a/arch/x86/include/asm/atomic64_64.h
14387 +++ b/arch/x86/include/asm/atomic64_64.h
14388 @@ -18,7 +18,19 @@
14389 */
14390 static inline long atomic64_read(const atomic64_t *v)
14391 {
14392 - return (*(volatile long *)&(v)->counter);
14393 + return (*(volatile const long *)&(v)->counter);
14394 +}
14395 +
14396 +/**
14397 + * atomic64_read_unchecked - read atomic64 variable
14398 + * @v: pointer of type atomic64_unchecked_t
14399 + *
14400 + * Atomically reads the value of @v.
14401 + * Doesn't imply a read memory barrier.
14402 + */
14403 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14404 +{
14405 + return (*(volatile const long *)&(v)->counter);
14406 }
14407
14408 /**
14409 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14410 }
14411
14412 /**
14413 + * atomic64_set_unchecked - set atomic64 variable
14414 + * @v: pointer to type atomic64_unchecked_t
14415 + * @i: required value
14416 + *
14417 + * Atomically sets the value of @v to @i.
14418 + */
14419 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14420 +{
14421 + v->counter = i;
14422 +}
14423 +
14424 +/**
14425 * atomic64_add - add integer to atomic64 variable
14426 * @i: integer value to add
14427 * @v: pointer to type atomic64_t
14428 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14429 */
14430 static inline void atomic64_add(long i, atomic64_t *v)
14431 {
14432 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14433 +
14434 +#ifdef CONFIG_PAX_REFCOUNT
14435 + "jno 0f\n"
14436 + LOCK_PREFIX "subq %1,%0\n"
14437 + "int $4\n0:\n"
14438 + _ASM_EXTABLE(0b, 0b)
14439 +#endif
14440 +
14441 + : "=m" (v->counter)
14442 + : "er" (i), "m" (v->counter));
14443 +}
14444 +
14445 +/**
14446 + * atomic64_add_unchecked - add integer to atomic64 variable
14447 + * @i: integer value to add
14448 + * @v: pointer to type atomic64_unchecked_t
14449 + *
14450 + * Atomically adds @i to @v.
14451 + */
14452 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14453 +{
14454 asm volatile(LOCK_PREFIX "addq %1,%0"
14455 : "=m" (v->counter)
14456 : "er" (i), "m" (v->counter));
14457 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14458 */
14459 static inline void atomic64_sub(long i, atomic64_t *v)
14460 {
14461 - asm volatile(LOCK_PREFIX "subq %1,%0"
14462 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14463 +
14464 +#ifdef CONFIG_PAX_REFCOUNT
14465 + "jno 0f\n"
14466 + LOCK_PREFIX "addq %1,%0\n"
14467 + "int $4\n0:\n"
14468 + _ASM_EXTABLE(0b, 0b)
14469 +#endif
14470 +
14471 + : "=m" (v->counter)
14472 + : "er" (i), "m" (v->counter));
14473 +}
14474 +
14475 +/**
14476 + * atomic64_sub_unchecked - subtract the atomic64 variable
14477 + * @i: integer value to subtract
14478 + * @v: pointer to type atomic64_unchecked_t
14479 + *
14480 + * Atomically subtracts @i from @v.
14481 + */
14482 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14483 +{
14484 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14485 : "=m" (v->counter)
14486 : "er" (i), "m" (v->counter));
14487 }
14488 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14489 {
14490 unsigned char c;
14491
14492 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14493 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14494 +
14495 +#ifdef CONFIG_PAX_REFCOUNT
14496 + "jno 0f\n"
14497 + LOCK_PREFIX "addq %2,%0\n"
14498 + "int $4\n0:\n"
14499 + _ASM_EXTABLE(0b, 0b)
14500 +#endif
14501 +
14502 + "sete %1\n"
14503 : "=m" (v->counter), "=qm" (c)
14504 : "er" (i), "m" (v->counter) : "memory");
14505 return c;
14506 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14507 */
14508 static inline void atomic64_inc(atomic64_t *v)
14509 {
14510 + asm volatile(LOCK_PREFIX "incq %0\n"
14511 +
14512 +#ifdef CONFIG_PAX_REFCOUNT
14513 + "jno 0f\n"
14514 + LOCK_PREFIX "decq %0\n"
14515 + "int $4\n0:\n"
14516 + _ASM_EXTABLE(0b, 0b)
14517 +#endif
14518 +
14519 + : "=m" (v->counter)
14520 + : "m" (v->counter));
14521 +}
14522 +
14523 +/**
14524 + * atomic64_inc_unchecked - increment atomic64 variable
14525 + * @v: pointer to type atomic64_unchecked_t
14526 + *
14527 + * Atomically increments @v by 1.
14528 + */
14529 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14530 +{
14531 asm volatile(LOCK_PREFIX "incq %0"
14532 : "=m" (v->counter)
14533 : "m" (v->counter));
14534 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14535 */
14536 static inline void atomic64_dec(atomic64_t *v)
14537 {
14538 - asm volatile(LOCK_PREFIX "decq %0"
14539 + asm volatile(LOCK_PREFIX "decq %0\n"
14540 +
14541 +#ifdef CONFIG_PAX_REFCOUNT
14542 + "jno 0f\n"
14543 + LOCK_PREFIX "incq %0\n"
14544 + "int $4\n0:\n"
14545 + _ASM_EXTABLE(0b, 0b)
14546 +#endif
14547 +
14548 + : "=m" (v->counter)
14549 + : "m" (v->counter));
14550 +}
14551 +
14552 +/**
14553 + * atomic64_dec_unchecked - decrement atomic64 variable
14554 + * @v: pointer to type atomic64_t
14555 + *
14556 + * Atomically decrements @v by 1.
14557 + */
14558 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14559 +{
14560 + asm volatile(LOCK_PREFIX "decq %0\n"
14561 : "=m" (v->counter)
14562 : "m" (v->counter));
14563 }
14564 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14565 {
14566 unsigned char c;
14567
14568 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14569 + asm volatile(LOCK_PREFIX "decq %0\n"
14570 +
14571 +#ifdef CONFIG_PAX_REFCOUNT
14572 + "jno 0f\n"
14573 + LOCK_PREFIX "incq %0\n"
14574 + "int $4\n0:\n"
14575 + _ASM_EXTABLE(0b, 0b)
14576 +#endif
14577 +
14578 + "sete %1\n"
14579 : "=m" (v->counter), "=qm" (c)
14580 : "m" (v->counter) : "memory");
14581 return c != 0;
14582 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14583 {
14584 unsigned char c;
14585
14586 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14587 + asm volatile(LOCK_PREFIX "incq %0\n"
14588 +
14589 +#ifdef CONFIG_PAX_REFCOUNT
14590 + "jno 0f\n"
14591 + LOCK_PREFIX "decq %0\n"
14592 + "int $4\n0:\n"
14593 + _ASM_EXTABLE(0b, 0b)
14594 +#endif
14595 +
14596 + "sete %1\n"
14597 : "=m" (v->counter), "=qm" (c)
14598 : "m" (v->counter) : "memory");
14599 return c != 0;
14600 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14601 {
14602 unsigned char c;
14603
14604 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14605 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14606 +
14607 +#ifdef CONFIG_PAX_REFCOUNT
14608 + "jno 0f\n"
14609 + LOCK_PREFIX "subq %2,%0\n"
14610 + "int $4\n0:\n"
14611 + _ASM_EXTABLE(0b, 0b)
14612 +#endif
14613 +
14614 + "sets %1\n"
14615 : "=m" (v->counter), "=qm" (c)
14616 : "er" (i), "m" (v->counter) : "memory");
14617 return c;
14618 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14619 */
14620 static inline long atomic64_add_return(long i, atomic64_t *v)
14621 {
14622 + return i + xadd_check_overflow(&v->counter, i);
14623 +}
14624 +
14625 +/**
14626 + * atomic64_add_return_unchecked - add and return
14627 + * @i: integer value to add
14628 + * @v: pointer to type atomic64_unchecked_t
14629 + *
14630 + * Atomically adds @i to @v and returns @i + @v
14631 + */
14632 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14633 +{
14634 return i + xadd(&v->counter, i);
14635 }
14636
14637 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14638 }
14639
14640 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14641 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14642 +{
14643 + return atomic64_add_return_unchecked(1, v);
14644 +}
14645 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14646
14647 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14648 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14649 return cmpxchg(&v->counter, old, new);
14650 }
14651
14652 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14653 +{
14654 + return cmpxchg(&v->counter, old, new);
14655 +}
14656 +
14657 static inline long atomic64_xchg(atomic64_t *v, long new)
14658 {
14659 return xchg(&v->counter, new);
14660 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14661 */
14662 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14663 {
14664 - long c, old;
14665 + long c, old, new;
14666 c = atomic64_read(v);
14667 for (;;) {
14668 - if (unlikely(c == (u)))
14669 + if (unlikely(c == u))
14670 break;
14671 - old = atomic64_cmpxchg((v), c, c + (a));
14672 +
14673 + asm volatile("add %2,%0\n"
14674 +
14675 +#ifdef CONFIG_PAX_REFCOUNT
14676 + "jno 0f\n"
14677 + "sub %2,%0\n"
14678 + "int $4\n0:\n"
14679 + _ASM_EXTABLE(0b, 0b)
14680 +#endif
14681 +
14682 + : "=r" (new)
14683 + : "0" (c), "ir" (a));
14684 +
14685 + old = atomic64_cmpxchg(v, c, new);
14686 if (likely(old == c))
14687 break;
14688 c = old;
14689 }
14690 - return c != (u);
14691 + return c != u;
14692 }
14693
14694 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14695 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14696 index 41639ce..0bd8c87 100644
14697 --- a/arch/x86/include/asm/bitops.h
14698 +++ b/arch/x86/include/asm/bitops.h
14699 @@ -48,7 +48,7 @@
14700 * a mask operation on a byte.
14701 */
14702 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14703 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14704 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14705 #define CONST_MASK(nr) (1 << ((nr) & 7))
14706
14707 /**
14708 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
14709 *
14710 * Undefined if no bit exists, so code should check against 0 first.
14711 */
14712 -static inline unsigned long __ffs(unsigned long word)
14713 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
14714 {
14715 asm("rep; bsf %1,%0"
14716 : "=r" (word)
14717 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
14718 *
14719 * Undefined if no zero exists, so code should check against ~0UL first.
14720 */
14721 -static inline unsigned long ffz(unsigned long word)
14722 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
14723 {
14724 asm("rep; bsf %1,%0"
14725 : "=r" (word)
14726 @@ -494,7 +494,7 @@ static inline int fls(int x)
14727 * at position 64.
14728 */
14729 #ifdef CONFIG_X86_64
14730 -static __always_inline int fls64(__u64 x)
14731 +static __always_inline long fls64(__u64 x)
14732 {
14733 int bitpos = -1;
14734 /*
14735 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14736 index 4fa687a..60f2d39 100644
14737 --- a/arch/x86/include/asm/boot.h
14738 +++ b/arch/x86/include/asm/boot.h
14739 @@ -6,10 +6,15 @@
14740 #include <uapi/asm/boot.h>
14741
14742 /* Physical address where kernel should be loaded. */
14743 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14744 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14745 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14746 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14747
14748 +#ifndef __ASSEMBLY__
14749 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14750 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14751 +#endif
14752 +
14753 /* Minimum kernel alignment, as a power of two */
14754 #ifdef CONFIG_X86_64
14755 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14756 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14757 index 48f99f1..d78ebf9 100644
14758 --- a/arch/x86/include/asm/cache.h
14759 +++ b/arch/x86/include/asm/cache.h
14760 @@ -5,12 +5,13 @@
14761
14762 /* L1 cache line size */
14763 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14764 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14765 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14766
14767 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14768 +#define __read_only __attribute__((__section__(".data..read_only")))
14769
14770 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14771 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14772 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14773
14774 #ifdef CONFIG_X86_VSMP
14775 #ifdef CONFIG_SMP
14776 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14777 index 9863ee3..4a1f8e1 100644
14778 --- a/arch/x86/include/asm/cacheflush.h
14779 +++ b/arch/x86/include/asm/cacheflush.h
14780 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14781 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14782
14783 if (pg_flags == _PGMT_DEFAULT)
14784 - return -1;
14785 + return ~0UL;
14786 else if (pg_flags == _PGMT_WC)
14787 return _PAGE_CACHE_WC;
14788 else if (pg_flags == _PGMT_UC_MINUS)
14789 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14790 index f50de69..2b0a458 100644
14791 --- a/arch/x86/include/asm/checksum_32.h
14792 +++ b/arch/x86/include/asm/checksum_32.h
14793 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14794 int len, __wsum sum,
14795 int *src_err_ptr, int *dst_err_ptr);
14796
14797 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14798 + int len, __wsum sum,
14799 + int *src_err_ptr, int *dst_err_ptr);
14800 +
14801 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14802 + int len, __wsum sum,
14803 + int *src_err_ptr, int *dst_err_ptr);
14804 +
14805 /*
14806 * Note: when you get a NULL pointer exception here this means someone
14807 * passed in an incorrect kernel address to one of these functions.
14808 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14809
14810 might_sleep();
14811 stac();
14812 - ret = csum_partial_copy_generic((__force void *)src, dst,
14813 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14814 len, sum, err_ptr, NULL);
14815 clac();
14816
14817 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14818 might_sleep();
14819 if (access_ok(VERIFY_WRITE, dst, len)) {
14820 stac();
14821 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14822 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14823 len, sum, NULL, err_ptr);
14824 clac();
14825 return ret;
14826 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14827 index d47786a..ce1b05d 100644
14828 --- a/arch/x86/include/asm/cmpxchg.h
14829 +++ b/arch/x86/include/asm/cmpxchg.h
14830 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14831 __compiletime_error("Bad argument size for cmpxchg");
14832 extern void __xadd_wrong_size(void)
14833 __compiletime_error("Bad argument size for xadd");
14834 +extern void __xadd_check_overflow_wrong_size(void)
14835 + __compiletime_error("Bad argument size for xadd_check_overflow");
14836 extern void __add_wrong_size(void)
14837 __compiletime_error("Bad argument size for add");
14838 +extern void __add_check_overflow_wrong_size(void)
14839 + __compiletime_error("Bad argument size for add_check_overflow");
14840
14841 /*
14842 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14843 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14844 __ret; \
14845 })
14846
14847 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14848 + ({ \
14849 + __typeof__ (*(ptr)) __ret = (arg); \
14850 + switch (sizeof(*(ptr))) { \
14851 + case __X86_CASE_L: \
14852 + asm volatile (lock #op "l %0, %1\n" \
14853 + "jno 0f\n" \
14854 + "mov %0,%1\n" \
14855 + "int $4\n0:\n" \
14856 + _ASM_EXTABLE(0b, 0b) \
14857 + : "+r" (__ret), "+m" (*(ptr)) \
14858 + : : "memory", "cc"); \
14859 + break; \
14860 + case __X86_CASE_Q: \
14861 + asm volatile (lock #op "q %q0, %1\n" \
14862 + "jno 0f\n" \
14863 + "mov %0,%1\n" \
14864 + "int $4\n0:\n" \
14865 + _ASM_EXTABLE(0b, 0b) \
14866 + : "+r" (__ret), "+m" (*(ptr)) \
14867 + : : "memory", "cc"); \
14868 + break; \
14869 + default: \
14870 + __ ## op ## _check_overflow_wrong_size(); \
14871 + } \
14872 + __ret; \
14873 + })
14874 +
14875 /*
14876 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14877 * Since this is generally used to protect other memory information, we
14878 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14879 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14880 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14881
14882 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14883 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14884 +
14885 #define __add(ptr, inc, lock) \
14886 ({ \
14887 __typeof__ (*(ptr)) __ret = (inc); \
14888 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14889 index 59c6c40..5e0b22c 100644
14890 --- a/arch/x86/include/asm/compat.h
14891 +++ b/arch/x86/include/asm/compat.h
14892 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14893 typedef u32 compat_uint_t;
14894 typedef u32 compat_ulong_t;
14895 typedef u64 __attribute__((aligned(4))) compat_u64;
14896 -typedef u32 compat_uptr_t;
14897 +typedef u32 __user compat_uptr_t;
14898
14899 struct compat_timespec {
14900 compat_time_t tv_sec;
14901 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14902 index 89270b4..f0abf8e 100644
14903 --- a/arch/x86/include/asm/cpufeature.h
14904 +++ b/arch/x86/include/asm/cpufeature.h
14905 @@ -203,7 +203,7 @@
14906 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14907 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14908 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14909 -
14910 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14911
14912 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14913 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14914 @@ -211,7 +211,7 @@
14915 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14916 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14917 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14918 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14919 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14920 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14921 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14922 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14923 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14924 #undef cpu_has_centaur_mcr
14925 #define cpu_has_centaur_mcr 0
14926
14927 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14928 #endif /* CONFIG_X86_64 */
14929
14930 #if __GNUC__ >= 4
14931 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14932
14933 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14934 t_warn:
14935 - warn_pre_alternatives();
14936 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14937 + warn_pre_alternatives();
14938 return false;
14939 #endif
14940
14941 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14942 ".section .discard,\"aw\",@progbits\n"
14943 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14944 ".previous\n"
14945 - ".section .altinstr_replacement,\"ax\"\n"
14946 + ".section .altinstr_replacement,\"a\"\n"
14947 "3: movb $1,%0\n"
14948 "4:\n"
14949 ".previous\n"
14950 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14951 " .byte 2b - 1b\n" /* src len */
14952 " .byte 4f - 3f\n" /* repl len */
14953 ".previous\n"
14954 - ".section .altinstr_replacement,\"ax\"\n"
14955 + ".section .altinstr_replacement,\"a\"\n"
14956 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14957 "4:\n"
14958 ".previous\n"
14959 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14960 ".section .discard,\"aw\",@progbits\n"
14961 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14962 ".previous\n"
14963 - ".section .altinstr_replacement,\"ax\"\n"
14964 + ".section .altinstr_replacement,\"a\"\n"
14965 "3: movb $0,%0\n"
14966 "4:\n"
14967 ".previous\n"
14968 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14969 ".section .discard,\"aw\",@progbits\n"
14970 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14971 ".previous\n"
14972 - ".section .altinstr_replacement,\"ax\"\n"
14973 + ".section .altinstr_replacement,\"a\"\n"
14974 "5: movb $1,%0\n"
14975 "6:\n"
14976 ".previous\n"
14977 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14978 index b90e5df..b462c91 100644
14979 --- a/arch/x86/include/asm/desc.h
14980 +++ b/arch/x86/include/asm/desc.h
14981 @@ -4,6 +4,7 @@
14982 #include <asm/desc_defs.h>
14983 #include <asm/ldt.h>
14984 #include <asm/mmu.h>
14985 +#include <asm/pgtable.h>
14986
14987 #include <linux/smp.h>
14988 #include <linux/percpu.h>
14989 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14990
14991 desc->type = (info->read_exec_only ^ 1) << 1;
14992 desc->type |= info->contents << 2;
14993 + desc->type |= info->seg_not_present ^ 1;
14994
14995 desc->s = 1;
14996 desc->dpl = 0x3;
14997 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14998 }
14999
15000 extern struct desc_ptr idt_descr;
15001 -extern gate_desc idt_table[];
15002 -extern struct desc_ptr debug_idt_descr;
15003 -extern gate_desc debug_idt_table[];
15004 -
15005 -struct gdt_page {
15006 - struct desc_struct gdt[GDT_ENTRIES];
15007 -} __attribute__((aligned(PAGE_SIZE)));
15008 -
15009 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15010 +extern gate_desc idt_table[IDT_ENTRIES];
15011 +extern const struct desc_ptr debug_idt_descr;
15012 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15013
15014 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15015 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15016 {
15017 - return per_cpu(gdt_page, cpu).gdt;
15018 + return cpu_gdt_table[cpu];
15019 }
15020
15021 #ifdef CONFIG_X86_64
15022 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15023 unsigned long base, unsigned dpl, unsigned flags,
15024 unsigned short seg)
15025 {
15026 - gate->a = (seg << 16) | (base & 0xffff);
15027 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15028 + gate->gate.offset_low = base;
15029 + gate->gate.seg = seg;
15030 + gate->gate.reserved = 0;
15031 + gate->gate.type = type;
15032 + gate->gate.s = 0;
15033 + gate->gate.dpl = dpl;
15034 + gate->gate.p = 1;
15035 + gate->gate.offset_high = base >> 16;
15036 }
15037
15038 #endif
15039 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15040
15041 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15042 {
15043 + pax_open_kernel();
15044 memcpy(&idt[entry], gate, sizeof(*gate));
15045 + pax_close_kernel();
15046 }
15047
15048 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15049 {
15050 + pax_open_kernel();
15051 memcpy(&ldt[entry], desc, 8);
15052 + pax_close_kernel();
15053 }
15054
15055 static inline void
15056 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15057 default: size = sizeof(*gdt); break;
15058 }
15059
15060 + pax_open_kernel();
15061 memcpy(&gdt[entry], desc, size);
15062 + pax_close_kernel();
15063 }
15064
15065 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15066 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15067
15068 static inline void native_load_tr_desc(void)
15069 {
15070 + pax_open_kernel();
15071 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15072 + pax_close_kernel();
15073 }
15074
15075 static inline void native_load_gdt(const struct desc_ptr *dtr)
15076 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15077 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15078 unsigned int i;
15079
15080 + pax_open_kernel();
15081 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15082 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15083 + pax_close_kernel();
15084 }
15085
15086 #define _LDT_empty(info) \
15087 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15088 preempt_enable();
15089 }
15090
15091 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15092 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15093 {
15094 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15095 }
15096 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15097 }
15098
15099 #ifdef CONFIG_X86_64
15100 -static inline void set_nmi_gate(int gate, void *addr)
15101 +static inline void set_nmi_gate(int gate, const void *addr)
15102 {
15103 gate_desc s;
15104
15105 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15106 #endif
15107
15108 #ifdef CONFIG_TRACING
15109 -extern struct desc_ptr trace_idt_descr;
15110 -extern gate_desc trace_idt_table[];
15111 +extern const struct desc_ptr trace_idt_descr;
15112 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15113 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15114 {
15115 write_idt_entry(trace_idt_table, entry, gate);
15116 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15117 }
15118 #endif
15119
15120 -static inline void _set_gate(int gate, unsigned type, void *addr,
15121 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15122 unsigned dpl, unsigned ist, unsigned seg)
15123 {
15124 gate_desc s;
15125 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15126 * Pentium F0 0F bugfix can have resulted in the mapped
15127 * IDT being write-protected.
15128 */
15129 -static inline void set_intr_gate(unsigned int n, void *addr)
15130 +static inline void set_intr_gate(unsigned int n, const void *addr)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15134 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15135 /*
15136 * This routine sets up an interrupt gate at directory privilege level 3.
15137 */
15138 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15139 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15140 {
15141 BUG_ON((unsigned)n > 0xFF);
15142 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15143 }
15144
15145 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15146 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15147 {
15148 BUG_ON((unsigned)n > 0xFF);
15149 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15150 }
15151
15152 -static inline void set_trap_gate(unsigned int n, void *addr)
15153 +static inline void set_trap_gate(unsigned int n, const void *addr)
15154 {
15155 BUG_ON((unsigned)n > 0xFF);
15156 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15157 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15158 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15159 {
15160 BUG_ON((unsigned)n > 0xFF);
15161 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15162 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15163 }
15164
15165 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15166 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15167 {
15168 BUG_ON((unsigned)n > 0xFF);
15169 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15170 }
15171
15172 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15173 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15174 {
15175 BUG_ON((unsigned)n > 0xFF);
15176 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15177 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15178 else
15179 load_idt((const struct desc_ptr *)&idt_descr);
15180 }
15181 +
15182 +#ifdef CONFIG_X86_32
15183 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15184 +{
15185 + struct desc_struct d;
15186 +
15187 + if (likely(limit))
15188 + limit = (limit - 1UL) >> PAGE_SHIFT;
15189 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15190 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15191 +}
15192 +#endif
15193 +
15194 #endif /* _ASM_X86_DESC_H */
15195 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15196 index 278441f..b95a174 100644
15197 --- a/arch/x86/include/asm/desc_defs.h
15198 +++ b/arch/x86/include/asm/desc_defs.h
15199 @@ -31,6 +31,12 @@ struct desc_struct {
15200 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15201 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15202 };
15203 + struct {
15204 + u16 offset_low;
15205 + u16 seg;
15206 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15207 + unsigned offset_high: 16;
15208 + } gate;
15209 };
15210 } __attribute__((packed));
15211
15212 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15213 index ced283a..ffe04cc 100644
15214 --- a/arch/x86/include/asm/div64.h
15215 +++ b/arch/x86/include/asm/div64.h
15216 @@ -39,7 +39,7 @@
15217 __mod; \
15218 })
15219
15220 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15221 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15222 {
15223 union {
15224 u64 v64;
15225 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15226 index 9c999c1..3860cb8 100644
15227 --- a/arch/x86/include/asm/elf.h
15228 +++ b/arch/x86/include/asm/elf.h
15229 @@ -243,7 +243,25 @@ extern int force_personality32;
15230 the loader. We need to make sure that it is out of the way of the program
15231 that it will "exec", and that there is sufficient room for the brk. */
15232
15233 +#ifdef CONFIG_PAX_SEGMEXEC
15234 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15235 +#else
15236 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15237 +#endif
15238 +
15239 +#ifdef CONFIG_PAX_ASLR
15240 +#ifdef CONFIG_X86_32
15241 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15242 +
15243 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15244 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15245 +#else
15246 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15247 +
15248 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15249 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15250 +#endif
15251 +#endif
15252
15253 /* This yields a mask that user programs can use to figure out what
15254 instruction set this CPU supports. This could be done in user space,
15255 @@ -296,16 +314,12 @@ do { \
15256
15257 #define ARCH_DLINFO \
15258 do { \
15259 - if (vdso_enabled) \
15260 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15261 - (unsigned long)current->mm->context.vdso); \
15262 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15263 } while (0)
15264
15265 #define ARCH_DLINFO_X32 \
15266 do { \
15267 - if (vdso_enabled) \
15268 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15269 - (unsigned long)current->mm->context.vdso); \
15270 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15271 } while (0)
15272
15273 #define AT_SYSINFO 32
15274 @@ -320,7 +334,7 @@ else \
15275
15276 #endif /* !CONFIG_X86_32 */
15277
15278 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15279 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15280
15281 #define VDSO_ENTRY \
15282 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15283 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15284 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15285 #define compat_arch_setup_additional_pages syscall32_setup_pages
15286
15287 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15288 -#define arch_randomize_brk arch_randomize_brk
15289 -
15290 /*
15291 * True on X86_32 or when emulating IA32 on X86_64
15292 */
15293 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15294 index 77a99ac..39ff7f5 100644
15295 --- a/arch/x86/include/asm/emergency-restart.h
15296 +++ b/arch/x86/include/asm/emergency-restart.h
15297 @@ -1,6 +1,6 @@
15298 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15299 #define _ASM_X86_EMERGENCY_RESTART_H
15300
15301 -extern void machine_emergency_restart(void);
15302 +extern void machine_emergency_restart(void) __noreturn;
15303
15304 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15305 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15306 index 4d0bda7..221da4d 100644
15307 --- a/arch/x86/include/asm/fpu-internal.h
15308 +++ b/arch/x86/include/asm/fpu-internal.h
15309 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15310 #define user_insn(insn, output, input...) \
15311 ({ \
15312 int err; \
15313 + pax_open_userland(); \
15314 asm volatile(ASM_STAC "\n" \
15315 - "1:" #insn "\n\t" \
15316 + "1:" \
15317 + __copyuser_seg \
15318 + #insn "\n\t" \
15319 "2: " ASM_CLAC "\n" \
15320 ".section .fixup,\"ax\"\n" \
15321 "3: movl $-1,%[err]\n" \
15322 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15323 _ASM_EXTABLE(1b, 3b) \
15324 : [err] "=r" (err), output \
15325 : "0"(0), input); \
15326 + pax_close_userland(); \
15327 err; \
15328 })
15329
15330 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15331 "emms\n\t" /* clear stack tags */
15332 "fildl %P[addr]", /* set F?P to defined value */
15333 X86_FEATURE_FXSAVE_LEAK,
15334 - [addr] "m" (tsk->thread.fpu.has_fpu));
15335 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15336
15337 return fpu_restore_checking(&tsk->thread.fpu);
15338 }
15339 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15340 index be27ba1..04a8801 100644
15341 --- a/arch/x86/include/asm/futex.h
15342 +++ b/arch/x86/include/asm/futex.h
15343 @@ -12,6 +12,7 @@
15344 #include <asm/smap.h>
15345
15346 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15347 + typecheck(u32 __user *, uaddr); \
15348 asm volatile("\t" ASM_STAC "\n" \
15349 "1:\t" insn "\n" \
15350 "2:\t" ASM_CLAC "\n" \
15351 @@ -20,15 +21,16 @@
15352 "\tjmp\t2b\n" \
15353 "\t.previous\n" \
15354 _ASM_EXTABLE(1b, 3b) \
15355 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15356 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15357 : "i" (-EFAULT), "0" (oparg), "1" (0))
15358
15359 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15360 + typecheck(u32 __user *, uaddr); \
15361 asm volatile("\t" ASM_STAC "\n" \
15362 "1:\tmovl %2, %0\n" \
15363 "\tmovl\t%0, %3\n" \
15364 "\t" insn "\n" \
15365 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15366 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15367 "\tjnz\t1b\n" \
15368 "3:\t" ASM_CLAC "\n" \
15369 "\t.section .fixup,\"ax\"\n" \
15370 @@ -38,7 +40,7 @@
15371 _ASM_EXTABLE(1b, 4b) \
15372 _ASM_EXTABLE(2b, 4b) \
15373 : "=&a" (oldval), "=&r" (ret), \
15374 - "+m" (*uaddr), "=&r" (tem) \
15375 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15376 : "r" (oparg), "i" (-EFAULT), "1" (0))
15377
15378 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15379 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15380
15381 pagefault_disable();
15382
15383 + pax_open_userland();
15384 switch (op) {
15385 case FUTEX_OP_SET:
15386 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15387 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15388 break;
15389 case FUTEX_OP_ADD:
15390 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15391 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15392 uaddr, oparg);
15393 break;
15394 case FUTEX_OP_OR:
15395 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15396 default:
15397 ret = -ENOSYS;
15398 }
15399 + pax_close_userland();
15400
15401 pagefault_enable();
15402
15403 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15404 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15405 return -EFAULT;
15406
15407 + pax_open_userland();
15408 asm volatile("\t" ASM_STAC "\n"
15409 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15410 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15411 "2:\t" ASM_CLAC "\n"
15412 "\t.section .fixup, \"ax\"\n"
15413 "3:\tmov %3, %0\n"
15414 "\tjmp 2b\n"
15415 "\t.previous\n"
15416 _ASM_EXTABLE(1b, 3b)
15417 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15418 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15419 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15420 : "memory"
15421 );
15422 + pax_close_userland();
15423
15424 *uval = oldval;
15425 return ret;
15426 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15427 index 92b3bae..3866449 100644
15428 --- a/arch/x86/include/asm/hw_irq.h
15429 +++ b/arch/x86/include/asm/hw_irq.h
15430 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15431 extern void enable_IO_APIC(void);
15432
15433 /* Statistics */
15434 -extern atomic_t irq_err_count;
15435 -extern atomic_t irq_mis_count;
15436 +extern atomic_unchecked_t irq_err_count;
15437 +extern atomic_unchecked_t irq_mis_count;
15438
15439 /* EISA */
15440 extern void eisa_set_level_irq(unsigned int irq);
15441 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15442 index a203659..9889f1c 100644
15443 --- a/arch/x86/include/asm/i8259.h
15444 +++ b/arch/x86/include/asm/i8259.h
15445 @@ -62,7 +62,7 @@ struct legacy_pic {
15446 void (*init)(int auto_eoi);
15447 int (*irq_pending)(unsigned int irq);
15448 void (*make_irq)(unsigned int irq);
15449 -};
15450 +} __do_const;
15451
15452 extern struct legacy_pic *legacy_pic;
15453 extern struct legacy_pic null_legacy_pic;
15454 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15455 index 34f69cb..6d95446 100644
15456 --- a/arch/x86/include/asm/io.h
15457 +++ b/arch/x86/include/asm/io.h
15458 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15459 "m" (*(volatile type __force *)addr) barrier); }
15460
15461 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15462 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15463 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15464 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15465 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15466
15467 build_mmio_read(__readb, "b", unsigned char, "=q", )
15468 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15469 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15470 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15471 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15472
15473 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15474 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15475 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15476 return ioremap_nocache(offset, size);
15477 }
15478
15479 -extern void iounmap(volatile void __iomem *addr);
15480 +extern void iounmap(const volatile void __iomem *addr);
15481
15482 extern void set_iounmap_nonlazy(void);
15483
15484 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15485
15486 #include <linux/vmalloc.h>
15487
15488 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15489 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15490 +{
15491 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15492 +}
15493 +
15494 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15495 +{
15496 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15497 +}
15498 +
15499 /*
15500 * Convert a virtual cached pointer to an uncached pointer
15501 */
15502 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15503 index bba3cf8..06bc8da 100644
15504 --- a/arch/x86/include/asm/irqflags.h
15505 +++ b/arch/x86/include/asm/irqflags.h
15506 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15507 sti; \
15508 sysexit
15509
15510 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15511 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15512 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15513 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15514 +
15515 #else
15516 #define INTERRUPT_RETURN iret
15517 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15518 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15519 index 9454c16..e4100e3 100644
15520 --- a/arch/x86/include/asm/kprobes.h
15521 +++ b/arch/x86/include/asm/kprobes.h
15522 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15523 #define RELATIVEJUMP_SIZE 5
15524 #define RELATIVECALL_OPCODE 0xe8
15525 #define RELATIVE_ADDR_SIZE 4
15526 -#define MAX_STACK_SIZE 64
15527 -#define MIN_STACK_SIZE(ADDR) \
15528 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15529 - THREAD_SIZE - (unsigned long)(ADDR))) \
15530 - ? (MAX_STACK_SIZE) \
15531 - : (((unsigned long)current_thread_info()) + \
15532 - THREAD_SIZE - (unsigned long)(ADDR)))
15533 +#define MAX_STACK_SIZE 64UL
15534 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15535
15536 #define flush_insn_slot(p) do { } while (0)
15537
15538 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15539 index 2d89e39..baee879 100644
15540 --- a/arch/x86/include/asm/local.h
15541 +++ b/arch/x86/include/asm/local.h
15542 @@ -10,33 +10,97 @@ typedef struct {
15543 atomic_long_t a;
15544 } local_t;
15545
15546 +typedef struct {
15547 + atomic_long_unchecked_t a;
15548 +} local_unchecked_t;
15549 +
15550 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15551
15552 #define local_read(l) atomic_long_read(&(l)->a)
15553 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15554 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15555 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15556
15557 static inline void local_inc(local_t *l)
15558 {
15559 - asm volatile(_ASM_INC "%0"
15560 + asm volatile(_ASM_INC "%0\n"
15561 +
15562 +#ifdef CONFIG_PAX_REFCOUNT
15563 + "jno 0f\n"
15564 + _ASM_DEC "%0\n"
15565 + "int $4\n0:\n"
15566 + _ASM_EXTABLE(0b, 0b)
15567 +#endif
15568 +
15569 + : "+m" (l->a.counter));
15570 +}
15571 +
15572 +static inline void local_inc_unchecked(local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_INC "%0\n"
15575 : "+m" (l->a.counter));
15576 }
15577
15578 static inline void local_dec(local_t *l)
15579 {
15580 - asm volatile(_ASM_DEC "%0"
15581 + asm volatile(_ASM_DEC "%0\n"
15582 +
15583 +#ifdef CONFIG_PAX_REFCOUNT
15584 + "jno 0f\n"
15585 + _ASM_INC "%0\n"
15586 + "int $4\n0:\n"
15587 + _ASM_EXTABLE(0b, 0b)
15588 +#endif
15589 +
15590 + : "+m" (l->a.counter));
15591 +}
15592 +
15593 +static inline void local_dec_unchecked(local_unchecked_t *l)
15594 +{
15595 + asm volatile(_ASM_DEC "%0\n"
15596 : "+m" (l->a.counter));
15597 }
15598
15599 static inline void local_add(long i, local_t *l)
15600 {
15601 - asm volatile(_ASM_ADD "%1,%0"
15602 + asm volatile(_ASM_ADD "%1,%0\n"
15603 +
15604 +#ifdef CONFIG_PAX_REFCOUNT
15605 + "jno 0f\n"
15606 + _ASM_SUB "%1,%0\n"
15607 + "int $4\n0:\n"
15608 + _ASM_EXTABLE(0b, 0b)
15609 +#endif
15610 +
15611 + : "+m" (l->a.counter)
15612 + : "ir" (i));
15613 +}
15614 +
15615 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15616 +{
15617 + asm volatile(_ASM_ADD "%1,%0\n"
15618 : "+m" (l->a.counter)
15619 : "ir" (i));
15620 }
15621
15622 static inline void local_sub(long i, local_t *l)
15623 {
15624 - asm volatile(_ASM_SUB "%1,%0"
15625 + asm volatile(_ASM_SUB "%1,%0\n"
15626 +
15627 +#ifdef CONFIG_PAX_REFCOUNT
15628 + "jno 0f\n"
15629 + _ASM_ADD "%1,%0\n"
15630 + "int $4\n0:\n"
15631 + _ASM_EXTABLE(0b, 0b)
15632 +#endif
15633 +
15634 + : "+m" (l->a.counter)
15635 + : "ir" (i));
15636 +}
15637 +
15638 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15639 +{
15640 + asm volatile(_ASM_SUB "%1,%0\n"
15641 : "+m" (l->a.counter)
15642 : "ir" (i));
15643 }
15644 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15645 {
15646 unsigned char c;
15647
15648 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15649 + asm volatile(_ASM_SUB "%2,%0\n"
15650 +
15651 +#ifdef CONFIG_PAX_REFCOUNT
15652 + "jno 0f\n"
15653 + _ASM_ADD "%2,%0\n"
15654 + "int $4\n0:\n"
15655 + _ASM_EXTABLE(0b, 0b)
15656 +#endif
15657 +
15658 + "sete %1\n"
15659 : "+m" (l->a.counter), "=qm" (c)
15660 : "ir" (i) : "memory");
15661 return c;
15662 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15663 {
15664 unsigned char c;
15665
15666 - asm volatile(_ASM_DEC "%0; sete %1"
15667 + asm volatile(_ASM_DEC "%0\n"
15668 +
15669 +#ifdef CONFIG_PAX_REFCOUNT
15670 + "jno 0f\n"
15671 + _ASM_INC "%0\n"
15672 + "int $4\n0:\n"
15673 + _ASM_EXTABLE(0b, 0b)
15674 +#endif
15675 +
15676 + "sete %1\n"
15677 : "+m" (l->a.counter), "=qm" (c)
15678 : : "memory");
15679 return c != 0;
15680 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15681 {
15682 unsigned char c;
15683
15684 - asm volatile(_ASM_INC "%0; sete %1"
15685 + asm volatile(_ASM_INC "%0\n"
15686 +
15687 +#ifdef CONFIG_PAX_REFCOUNT
15688 + "jno 0f\n"
15689 + _ASM_DEC "%0\n"
15690 + "int $4\n0:\n"
15691 + _ASM_EXTABLE(0b, 0b)
15692 +#endif
15693 +
15694 + "sete %1\n"
15695 : "+m" (l->a.counter), "=qm" (c)
15696 : : "memory");
15697 return c != 0;
15698 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15699 {
15700 unsigned char c;
15701
15702 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15703 + asm volatile(_ASM_ADD "%2,%0\n"
15704 +
15705 +#ifdef CONFIG_PAX_REFCOUNT
15706 + "jno 0f\n"
15707 + _ASM_SUB "%2,%0\n"
15708 + "int $4\n0:\n"
15709 + _ASM_EXTABLE(0b, 0b)
15710 +#endif
15711 +
15712 + "sets %1\n"
15713 : "+m" (l->a.counter), "=qm" (c)
15714 : "ir" (i) : "memory");
15715 return c;
15716 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15717 static inline long local_add_return(long i, local_t *l)
15718 {
15719 long __i = i;
15720 + asm volatile(_ASM_XADD "%0, %1\n"
15721 +
15722 +#ifdef CONFIG_PAX_REFCOUNT
15723 + "jno 0f\n"
15724 + _ASM_MOV "%0,%1\n"
15725 + "int $4\n0:\n"
15726 + _ASM_EXTABLE(0b, 0b)
15727 +#endif
15728 +
15729 + : "+r" (i), "+m" (l->a.counter)
15730 + : : "memory");
15731 + return i + __i;
15732 +}
15733 +
15734 +/**
15735 + * local_add_return_unchecked - add and return
15736 + * @i: integer value to add
15737 + * @l: pointer to type local_unchecked_t
15738 + *
15739 + * Atomically adds @i to @l and returns @i + @l
15740 + */
15741 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15742 +{
15743 + long __i = i;
15744 asm volatile(_ASM_XADD "%0, %1;"
15745 : "+r" (i), "+m" (l->a.counter)
15746 : : "memory");
15747 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15748
15749 #define local_cmpxchg(l, o, n) \
15750 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15751 +#define local_cmpxchg_unchecked(l, o, n) \
15752 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15753 /* Always has a lock prefix */
15754 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15755
15756 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15757 new file mode 100644
15758 index 0000000..2bfd3ba
15759 --- /dev/null
15760 +++ b/arch/x86/include/asm/mman.h
15761 @@ -0,0 +1,15 @@
15762 +#ifndef _X86_MMAN_H
15763 +#define _X86_MMAN_H
15764 +
15765 +#include <uapi/asm/mman.h>
15766 +
15767 +#ifdef __KERNEL__
15768 +#ifndef __ASSEMBLY__
15769 +#ifdef CONFIG_X86_32
15770 +#define arch_mmap_check i386_mmap_check
15771 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15772 +#endif
15773 +#endif
15774 +#endif
15775 +
15776 +#endif /* X86_MMAN_H */
15777 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15778 index 5f55e69..e20bfb1 100644
15779 --- a/arch/x86/include/asm/mmu.h
15780 +++ b/arch/x86/include/asm/mmu.h
15781 @@ -9,7 +9,7 @@
15782 * we put the segment information here.
15783 */
15784 typedef struct {
15785 - void *ldt;
15786 + struct desc_struct *ldt;
15787 int size;
15788
15789 #ifdef CONFIG_X86_64
15790 @@ -18,7 +18,19 @@ typedef struct {
15791 #endif
15792
15793 struct mutex lock;
15794 - void *vdso;
15795 + unsigned long vdso;
15796 +
15797 +#ifdef CONFIG_X86_32
15798 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15799 + unsigned long user_cs_base;
15800 + unsigned long user_cs_limit;
15801 +
15802 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15803 + cpumask_t cpu_user_cs_mask;
15804 +#endif
15805 +
15806 +#endif
15807 +#endif
15808 } mm_context_t;
15809
15810 #ifdef CONFIG_SMP
15811 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15812 index be12c53..4d24039 100644
15813 --- a/arch/x86/include/asm/mmu_context.h
15814 +++ b/arch/x86/include/asm/mmu_context.h
15815 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15816
15817 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15818 {
15819 +
15820 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15821 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15822 + unsigned int i;
15823 + pgd_t *pgd;
15824 +
15825 + pax_open_kernel();
15826 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15827 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15828 + set_pgd_batched(pgd+i, native_make_pgd(0));
15829 + pax_close_kernel();
15830 + }
15831 +#endif
15832 +
15833 #ifdef CONFIG_SMP
15834 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15835 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15836 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15837 struct task_struct *tsk)
15838 {
15839 unsigned cpu = smp_processor_id();
15840 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15841 + int tlbstate = TLBSTATE_OK;
15842 +#endif
15843
15844 if (likely(prev != next)) {
15845 #ifdef CONFIG_SMP
15846 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15847 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15848 +#endif
15849 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15850 this_cpu_write(cpu_tlbstate.active_mm, next);
15851 #endif
15852 cpumask_set_cpu(cpu, mm_cpumask(next));
15853
15854 /* Re-load page tables */
15855 +#ifdef CONFIG_PAX_PER_CPU_PGD
15856 + pax_open_kernel();
15857 +
15858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15859 + if (static_cpu_has(X86_FEATURE_PCID))
15860 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15861 + else
15862 +#endif
15863 +
15864 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15865 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15866 + pax_close_kernel();
15867 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15868 +
15869 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15870 + if (static_cpu_has(X86_FEATURE_PCID)) {
15871 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15872 + u64 descriptor[2];
15873 + descriptor[0] = PCID_USER;
15874 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15875 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15876 + descriptor[0] = PCID_KERNEL;
15877 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15878 + }
15879 + } else {
15880 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15881 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15882 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15883 + else
15884 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15885 + }
15886 + } else
15887 +#endif
15888 +
15889 + load_cr3(get_cpu_pgd(cpu, kernel));
15890 +#else
15891 load_cr3(next->pgd);
15892 +#endif
15893
15894 /* Stop flush ipis for the previous mm */
15895 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15896 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15897 /* Load the LDT, if the LDT is different: */
15898 if (unlikely(prev->context.ldt != next->context.ldt))
15899 load_LDT_nolock(&next->context);
15900 +
15901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15902 + if (!(__supported_pte_mask & _PAGE_NX)) {
15903 + smp_mb__before_clear_bit();
15904 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15905 + smp_mb__after_clear_bit();
15906 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15907 + }
15908 +#endif
15909 +
15910 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15911 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15912 + prev->context.user_cs_limit != next->context.user_cs_limit))
15913 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15914 +#ifdef CONFIG_SMP
15915 + else if (unlikely(tlbstate != TLBSTATE_OK))
15916 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15917 +#endif
15918 +#endif
15919 +
15920 }
15921 + else {
15922 +
15923 +#ifdef CONFIG_PAX_PER_CPU_PGD
15924 + pax_open_kernel();
15925 +
15926 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15927 + if (static_cpu_has(X86_FEATURE_PCID))
15928 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15929 + else
15930 +#endif
15931 +
15932 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15933 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15934 + pax_close_kernel();
15935 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15936 +
15937 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15938 + if (static_cpu_has(X86_FEATURE_PCID)) {
15939 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15940 + u64 descriptor[2];
15941 + descriptor[0] = PCID_USER;
15942 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15943 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15944 + descriptor[0] = PCID_KERNEL;
15945 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15946 + }
15947 + } else {
15948 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15949 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15950 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15951 + else
15952 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15953 + }
15954 + } else
15955 +#endif
15956 +
15957 + load_cr3(get_cpu_pgd(cpu, kernel));
15958 +#endif
15959 +
15960 #ifdef CONFIG_SMP
15961 - else {
15962 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15963 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15964
15965 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15966 * tlb flush IPI delivery. We must reload CR3
15967 * to make sure to use no freed page tables.
15968 */
15969 +
15970 +#ifndef CONFIG_PAX_PER_CPU_PGD
15971 load_cr3(next->pgd);
15972 +#endif
15973 +
15974 load_LDT_nolock(&next->context);
15975 +
15976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15977 + if (!(__supported_pte_mask & _PAGE_NX))
15978 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15979 +#endif
15980 +
15981 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15982 +#ifdef CONFIG_PAX_PAGEEXEC
15983 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15984 +#endif
15985 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15986 +#endif
15987 +
15988 }
15989 +#endif
15990 }
15991 -#endif
15992 }
15993
15994 #define activate_mm(prev, next) \
15995 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15996 index e3b7819..b257c64 100644
15997 --- a/arch/x86/include/asm/module.h
15998 +++ b/arch/x86/include/asm/module.h
15999 @@ -5,6 +5,7 @@
16000
16001 #ifdef CONFIG_X86_64
16002 /* X86_64 does not define MODULE_PROC_FAMILY */
16003 +#define MODULE_PROC_FAMILY ""
16004 #elif defined CONFIG_M486
16005 #define MODULE_PROC_FAMILY "486 "
16006 #elif defined CONFIG_M586
16007 @@ -57,8 +58,20 @@
16008 #error unknown processor family
16009 #endif
16010
16011 -#ifdef CONFIG_X86_32
16012 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16013 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16014 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16015 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16016 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16017 +#else
16018 +#define MODULE_PAX_KERNEXEC ""
16019 #endif
16020
16021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16022 +#define MODULE_PAX_UDEREF "UDEREF "
16023 +#else
16024 +#define MODULE_PAX_UDEREF ""
16025 +#endif
16026 +
16027 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16028 +
16029 #endif /* _ASM_X86_MODULE_H */
16030 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16031 index 86f9301..b365cda 100644
16032 --- a/arch/x86/include/asm/nmi.h
16033 +++ b/arch/x86/include/asm/nmi.h
16034 @@ -40,11 +40,11 @@ struct nmiaction {
16035 nmi_handler_t handler;
16036 unsigned long flags;
16037 const char *name;
16038 -};
16039 +} __do_const;
16040
16041 #define register_nmi_handler(t, fn, fg, n, init...) \
16042 ({ \
16043 - static struct nmiaction init fn##_na = { \
16044 + static const struct nmiaction init fn##_na = { \
16045 .handler = (fn), \
16046 .name = (n), \
16047 .flags = (fg), \
16048 @@ -52,7 +52,7 @@ struct nmiaction {
16049 __register_nmi_handler((t), &fn##_na); \
16050 })
16051
16052 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16053 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16054
16055 void unregister_nmi_handler(unsigned int, const char *);
16056
16057 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16058 index c878924..21f4889 100644
16059 --- a/arch/x86/include/asm/page.h
16060 +++ b/arch/x86/include/asm/page.h
16061 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16062 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16063
16064 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16065 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16066
16067 #define __boot_va(x) __va(x)
16068 #define __boot_pa(x) __pa(x)
16069 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16070 index 0f1ddee..e2fc3d1 100644
16071 --- a/arch/x86/include/asm/page_64.h
16072 +++ b/arch/x86/include/asm/page_64.h
16073 @@ -7,9 +7,9 @@
16074
16075 /* duplicated to the one in bootmem.h */
16076 extern unsigned long max_pfn;
16077 -extern unsigned long phys_base;
16078 +extern const unsigned long phys_base;
16079
16080 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16081 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16082 {
16083 unsigned long y = x - __START_KERNEL_map;
16084
16085 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16086 index 401f350..dee5d13 100644
16087 --- a/arch/x86/include/asm/paravirt.h
16088 +++ b/arch/x86/include/asm/paravirt.h
16089 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16090 return (pmd_t) { ret };
16091 }
16092
16093 -static inline pmdval_t pmd_val(pmd_t pmd)
16094 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16095 {
16096 pmdval_t ret;
16097
16098 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16099 val);
16100 }
16101
16102 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16103 +{
16104 + pgdval_t val = native_pgd_val(pgd);
16105 +
16106 + if (sizeof(pgdval_t) > sizeof(long))
16107 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16108 + val, (u64)val >> 32);
16109 + else
16110 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16111 + val);
16112 +}
16113 +
16114 static inline void pgd_clear(pgd_t *pgdp)
16115 {
16116 set_pgd(pgdp, __pgd(0));
16117 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16118 pv_mmu_ops.set_fixmap(idx, phys, flags);
16119 }
16120
16121 +#ifdef CONFIG_PAX_KERNEXEC
16122 +static inline unsigned long pax_open_kernel(void)
16123 +{
16124 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16125 +}
16126 +
16127 +static inline unsigned long pax_close_kernel(void)
16128 +{
16129 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16130 +}
16131 +#else
16132 +static inline unsigned long pax_open_kernel(void) { return 0; }
16133 +static inline unsigned long pax_close_kernel(void) { return 0; }
16134 +#endif
16135 +
16136 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16137
16138 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16139 @@ -906,7 +933,7 @@ extern void default_banner(void);
16140
16141 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16142 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16143 -#define PARA_INDIRECT(addr) *%cs:addr
16144 +#define PARA_INDIRECT(addr) *%ss:addr
16145 #endif
16146
16147 #define INTERRUPT_RETURN \
16148 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16149 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16150 CLBR_NONE, \
16151 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16152 +
16153 +#define GET_CR0_INTO_RDI \
16154 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16155 + mov %rax,%rdi
16156 +
16157 +#define SET_RDI_INTO_CR0 \
16158 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16159 +
16160 +#define GET_CR3_INTO_RDI \
16161 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16162 + mov %rax,%rdi
16163 +
16164 +#define SET_RDI_INTO_CR3 \
16165 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16166 +
16167 #endif /* CONFIG_X86_32 */
16168
16169 #endif /* __ASSEMBLY__ */
16170 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16171 index aab8f67..2531748 100644
16172 --- a/arch/x86/include/asm/paravirt_types.h
16173 +++ b/arch/x86/include/asm/paravirt_types.h
16174 @@ -84,7 +84,7 @@ struct pv_init_ops {
16175 */
16176 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16177 unsigned long addr, unsigned len);
16178 -};
16179 +} __no_const;
16180
16181
16182 struct pv_lazy_ops {
16183 @@ -98,7 +98,7 @@ struct pv_time_ops {
16184 unsigned long long (*sched_clock)(void);
16185 unsigned long long (*steal_clock)(int cpu);
16186 unsigned long (*get_tsc_khz)(void);
16187 -};
16188 +} __no_const;
16189
16190 struct pv_cpu_ops {
16191 /* hooks for various privileged instructions */
16192 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16193
16194 void (*start_context_switch)(struct task_struct *prev);
16195 void (*end_context_switch)(struct task_struct *next);
16196 -};
16197 +} __no_const;
16198
16199 struct pv_irq_ops {
16200 /*
16201 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16202 unsigned long start_eip,
16203 unsigned long start_esp);
16204 #endif
16205 -};
16206 +} __no_const;
16207
16208 struct pv_mmu_ops {
16209 unsigned long (*read_cr2)(void);
16210 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16211 struct paravirt_callee_save make_pud;
16212
16213 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16214 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16215 #endif /* PAGETABLE_LEVELS == 4 */
16216 #endif /* PAGETABLE_LEVELS >= 3 */
16217
16218 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16219 an mfn. We can tell which is which from the index. */
16220 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16221 phys_addr_t phys, pgprot_t flags);
16222 +
16223 +#ifdef CONFIG_PAX_KERNEXEC
16224 + unsigned long (*pax_open_kernel)(void);
16225 + unsigned long (*pax_close_kernel)(void);
16226 +#endif
16227 +
16228 };
16229
16230 struct arch_spinlock;
16231 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16232 index b4389a4..7024269 100644
16233 --- a/arch/x86/include/asm/pgalloc.h
16234 +++ b/arch/x86/include/asm/pgalloc.h
16235 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16236 pmd_t *pmd, pte_t *pte)
16237 {
16238 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16239 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16240 +}
16241 +
16242 +static inline void pmd_populate_user(struct mm_struct *mm,
16243 + pmd_t *pmd, pte_t *pte)
16244 +{
16245 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16246 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16247 }
16248
16249 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16250
16251 #ifdef CONFIG_X86_PAE
16252 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16253 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16254 +{
16255 + pud_populate(mm, pudp, pmd);
16256 +}
16257 #else /* !CONFIG_X86_PAE */
16258 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16259 {
16260 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16261 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16262 }
16263 +
16264 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16265 +{
16266 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16267 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16268 +}
16269 #endif /* CONFIG_X86_PAE */
16270
16271 #if PAGETABLE_LEVELS > 3
16272 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16273 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16274 }
16275
16276 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16277 +{
16278 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16279 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16280 +}
16281 +
16282 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16283 {
16284 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16285 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16286 index 3bf2dd0..23d2a9f 100644
16287 --- a/arch/x86/include/asm/pgtable-2level.h
16288 +++ b/arch/x86/include/asm/pgtable-2level.h
16289 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16290
16291 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16292 {
16293 + pax_open_kernel();
16294 *pmdp = pmd;
16295 + pax_close_kernel();
16296 }
16297
16298 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16299 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16300 index 81bb91b..9392125 100644
16301 --- a/arch/x86/include/asm/pgtable-3level.h
16302 +++ b/arch/x86/include/asm/pgtable-3level.h
16303 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16304
16305 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16306 {
16307 + pax_open_kernel();
16308 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16309 + pax_close_kernel();
16310 }
16311
16312 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16313 {
16314 + pax_open_kernel();
16315 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16316 + pax_close_kernel();
16317 }
16318
16319 /*
16320 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16321 index 3d19994..732a48c 100644
16322 --- a/arch/x86/include/asm/pgtable.h
16323 +++ b/arch/x86/include/asm/pgtable.h
16324 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16325
16326 #ifndef __PAGETABLE_PUD_FOLDED
16327 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16328 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16329 #define pgd_clear(pgd) native_pgd_clear(pgd)
16330 #endif
16331
16332 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16333
16334 #define arch_end_context_switch(prev) do {} while(0)
16335
16336 +#define pax_open_kernel() native_pax_open_kernel()
16337 +#define pax_close_kernel() native_pax_close_kernel()
16338 #endif /* CONFIG_PARAVIRT */
16339
16340 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16341 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16342 +
16343 +#ifdef CONFIG_PAX_KERNEXEC
16344 +static inline unsigned long native_pax_open_kernel(void)
16345 +{
16346 + unsigned long cr0;
16347 +
16348 + preempt_disable();
16349 + barrier();
16350 + cr0 = read_cr0() ^ X86_CR0_WP;
16351 + BUG_ON(cr0 & X86_CR0_WP);
16352 + write_cr0(cr0);
16353 + return cr0 ^ X86_CR0_WP;
16354 +}
16355 +
16356 +static inline unsigned long native_pax_close_kernel(void)
16357 +{
16358 + unsigned long cr0;
16359 +
16360 + cr0 = read_cr0() ^ X86_CR0_WP;
16361 + BUG_ON(!(cr0 & X86_CR0_WP));
16362 + write_cr0(cr0);
16363 + barrier();
16364 + preempt_enable_no_resched();
16365 + return cr0 ^ X86_CR0_WP;
16366 +}
16367 +#else
16368 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16369 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16370 +#endif
16371 +
16372 /*
16373 * The following only work if pte_present() is true.
16374 * Undefined behaviour if not..
16375 */
16376 +static inline int pte_user(pte_t pte)
16377 +{
16378 + return pte_val(pte) & _PAGE_USER;
16379 +}
16380 +
16381 static inline int pte_dirty(pte_t pte)
16382 {
16383 return pte_flags(pte) & _PAGE_DIRTY;
16384 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16385 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16386 }
16387
16388 +static inline unsigned long pgd_pfn(pgd_t pgd)
16389 +{
16390 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16391 +}
16392 +
16393 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16394
16395 static inline int pmd_large(pmd_t pte)
16396 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16397 return pte_clear_flags(pte, _PAGE_RW);
16398 }
16399
16400 +static inline pte_t pte_mkread(pte_t pte)
16401 +{
16402 + return __pte(pte_val(pte) | _PAGE_USER);
16403 +}
16404 +
16405 static inline pte_t pte_mkexec(pte_t pte)
16406 {
16407 - return pte_clear_flags(pte, _PAGE_NX);
16408 +#ifdef CONFIG_X86_PAE
16409 + if (__supported_pte_mask & _PAGE_NX)
16410 + return pte_clear_flags(pte, _PAGE_NX);
16411 + else
16412 +#endif
16413 + return pte_set_flags(pte, _PAGE_USER);
16414 +}
16415 +
16416 +static inline pte_t pte_exprotect(pte_t pte)
16417 +{
16418 +#ifdef CONFIG_X86_PAE
16419 + if (__supported_pte_mask & _PAGE_NX)
16420 + return pte_set_flags(pte, _PAGE_NX);
16421 + else
16422 +#endif
16423 + return pte_clear_flags(pte, _PAGE_USER);
16424 }
16425
16426 static inline pte_t pte_mkdirty(pte_t pte)
16427 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16428 #endif
16429
16430 #ifndef __ASSEMBLY__
16431 +
16432 +#ifdef CONFIG_PAX_PER_CPU_PGD
16433 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16434 +enum cpu_pgd_type {kernel = 0, user = 1};
16435 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16436 +{
16437 + return cpu_pgd[cpu][type];
16438 +}
16439 +#endif
16440 +
16441 #include <linux/mm_types.h>
16442 #include <linux/mmdebug.h>
16443 #include <linux/log2.h>
16444 @@ -563,7 +638,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16445 * Currently stuck as a macro due to indirect forward reference to
16446 * linux/mmzone.h's __section_mem_map_addr() definition:
16447 */
16448 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16449 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16450
16451 /* Find an entry in the second-level page table.. */
16452 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16453 @@ -603,7 +678,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16454 * Currently stuck as a macro due to indirect forward reference to
16455 * linux/mmzone.h's __section_mem_map_addr() definition:
16456 */
16457 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16458 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16459
16460 /* to find an entry in a page-table-directory. */
16461 static inline unsigned long pud_index(unsigned long address)
16462 @@ -618,7 +693,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16463
16464 static inline int pgd_bad(pgd_t pgd)
16465 {
16466 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16467 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16468 }
16469
16470 static inline int pgd_none(pgd_t pgd)
16471 @@ -641,7 +716,12 @@ static inline int pgd_none(pgd_t pgd)
16472 * pgd_offset() returns a (pgd_t *)
16473 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16474 */
16475 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16476 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16477 +
16478 +#ifdef CONFIG_PAX_PER_CPU_PGD
16479 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16480 +#endif
16481 +
16482 /*
16483 * a shortcut which implies the use of the kernel's pgd, instead
16484 * of a process's
16485 @@ -652,6 +732,23 @@ static inline int pgd_none(pgd_t pgd)
16486 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16487 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16488
16489 +#ifdef CONFIG_X86_32
16490 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16491 +#else
16492 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16493 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16494 +
16495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16496 +#ifdef __ASSEMBLY__
16497 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16498 +#else
16499 +extern unsigned long pax_user_shadow_base;
16500 +extern pgdval_t clone_pgd_mask;
16501 +#endif
16502 +#endif
16503 +
16504 +#endif
16505 +
16506 #ifndef __ASSEMBLY__
16507
16508 extern int direct_gbpages;
16509 @@ -818,11 +915,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16510 * dst and src can be on the same page, but the range must not overlap,
16511 * and must not cross a page boundary.
16512 */
16513 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16514 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16515 {
16516 - memcpy(dst, src, count * sizeof(pgd_t));
16517 + pax_open_kernel();
16518 + while (count--)
16519 + *dst++ = *src++;
16520 + pax_close_kernel();
16521 }
16522
16523 +#ifdef CONFIG_PAX_PER_CPU_PGD
16524 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16525 +#endif
16526 +
16527 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16528 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16529 +#else
16530 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16531 +#endif
16532 +
16533 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16534 static inline int page_level_shift(enum pg_level level)
16535 {
16536 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16537 index 9ee3221..b979c6b 100644
16538 --- a/arch/x86/include/asm/pgtable_32.h
16539 +++ b/arch/x86/include/asm/pgtable_32.h
16540 @@ -25,9 +25,6 @@
16541 struct mm_struct;
16542 struct vm_area_struct;
16543
16544 -extern pgd_t swapper_pg_dir[1024];
16545 -extern pgd_t initial_page_table[1024];
16546 -
16547 static inline void pgtable_cache_init(void) { }
16548 static inline void check_pgt_cache(void) { }
16549 void paging_init(void);
16550 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16551 # include <asm/pgtable-2level.h>
16552 #endif
16553
16554 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16555 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16556 +#ifdef CONFIG_X86_PAE
16557 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16558 +#endif
16559 +
16560 #if defined(CONFIG_HIGHPTE)
16561 #define pte_offset_map(dir, address) \
16562 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16563 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16564 /* Clear a kernel PTE and flush it from the TLB */
16565 #define kpte_clear_flush(ptep, vaddr) \
16566 do { \
16567 + pax_open_kernel(); \
16568 pte_clear(&init_mm, (vaddr), (ptep)); \
16569 + pax_close_kernel(); \
16570 __flush_tlb_one((vaddr)); \
16571 } while (0)
16572
16573 #endif /* !__ASSEMBLY__ */
16574
16575 +#define HAVE_ARCH_UNMAPPED_AREA
16576 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16577 +
16578 /*
16579 * kern_addr_valid() is (1) for FLATMEM and (0) for
16580 * SPARSEMEM and DISCONTIGMEM
16581 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16582 index ed5903b..c7fe163 100644
16583 --- a/arch/x86/include/asm/pgtable_32_types.h
16584 +++ b/arch/x86/include/asm/pgtable_32_types.h
16585 @@ -8,7 +8,7 @@
16586 */
16587 #ifdef CONFIG_X86_PAE
16588 # include <asm/pgtable-3level_types.h>
16589 -# define PMD_SIZE (1UL << PMD_SHIFT)
16590 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16591 # define PMD_MASK (~(PMD_SIZE - 1))
16592 #else
16593 # include <asm/pgtable-2level_types.h>
16594 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16595 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16596 #endif
16597
16598 +#ifdef CONFIG_PAX_KERNEXEC
16599 +#ifndef __ASSEMBLY__
16600 +extern unsigned char MODULES_EXEC_VADDR[];
16601 +extern unsigned char MODULES_EXEC_END[];
16602 +#endif
16603 +#include <asm/boot.h>
16604 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16605 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16606 +#else
16607 +#define ktla_ktva(addr) (addr)
16608 +#define ktva_ktla(addr) (addr)
16609 +#endif
16610 +
16611 #define MODULES_VADDR VMALLOC_START
16612 #define MODULES_END VMALLOC_END
16613 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16614 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16615 index e22c1db..23a625a 100644
16616 --- a/arch/x86/include/asm/pgtable_64.h
16617 +++ b/arch/x86/include/asm/pgtable_64.h
16618 @@ -16,10 +16,14 @@
16619
16620 extern pud_t level3_kernel_pgt[512];
16621 extern pud_t level3_ident_pgt[512];
16622 +extern pud_t level3_vmalloc_start_pgt[512];
16623 +extern pud_t level3_vmalloc_end_pgt[512];
16624 +extern pud_t level3_vmemmap_pgt[512];
16625 +extern pud_t level2_vmemmap_pgt[512];
16626 extern pmd_t level2_kernel_pgt[512];
16627 extern pmd_t level2_fixmap_pgt[512];
16628 -extern pmd_t level2_ident_pgt[512];
16629 -extern pgd_t init_level4_pgt[];
16630 +extern pmd_t level2_ident_pgt[512*2];
16631 +extern pgd_t init_level4_pgt[512];
16632
16633 #define swapper_pg_dir init_level4_pgt
16634
16635 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16636
16637 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16638 {
16639 + pax_open_kernel();
16640 *pmdp = pmd;
16641 + pax_close_kernel();
16642 }
16643
16644 static inline void native_pmd_clear(pmd_t *pmd)
16645 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16646
16647 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16648 {
16649 + pax_open_kernel();
16650 *pudp = pud;
16651 + pax_close_kernel();
16652 }
16653
16654 static inline void native_pud_clear(pud_t *pud)
16655 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16656
16657 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16658 {
16659 + pax_open_kernel();
16660 + *pgdp = pgd;
16661 + pax_close_kernel();
16662 +}
16663 +
16664 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16665 +{
16666 *pgdp = pgd;
16667 }
16668
16669 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16670 index 2d88344..4679fc3 100644
16671 --- a/arch/x86/include/asm/pgtable_64_types.h
16672 +++ b/arch/x86/include/asm/pgtable_64_types.h
16673 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16674 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16675 #define MODULES_END _AC(0xffffffffff000000, UL)
16676 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16677 +#define MODULES_EXEC_VADDR MODULES_VADDR
16678 +#define MODULES_EXEC_END MODULES_END
16679 +
16680 +#define ktla_ktva(addr) (addr)
16681 +#define ktva_ktla(addr) (addr)
16682
16683 #define EARLY_DYNAMIC_PAGE_TABLES 64
16684
16685 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16686 index 0ecac25..306c276 100644
16687 --- a/arch/x86/include/asm/pgtable_types.h
16688 +++ b/arch/x86/include/asm/pgtable_types.h
16689 @@ -16,13 +16,12 @@
16690 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16691 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16692 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16693 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16694 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16695 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16696 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16697 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16698 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16699 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16700 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16701 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16702 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16703 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16704
16705 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16706 @@ -40,7 +39,6 @@
16707 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16708 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16709 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16710 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16711 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16712 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16713 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16714 @@ -87,8 +85,10 @@
16715
16716 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16717 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16718 -#else
16719 +#elif defined(CONFIG_KMEMCHECK)
16720 #define _PAGE_NX (_AT(pteval_t, 0))
16721 +#else
16722 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16723 #endif
16724
16725 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16726 @@ -146,6 +146,9 @@
16727 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16728 _PAGE_ACCESSED)
16729
16730 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16731 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16732 +
16733 #define __PAGE_KERNEL_EXEC \
16734 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16735 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16736 @@ -156,7 +159,7 @@
16737 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16738 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16739 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16740 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16741 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16742 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16743 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16744 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16745 @@ -218,8 +221,8 @@
16746 * bits are combined, this will alow user to access the high address mapped
16747 * VDSO in the presence of CONFIG_COMPAT_VDSO
16748 */
16749 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16750 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16751 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16752 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16753 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16754 #endif
16755
16756 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16757 {
16758 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16759 }
16760 +#endif
16761
16762 +#if PAGETABLE_LEVELS == 3
16763 +#include <asm-generic/pgtable-nopud.h>
16764 +#endif
16765 +
16766 +#if PAGETABLE_LEVELS == 2
16767 +#include <asm-generic/pgtable-nopmd.h>
16768 +#endif
16769 +
16770 +#ifndef __ASSEMBLY__
16771 #if PAGETABLE_LEVELS > 3
16772 typedef struct { pudval_t pud; } pud_t;
16773
16774 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16775 return pud.pud;
16776 }
16777 #else
16778 -#include <asm-generic/pgtable-nopud.h>
16779 -
16780 static inline pudval_t native_pud_val(pud_t pud)
16781 {
16782 return native_pgd_val(pud.pgd);
16783 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16784 return pmd.pmd;
16785 }
16786 #else
16787 -#include <asm-generic/pgtable-nopmd.h>
16788 -
16789 static inline pmdval_t native_pmd_val(pmd_t pmd)
16790 {
16791 return native_pgd_val(pmd.pud.pgd);
16792 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
16793
16794 extern pteval_t __supported_pte_mask;
16795 extern void set_nx(void);
16796 -extern int nx_enabled;
16797
16798 #define pgprot_writecombine pgprot_writecombine
16799 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16800 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16801 index 987c75e..2723054 100644
16802 --- a/arch/x86/include/asm/processor.h
16803 +++ b/arch/x86/include/asm/processor.h
16804 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16805 : "memory");
16806 }
16807
16808 +/* invpcid (%rdx),%rax */
16809 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16810 +
16811 +#define INVPCID_SINGLE_ADDRESS 0UL
16812 +#define INVPCID_SINGLE_CONTEXT 1UL
16813 +#define INVPCID_ALL_GLOBAL 2UL
16814 +#define INVPCID_ALL_MONGLOBAL 3UL
16815 +
16816 +#define PCID_KERNEL 0UL
16817 +#define PCID_USER 1UL
16818 +#define PCID_NOFLUSH (1UL << 63)
16819 +
16820 static inline void load_cr3(pgd_t *pgdir)
16821 {
16822 - write_cr3(__pa(pgdir));
16823 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16824 }
16825
16826 #ifdef CONFIG_X86_32
16827 @@ -283,7 +295,7 @@ struct tss_struct {
16828
16829 } ____cacheline_aligned;
16830
16831 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16832 +extern struct tss_struct init_tss[NR_CPUS];
16833
16834 /*
16835 * Save the original ist values for checking stack pointers during debugging
16836 @@ -453,6 +465,7 @@ struct thread_struct {
16837 unsigned short ds;
16838 unsigned short fsindex;
16839 unsigned short gsindex;
16840 + unsigned short ss;
16841 #endif
16842 #ifdef CONFIG_X86_32
16843 unsigned long ip;
16844 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16845 extern unsigned long mmu_cr4_features;
16846 extern u32 *trampoline_cr4_features;
16847
16848 -static inline void set_in_cr4(unsigned long mask)
16849 -{
16850 - unsigned long cr4;
16851 -
16852 - mmu_cr4_features |= mask;
16853 - if (trampoline_cr4_features)
16854 - *trampoline_cr4_features = mmu_cr4_features;
16855 - cr4 = read_cr4();
16856 - cr4 |= mask;
16857 - write_cr4(cr4);
16858 -}
16859 -
16860 -static inline void clear_in_cr4(unsigned long mask)
16861 -{
16862 - unsigned long cr4;
16863 -
16864 - mmu_cr4_features &= ~mask;
16865 - if (trampoline_cr4_features)
16866 - *trampoline_cr4_features = mmu_cr4_features;
16867 - cr4 = read_cr4();
16868 - cr4 &= ~mask;
16869 - write_cr4(cr4);
16870 -}
16871 +extern void set_in_cr4(unsigned long mask);
16872 +extern void clear_in_cr4(unsigned long mask);
16873
16874 typedef struct {
16875 unsigned long seg;
16876 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16877 */
16878 #define TASK_SIZE PAGE_OFFSET
16879 #define TASK_SIZE_MAX TASK_SIZE
16880 +
16881 +#ifdef CONFIG_PAX_SEGMEXEC
16882 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16883 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16884 +#else
16885 #define STACK_TOP TASK_SIZE
16886 -#define STACK_TOP_MAX STACK_TOP
16887 +#endif
16888 +
16889 +#define STACK_TOP_MAX TASK_SIZE
16890
16891 #define INIT_THREAD { \
16892 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16893 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16894 .vm86_info = NULL, \
16895 .sysenter_cs = __KERNEL_CS, \
16896 .io_bitmap_ptr = NULL, \
16897 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16898 */
16899 #define INIT_TSS { \
16900 .x86_tss = { \
16901 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16902 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16903 .ss0 = __KERNEL_DS, \
16904 .ss1 = __KERNEL_CS, \
16905 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16906 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16907 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16908
16909 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16910 -#define KSTK_TOP(info) \
16911 -({ \
16912 - unsigned long *__ptr = (unsigned long *)(info); \
16913 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16914 -})
16915 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16916
16917 /*
16918 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16919 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16920 #define task_pt_regs(task) \
16921 ({ \
16922 struct pt_regs *__regs__; \
16923 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16924 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16925 __regs__ - 1; \
16926 })
16927
16928 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16929 /*
16930 * User space process size. 47bits minus one guard page.
16931 */
16932 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16933 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16934
16935 /* This decides where the kernel will search for a free chunk of vm
16936 * space during mmap's.
16937 */
16938 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16939 - 0xc0000000 : 0xFFFFe000)
16940 + 0xc0000000 : 0xFFFFf000)
16941
16942 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16943 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16944 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16945 #define STACK_TOP_MAX TASK_SIZE_MAX
16946
16947 #define INIT_THREAD { \
16948 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16949 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16950 }
16951
16952 #define INIT_TSS { \
16953 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16954 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16955 }
16956
16957 /*
16958 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16959 */
16960 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16961
16962 +#ifdef CONFIG_PAX_SEGMEXEC
16963 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16964 +#endif
16965 +
16966 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16967
16968 /* Get/set a process' ability to use the timestamp counter instruction */
16969 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
16970 return 0;
16971 }
16972
16973 -extern unsigned long arch_align_stack(unsigned long sp);
16974 +#define arch_align_stack(x) ((x) & ~0xfUL)
16975 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16976
16977 void default_idle(void);
16978 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
16979 #define xen_set_default_idle 0
16980 #endif
16981
16982 -void stop_this_cpu(void *dummy);
16983 +void stop_this_cpu(void *dummy) __noreturn;
16984 void df_debug(struct pt_regs *regs, long error_code);
16985 #endif /* _ASM_X86_PROCESSOR_H */
16986 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16987 index 942a086..6c26446 100644
16988 --- a/arch/x86/include/asm/ptrace.h
16989 +++ b/arch/x86/include/asm/ptrace.h
16990 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16991 }
16992
16993 /*
16994 - * user_mode_vm(regs) determines whether a register set came from user mode.
16995 + * user_mode(regs) determines whether a register set came from user mode.
16996 * This is true if V8086 mode was enabled OR if the register set was from
16997 * protected mode with RPL-3 CS value. This tricky test checks that with
16998 * one comparison. Many places in the kernel can bypass this full check
16999 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17000 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17001 + * be used.
17002 */
17003 -static inline int user_mode(struct pt_regs *regs)
17004 +static inline int user_mode_novm(struct pt_regs *regs)
17005 {
17006 #ifdef CONFIG_X86_32
17007 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17008 #else
17009 - return !!(regs->cs & 3);
17010 + return !!(regs->cs & SEGMENT_RPL_MASK);
17011 #endif
17012 }
17013
17014 -static inline int user_mode_vm(struct pt_regs *regs)
17015 +static inline int user_mode(struct pt_regs *regs)
17016 {
17017 #ifdef CONFIG_X86_32
17018 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17019 USER_RPL;
17020 #else
17021 - return user_mode(regs);
17022 + return user_mode_novm(regs);
17023 #endif
17024 }
17025
17026 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17027 #ifdef CONFIG_X86_64
17028 static inline bool user_64bit_mode(struct pt_regs *regs)
17029 {
17030 + unsigned long cs = regs->cs & 0xffff;
17031 #ifndef CONFIG_PARAVIRT
17032 /*
17033 * On non-paravirt systems, this is the only long mode CPL 3
17034 * selector. We do not allow long mode selectors in the LDT.
17035 */
17036 - return regs->cs == __USER_CS;
17037 + return cs == __USER_CS;
17038 #else
17039 /* Headers are too twisted for this to go in paravirt.h. */
17040 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17041 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17042 #endif
17043 }
17044
17045 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17046 * Traps from the kernel do not save sp and ss.
17047 * Use the helper function to retrieve sp.
17048 */
17049 - if (offset == offsetof(struct pt_regs, sp) &&
17050 - regs->cs == __KERNEL_CS)
17051 - return kernel_stack_pointer(regs);
17052 + if (offset == offsetof(struct pt_regs, sp)) {
17053 + unsigned long cs = regs->cs & 0xffff;
17054 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17055 + return kernel_stack_pointer(regs);
17056 + }
17057 #endif
17058 return *(unsigned long *)((unsigned long)regs + offset);
17059 }
17060 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17061 index 9c6b890..5305f53 100644
17062 --- a/arch/x86/include/asm/realmode.h
17063 +++ b/arch/x86/include/asm/realmode.h
17064 @@ -22,16 +22,14 @@ struct real_mode_header {
17065 #endif
17066 /* APM/BIOS reboot */
17067 u32 machine_real_restart_asm;
17068 -#ifdef CONFIG_X86_64
17069 u32 machine_real_restart_seg;
17070 -#endif
17071 };
17072
17073 /* This must match data at trampoline_32/64.S */
17074 struct trampoline_header {
17075 #ifdef CONFIG_X86_32
17076 u32 start;
17077 - u16 gdt_pad;
17078 + u16 boot_cs;
17079 u16 gdt_limit;
17080 u32 gdt_base;
17081 #else
17082 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17083 index a82c4f1..ac45053 100644
17084 --- a/arch/x86/include/asm/reboot.h
17085 +++ b/arch/x86/include/asm/reboot.h
17086 @@ -6,13 +6,13 @@
17087 struct pt_regs;
17088
17089 struct machine_ops {
17090 - void (*restart)(char *cmd);
17091 - void (*halt)(void);
17092 - void (*power_off)(void);
17093 + void (* __noreturn restart)(char *cmd);
17094 + void (* __noreturn halt)(void);
17095 + void (* __noreturn power_off)(void);
17096 void (*shutdown)(void);
17097 void (*crash_shutdown)(struct pt_regs *);
17098 - void (*emergency_restart)(void);
17099 -};
17100 + void (* __noreturn emergency_restart)(void);
17101 +} __no_const;
17102
17103 extern struct machine_ops machine_ops;
17104
17105 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17106 index cad82c9..2e5c5c1 100644
17107 --- a/arch/x86/include/asm/rwsem.h
17108 +++ b/arch/x86/include/asm/rwsem.h
17109 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17110 {
17111 asm volatile("# beginning down_read\n\t"
17112 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17113 +
17114 +#ifdef CONFIG_PAX_REFCOUNT
17115 + "jno 0f\n"
17116 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17117 + "int $4\n0:\n"
17118 + _ASM_EXTABLE(0b, 0b)
17119 +#endif
17120 +
17121 /* adds 0x00000001 */
17122 " jns 1f\n"
17123 " call call_rwsem_down_read_failed\n"
17124 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17125 "1:\n\t"
17126 " mov %1,%2\n\t"
17127 " add %3,%2\n\t"
17128 +
17129 +#ifdef CONFIG_PAX_REFCOUNT
17130 + "jno 0f\n"
17131 + "sub %3,%2\n"
17132 + "int $4\n0:\n"
17133 + _ASM_EXTABLE(0b, 0b)
17134 +#endif
17135 +
17136 " jle 2f\n\t"
17137 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17138 " jnz 1b\n\t"
17139 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17140 long tmp;
17141 asm volatile("# beginning down_write\n\t"
17142 LOCK_PREFIX " xadd %1,(%2)\n\t"
17143 +
17144 +#ifdef CONFIG_PAX_REFCOUNT
17145 + "jno 0f\n"
17146 + "mov %1,(%2)\n"
17147 + "int $4\n0:\n"
17148 + _ASM_EXTABLE(0b, 0b)
17149 +#endif
17150 +
17151 /* adds 0xffff0001, returns the old value */
17152 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17153 /* was the active mask 0 before? */
17154 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17155 long tmp;
17156 asm volatile("# beginning __up_read\n\t"
17157 LOCK_PREFIX " xadd %1,(%2)\n\t"
17158 +
17159 +#ifdef CONFIG_PAX_REFCOUNT
17160 + "jno 0f\n"
17161 + "mov %1,(%2)\n"
17162 + "int $4\n0:\n"
17163 + _ASM_EXTABLE(0b, 0b)
17164 +#endif
17165 +
17166 /* subtracts 1, returns the old value */
17167 " jns 1f\n\t"
17168 " call call_rwsem_wake\n" /* expects old value in %edx */
17169 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17170 long tmp;
17171 asm volatile("# beginning __up_write\n\t"
17172 LOCK_PREFIX " xadd %1,(%2)\n\t"
17173 +
17174 +#ifdef CONFIG_PAX_REFCOUNT
17175 + "jno 0f\n"
17176 + "mov %1,(%2)\n"
17177 + "int $4\n0:\n"
17178 + _ASM_EXTABLE(0b, 0b)
17179 +#endif
17180 +
17181 /* subtracts 0xffff0001, returns the old value */
17182 " jns 1f\n\t"
17183 " call call_rwsem_wake\n" /* expects old value in %edx */
17184 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17185 {
17186 asm volatile("# beginning __downgrade_write\n\t"
17187 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17188 +
17189 +#ifdef CONFIG_PAX_REFCOUNT
17190 + "jno 0f\n"
17191 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17192 + "int $4\n0:\n"
17193 + _ASM_EXTABLE(0b, 0b)
17194 +#endif
17195 +
17196 /*
17197 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17198 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17199 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17200 */
17201 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17202 {
17203 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17204 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17205 +
17206 +#ifdef CONFIG_PAX_REFCOUNT
17207 + "jno 0f\n"
17208 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17209 + "int $4\n0:\n"
17210 + _ASM_EXTABLE(0b, 0b)
17211 +#endif
17212 +
17213 : "+m" (sem->count)
17214 : "er" (delta));
17215 }
17216 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17217 */
17218 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17219 {
17220 - return delta + xadd(&sem->count, delta);
17221 + return delta + xadd_check_overflow(&sem->count, delta);
17222 }
17223
17224 #endif /* __KERNEL__ */
17225 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17226 index c48a950..bc40804 100644
17227 --- a/arch/x86/include/asm/segment.h
17228 +++ b/arch/x86/include/asm/segment.h
17229 @@ -64,10 +64,15 @@
17230 * 26 - ESPFIX small SS
17231 * 27 - per-cpu [ offset to per-cpu data area ]
17232 * 28 - stack_canary-20 [ for stack protector ]
17233 - * 29 - unused
17234 - * 30 - unused
17235 + * 29 - PCI BIOS CS
17236 + * 30 - PCI BIOS DS
17237 * 31 - TSS for double fault handler
17238 */
17239 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17240 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17241 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17242 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17243 +
17244 #define GDT_ENTRY_TLS_MIN 6
17245 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17246
17247 @@ -79,6 +84,8 @@
17248
17249 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17250
17251 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17252 +
17253 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17254
17255 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17256 @@ -104,6 +111,12 @@
17257 #define __KERNEL_STACK_CANARY 0
17258 #endif
17259
17260 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17261 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17262 +
17263 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17264 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17265 +
17266 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17267
17268 /*
17269 @@ -141,7 +154,7 @@
17270 */
17271
17272 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17273 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17274 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17275
17276
17277 #else
17278 @@ -165,6 +178,8 @@
17279 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17280 #define __USER32_DS __USER_DS
17281
17282 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17283 +
17284 #define GDT_ENTRY_TSS 8 /* needs two entries */
17285 #define GDT_ENTRY_LDT 10 /* needs two entries */
17286 #define GDT_ENTRY_TLS_MIN 12
17287 @@ -173,6 +188,8 @@
17288 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17289 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17290
17291 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17292 +
17293 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17294 #define FS_TLS 0
17295 #define GS_TLS 1
17296 @@ -180,12 +197,14 @@
17297 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17298 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17299
17300 -#define GDT_ENTRIES 16
17301 +#define GDT_ENTRIES 17
17302
17303 #endif
17304
17305 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17306 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17307 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17308 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17309 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17310 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17311 #ifndef CONFIG_PARAVIRT
17312 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17313 {
17314 unsigned long __limit;
17315 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17316 - return __limit + 1;
17317 + return __limit;
17318 }
17319
17320 #endif /* !__ASSEMBLY__ */
17321 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17322 index 8d3120f..352b440 100644
17323 --- a/arch/x86/include/asm/smap.h
17324 +++ b/arch/x86/include/asm/smap.h
17325 @@ -25,11 +25,40 @@
17326
17327 #include <asm/alternative-asm.h>
17328
17329 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17330 +#define ASM_PAX_OPEN_USERLAND \
17331 + 661: jmp 663f; \
17332 + .pushsection .altinstr_replacement, "a" ; \
17333 + 662: pushq %rax; nop; \
17334 + .popsection ; \
17335 + .pushsection .altinstructions, "a" ; \
17336 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17337 + .popsection ; \
17338 + call __pax_open_userland; \
17339 + popq %rax; \
17340 + 663:
17341 +
17342 +#define ASM_PAX_CLOSE_USERLAND \
17343 + 661: jmp 663f; \
17344 + .pushsection .altinstr_replacement, "a" ; \
17345 + 662: pushq %rax; nop; \
17346 + .popsection; \
17347 + .pushsection .altinstructions, "a" ; \
17348 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17349 + .popsection; \
17350 + call __pax_close_userland; \
17351 + popq %rax; \
17352 + 663:
17353 +#else
17354 +#define ASM_PAX_OPEN_USERLAND
17355 +#define ASM_PAX_CLOSE_USERLAND
17356 +#endif
17357 +
17358 #ifdef CONFIG_X86_SMAP
17359
17360 #define ASM_CLAC \
17361 661: ASM_NOP3 ; \
17362 - .pushsection .altinstr_replacement, "ax" ; \
17363 + .pushsection .altinstr_replacement, "a" ; \
17364 662: __ASM_CLAC ; \
17365 .popsection ; \
17366 .pushsection .altinstructions, "a" ; \
17367 @@ -38,7 +67,7 @@
17368
17369 #define ASM_STAC \
17370 661: ASM_NOP3 ; \
17371 - .pushsection .altinstr_replacement, "ax" ; \
17372 + .pushsection .altinstr_replacement, "a" ; \
17373 662: __ASM_STAC ; \
17374 .popsection ; \
17375 .pushsection .altinstructions, "a" ; \
17376 @@ -56,6 +85,37 @@
17377
17378 #include <asm/alternative.h>
17379
17380 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17381 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17382 +
17383 +extern void __pax_open_userland(void);
17384 +static __always_inline unsigned long pax_open_userland(void)
17385 +{
17386 +
17387 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17388 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17389 + :
17390 + : [open] "i" (__pax_open_userland)
17391 + : "memory", "rax");
17392 +#endif
17393 +
17394 + return 0;
17395 +}
17396 +
17397 +extern void __pax_close_userland(void);
17398 +static __always_inline unsigned long pax_close_userland(void)
17399 +{
17400 +
17401 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17402 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17403 + :
17404 + : [close] "i" (__pax_close_userland)
17405 + : "memory", "rax");
17406 +#endif
17407 +
17408 + return 0;
17409 +}
17410 +
17411 #ifdef CONFIG_X86_SMAP
17412
17413 static __always_inline void clac(void)
17414 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17415 index 4137890..03fa172 100644
17416 --- a/arch/x86/include/asm/smp.h
17417 +++ b/arch/x86/include/asm/smp.h
17418 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17419 /* cpus sharing the last level cache: */
17420 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17421 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17422 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17423 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17424
17425 static inline struct cpumask *cpu_sibling_mask(int cpu)
17426 {
17427 @@ -79,7 +79,7 @@ struct smp_ops {
17428
17429 void (*send_call_func_ipi)(const struct cpumask *mask);
17430 void (*send_call_func_single_ipi)(int cpu);
17431 -};
17432 +} __no_const;
17433
17434 /* Globals due to paravirt */
17435 extern void set_cpu_sibling_map(int cpu);
17436 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17437 extern int safe_smp_processor_id(void);
17438
17439 #elif defined(CONFIG_X86_64_SMP)
17440 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17441 -
17442 -#define stack_smp_processor_id() \
17443 -({ \
17444 - struct thread_info *ti; \
17445 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17446 - ti->cpu; \
17447 -})
17448 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17449 +#define stack_smp_processor_id() raw_smp_processor_id()
17450 #define safe_smp_processor_id() smp_processor_id()
17451
17452 #endif
17453 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17454 index bf156de..1a782ab 100644
17455 --- a/arch/x86/include/asm/spinlock.h
17456 +++ b/arch/x86/include/asm/spinlock.h
17457 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17458 static inline void arch_read_lock(arch_rwlock_t *rw)
17459 {
17460 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17461 +
17462 +#ifdef CONFIG_PAX_REFCOUNT
17463 + "jno 0f\n"
17464 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17465 + "int $4\n0:\n"
17466 + _ASM_EXTABLE(0b, 0b)
17467 +#endif
17468 +
17469 "jns 1f\n"
17470 "call __read_lock_failed\n\t"
17471 "1:\n"
17472 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17473 static inline void arch_write_lock(arch_rwlock_t *rw)
17474 {
17475 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17476 +
17477 +#ifdef CONFIG_PAX_REFCOUNT
17478 + "jno 0f\n"
17479 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17480 + "int $4\n0:\n"
17481 + _ASM_EXTABLE(0b, 0b)
17482 +#endif
17483 +
17484 "jz 1f\n"
17485 "call __write_lock_failed\n\t"
17486 "1:\n"
17487 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17488
17489 static inline void arch_read_unlock(arch_rwlock_t *rw)
17490 {
17491 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17492 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17493 +
17494 +#ifdef CONFIG_PAX_REFCOUNT
17495 + "jno 0f\n"
17496 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17497 + "int $4\n0:\n"
17498 + _ASM_EXTABLE(0b, 0b)
17499 +#endif
17500 +
17501 :"+m" (rw->lock) : : "memory");
17502 }
17503
17504 static inline void arch_write_unlock(arch_rwlock_t *rw)
17505 {
17506 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17507 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17508 +
17509 +#ifdef CONFIG_PAX_REFCOUNT
17510 + "jno 0f\n"
17511 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17512 + "int $4\n0:\n"
17513 + _ASM_EXTABLE(0b, 0b)
17514 +#endif
17515 +
17516 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17517 }
17518
17519 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17520 index 6a99859..03cb807 100644
17521 --- a/arch/x86/include/asm/stackprotector.h
17522 +++ b/arch/x86/include/asm/stackprotector.h
17523 @@ -47,7 +47,7 @@
17524 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17525 */
17526 #define GDT_STACK_CANARY_INIT \
17527 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17528 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17529
17530 /*
17531 * Initialize the stackprotector canary value.
17532 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17533
17534 static inline void load_stack_canary_segment(void)
17535 {
17536 -#ifdef CONFIG_X86_32
17537 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17538 asm volatile ("mov %0, %%gs" : : "r" (0));
17539 #endif
17540 }
17541 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17542 index 70bbe39..4ae2bd4 100644
17543 --- a/arch/x86/include/asm/stacktrace.h
17544 +++ b/arch/x86/include/asm/stacktrace.h
17545 @@ -11,28 +11,20 @@
17546
17547 extern int kstack_depth_to_print;
17548
17549 -struct thread_info;
17550 +struct task_struct;
17551 struct stacktrace_ops;
17552
17553 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17554 - unsigned long *stack,
17555 - unsigned long bp,
17556 - const struct stacktrace_ops *ops,
17557 - void *data,
17558 - unsigned long *end,
17559 - int *graph);
17560 +typedef unsigned long walk_stack_t(struct task_struct *task,
17561 + void *stack_start,
17562 + unsigned long *stack,
17563 + unsigned long bp,
17564 + const struct stacktrace_ops *ops,
17565 + void *data,
17566 + unsigned long *end,
17567 + int *graph);
17568
17569 -extern unsigned long
17570 -print_context_stack(struct thread_info *tinfo,
17571 - unsigned long *stack, unsigned long bp,
17572 - const struct stacktrace_ops *ops, void *data,
17573 - unsigned long *end, int *graph);
17574 -
17575 -extern unsigned long
17576 -print_context_stack_bp(struct thread_info *tinfo,
17577 - unsigned long *stack, unsigned long bp,
17578 - const struct stacktrace_ops *ops, void *data,
17579 - unsigned long *end, int *graph);
17580 +extern walk_stack_t print_context_stack;
17581 +extern walk_stack_t print_context_stack_bp;
17582
17583 /* Generic stack tracer with callbacks */
17584
17585 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17586 void (*address)(void *data, unsigned long address, int reliable);
17587 /* On negative return stop dumping */
17588 int (*stack)(void *data, char *name);
17589 - walk_stack_t walk_stack;
17590 + walk_stack_t *walk_stack;
17591 };
17592
17593 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17594 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17595 index d7f3b3b..3cc39f1 100644
17596 --- a/arch/x86/include/asm/switch_to.h
17597 +++ b/arch/x86/include/asm/switch_to.h
17598 @@ -108,7 +108,7 @@ do { \
17599 "call __switch_to\n\t" \
17600 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17601 __switch_canary \
17602 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17603 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17604 "movq %%rax,%%rdi\n\t" \
17605 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17606 "jnz ret_from_fork\n\t" \
17607 @@ -119,7 +119,7 @@ do { \
17608 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17609 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17610 [_tif_fork] "i" (_TIF_FORK), \
17611 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17612 + [thread_info] "m" (current_tinfo), \
17613 [current_task] "m" (current_task) \
17614 __switch_canary_iparam \
17615 : "memory", "cc" __EXTRA_CLOBBER)
17616 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17617 index 2781119..618b59b 100644
17618 --- a/arch/x86/include/asm/thread_info.h
17619 +++ b/arch/x86/include/asm/thread_info.h
17620 @@ -10,6 +10,7 @@
17621 #include <linux/compiler.h>
17622 #include <asm/page.h>
17623 #include <asm/types.h>
17624 +#include <asm/percpu.h>
17625
17626 /*
17627 * low level task data that entry.S needs immediate access to
17628 @@ -23,7 +24,6 @@ struct exec_domain;
17629 #include <linux/atomic.h>
17630
17631 struct thread_info {
17632 - struct task_struct *task; /* main task structure */
17633 struct exec_domain *exec_domain; /* execution domain */
17634 __u32 flags; /* low level flags */
17635 __u32 status; /* thread synchronous flags */
17636 @@ -33,19 +33,13 @@ struct thread_info {
17637 mm_segment_t addr_limit;
17638 struct restart_block restart_block;
17639 void __user *sysenter_return;
17640 -#ifdef CONFIG_X86_32
17641 - unsigned long previous_esp; /* ESP of the previous stack in
17642 - case of nested (IRQ) stacks
17643 - */
17644 - __u8 supervisor_stack[0];
17645 -#endif
17646 + unsigned long lowest_stack;
17647 unsigned int sig_on_uaccess_error:1;
17648 unsigned int uaccess_err:1; /* uaccess failed */
17649 };
17650
17651 -#define INIT_THREAD_INFO(tsk) \
17652 +#define INIT_THREAD_INFO \
17653 { \
17654 - .task = &tsk, \
17655 .exec_domain = &default_exec_domain, \
17656 .flags = 0, \
17657 .cpu = 0, \
17658 @@ -56,7 +50,7 @@ struct thread_info {
17659 }, \
17660 }
17661
17662 -#define init_thread_info (init_thread_union.thread_info)
17663 +#define init_thread_info (init_thread_union.stack)
17664 #define init_stack (init_thread_union.stack)
17665
17666 #else /* !__ASSEMBLY__ */
17667 @@ -96,6 +90,7 @@ struct thread_info {
17668 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17669 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17670 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17671 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17672
17673 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17674 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17675 @@ -119,17 +114,18 @@ struct thread_info {
17676 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17677 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17678 #define _TIF_X32 (1 << TIF_X32)
17679 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17680
17681 /* work to do in syscall_trace_enter() */
17682 #define _TIF_WORK_SYSCALL_ENTRY \
17683 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17684 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17685 - _TIF_NOHZ)
17686 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17687
17688 /* work to do in syscall_trace_leave() */
17689 #define _TIF_WORK_SYSCALL_EXIT \
17690 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17691 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17692 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17693
17694 /* work to do on interrupt/exception return */
17695 #define _TIF_WORK_MASK \
17696 @@ -140,7 +136,7 @@ struct thread_info {
17697 /* work to do on any return to user space */
17698 #define _TIF_ALLWORK_MASK \
17699 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17700 - _TIF_NOHZ)
17701 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17702
17703 /* Only used for 64 bit */
17704 #define _TIF_DO_NOTIFY_MASK \
17705 @@ -156,45 +152,40 @@ struct thread_info {
17706
17707 #define PREEMPT_ACTIVE 0x10000000
17708
17709 -#ifdef CONFIG_X86_32
17710 -
17711 -#define STACK_WARN (THREAD_SIZE/8)
17712 -/*
17713 - * macros/functions for gaining access to the thread information structure
17714 - *
17715 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17716 - */
17717 -#ifndef __ASSEMBLY__
17718 -
17719 -
17720 -/* how to get the current stack pointer from C */
17721 -register unsigned long current_stack_pointer asm("esp") __used;
17722 -
17723 -/* how to get the thread information struct from C */
17724 -static inline struct thread_info *current_thread_info(void)
17725 -{
17726 - return (struct thread_info *)
17727 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17728 -}
17729 -
17730 -#else /* !__ASSEMBLY__ */
17731 -
17732 +#ifdef __ASSEMBLY__
17733 /* how to get the thread information struct from ASM */
17734 #define GET_THREAD_INFO(reg) \
17735 - movl $-THREAD_SIZE, reg; \
17736 - andl %esp, reg
17737 + mov PER_CPU_VAR(current_tinfo), reg
17738
17739 /* use this one if reg already contains %esp */
17740 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17741 - andl $-THREAD_SIZE, reg
17742 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17743 +#else
17744 +/* how to get the thread information struct from C */
17745 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17746 +
17747 +static __always_inline struct thread_info *current_thread_info(void)
17748 +{
17749 + return this_cpu_read_stable(current_tinfo);
17750 +}
17751 +#endif
17752 +
17753 +#ifdef CONFIG_X86_32
17754 +
17755 +#define STACK_WARN (THREAD_SIZE/8)
17756 +/*
17757 + * macros/functions for gaining access to the thread information structure
17758 + *
17759 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17760 + */
17761 +#ifndef __ASSEMBLY__
17762 +
17763 +/* how to get the current stack pointer from C */
17764 +register unsigned long current_stack_pointer asm("esp") __used;
17765
17766 #endif
17767
17768 #else /* X86_32 */
17769
17770 -#include <asm/percpu.h>
17771 -#define KERNEL_STACK_OFFSET (5*8)
17772 -
17773 /*
17774 * macros/functions for gaining access to the thread information structure
17775 * preempt_count needs to be 1 initially, until the scheduler is functional.
17776 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17777 #ifndef __ASSEMBLY__
17778 DECLARE_PER_CPU(unsigned long, kernel_stack);
17779
17780 -static inline struct thread_info *current_thread_info(void)
17781 -{
17782 - struct thread_info *ti;
17783 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17784 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17785 - return ti;
17786 -}
17787 -
17788 -#else /* !__ASSEMBLY__ */
17789 -
17790 -/* how to get the thread information struct from ASM */
17791 -#define GET_THREAD_INFO(reg) \
17792 - movq PER_CPU_VAR(kernel_stack),reg ; \
17793 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17794 -
17795 -/*
17796 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17797 - * a certain register (to be used in assembler memory operands).
17798 - */
17799 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17800 -
17801 +/* how to get the current stack pointer from C */
17802 +register unsigned long current_stack_pointer asm("rsp") __used;
17803 #endif
17804
17805 #endif /* !X86_32 */
17806 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17807 extern void arch_task_cache_init(void);
17808 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17809 extern void arch_release_task_struct(struct task_struct *tsk);
17810 +
17811 +#define __HAVE_THREAD_FUNCTIONS
17812 +#define task_thread_info(task) (&(task)->tinfo)
17813 +#define task_stack_page(task) ((task)->stack)
17814 +#define setup_thread_stack(p, org) do {} while (0)
17815 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17816 +
17817 #endif
17818 #endif /* _ASM_X86_THREAD_INFO_H */
17819 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17820 index e6d90ba..0897f44 100644
17821 --- a/arch/x86/include/asm/tlbflush.h
17822 +++ b/arch/x86/include/asm/tlbflush.h
17823 @@ -17,18 +17,44 @@
17824
17825 static inline void __native_flush_tlb(void)
17826 {
17827 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17828 + u64 descriptor[2];
17829 +
17830 + descriptor[0] = PCID_KERNEL;
17831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17832 + return;
17833 + }
17834 +
17835 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17836 + if (static_cpu_has(X86_FEATURE_PCID)) {
17837 + unsigned int cpu = raw_get_cpu();
17838 +
17839 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17840 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17841 + raw_put_cpu_no_resched();
17842 + return;
17843 + }
17844 +#endif
17845 +
17846 native_write_cr3(native_read_cr3());
17847 }
17848
17849 static inline void __native_flush_tlb_global_irq_disabled(void)
17850 {
17851 - unsigned long cr4;
17852 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17853 + u64 descriptor[2];
17854
17855 - cr4 = native_read_cr4();
17856 - /* clear PGE */
17857 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17858 - /* write old PGE again and flush TLBs */
17859 - native_write_cr4(cr4);
17860 + descriptor[0] = PCID_KERNEL;
17861 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17862 + } else {
17863 + unsigned long cr4;
17864 +
17865 + cr4 = native_read_cr4();
17866 + /* clear PGE */
17867 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17868 + /* write old PGE again and flush TLBs */
17869 + native_write_cr4(cr4);
17870 + }
17871 }
17872
17873 static inline void __native_flush_tlb_global(void)
17874 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17875
17876 static inline void __native_flush_tlb_single(unsigned long addr)
17877 {
17878 +
17879 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17880 + u64 descriptor[2];
17881 +
17882 + descriptor[0] = PCID_KERNEL;
17883 + descriptor[1] = addr;
17884 +
17885 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17886 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17887 + if (addr < TASK_SIZE_MAX)
17888 + descriptor[1] += pax_user_shadow_base;
17889 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17890 + }
17891 +
17892 + descriptor[0] = PCID_USER;
17893 + descriptor[1] = addr;
17894 +#endif
17895 +
17896 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17897 + return;
17898 + }
17899 +
17900 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17901 + if (static_cpu_has(X86_FEATURE_PCID)) {
17902 + unsigned int cpu = raw_get_cpu();
17903 +
17904 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17905 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17906 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17907 + raw_put_cpu_no_resched();
17908 +
17909 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17910 + addr += pax_user_shadow_base;
17911 + }
17912 +#endif
17913 +
17914 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17915 }
17916
17917 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17918 index 5838fa9..f7ae572 100644
17919 --- a/arch/x86/include/asm/uaccess.h
17920 +++ b/arch/x86/include/asm/uaccess.h
17921 @@ -7,6 +7,7 @@
17922 #include <linux/compiler.h>
17923 #include <linux/thread_info.h>
17924 #include <linux/string.h>
17925 +#include <linux/sched.h>
17926 #include <asm/asm.h>
17927 #include <asm/page.h>
17928 #include <asm/smap.h>
17929 @@ -29,7 +30,12 @@
17930
17931 #define get_ds() (KERNEL_DS)
17932 #define get_fs() (current_thread_info()->addr_limit)
17933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17934 +void __set_fs(mm_segment_t x);
17935 +void set_fs(mm_segment_t x);
17936 +#else
17937 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17938 +#endif
17939
17940 #define segment_eq(a, b) ((a).seg == (b).seg)
17941
17942 @@ -77,8 +83,33 @@
17943 * checks that the pointer is in the user space range - after calling
17944 * this function, memory access functions may still return -EFAULT.
17945 */
17946 -#define access_ok(type, addr, size) \
17947 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17948 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17949 +#define access_ok(type, addr, size) \
17950 +({ \
17951 + long __size = size; \
17952 + unsigned long __addr = (unsigned long)addr; \
17953 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17954 + unsigned long __end_ao = __addr + __size - 1; \
17955 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17956 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17957 + while(__addr_ao <= __end_ao) { \
17958 + char __c_ao; \
17959 + __addr_ao += PAGE_SIZE; \
17960 + if (__size > PAGE_SIZE) \
17961 + cond_resched(); \
17962 + if (__get_user(__c_ao, (char __user *)__addr)) \
17963 + break; \
17964 + if (type != VERIFY_WRITE) { \
17965 + __addr = __addr_ao; \
17966 + continue; \
17967 + } \
17968 + if (__put_user(__c_ao, (char __user *)__addr)) \
17969 + break; \
17970 + __addr = __addr_ao; \
17971 + } \
17972 + } \
17973 + __ret_ao; \
17974 +})
17975
17976 /*
17977 * The exception table consists of pairs of addresses relative to the
17978 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17979 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
17980 __chk_user_ptr(ptr); \
17981 might_fault(); \
17982 + pax_open_userland(); \
17983 asm volatile("call __get_user_%P3" \
17984 : "=a" (__ret_gu), "=r" (__val_gu) \
17985 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17986 (x) = (__typeof__(*(ptr))) __val_gu; \
17987 + pax_close_userland(); \
17988 __ret_gu; \
17989 })
17990
17991 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17992 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17993 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17994
17995 -
17996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17997 +#define __copyuser_seg "gs;"
17998 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17999 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18000 +#else
18001 +#define __copyuser_seg
18002 +#define __COPYUSER_SET_ES
18003 +#define __COPYUSER_RESTORE_ES
18004 +#endif
18005
18006 #ifdef CONFIG_X86_32
18007 #define __put_user_asm_u64(x, addr, err, errret) \
18008 asm volatile(ASM_STAC "\n" \
18009 - "1: movl %%eax,0(%2)\n" \
18010 - "2: movl %%edx,4(%2)\n" \
18011 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18012 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18013 "3: " ASM_CLAC "\n" \
18014 ".section .fixup,\"ax\"\n" \
18015 "4: movl %3,%0\n" \
18016 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18017
18018 #define __put_user_asm_ex_u64(x, addr) \
18019 asm volatile(ASM_STAC "\n" \
18020 - "1: movl %%eax,0(%1)\n" \
18021 - "2: movl %%edx,4(%1)\n" \
18022 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18023 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18024 "3: " ASM_CLAC "\n" \
18025 _ASM_EXTABLE_EX(1b, 2b) \
18026 _ASM_EXTABLE_EX(2b, 3b) \
18027 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18028 __typeof__(*(ptr)) __pu_val; \
18029 __chk_user_ptr(ptr); \
18030 might_fault(); \
18031 - __pu_val = x; \
18032 + __pu_val = (x); \
18033 + pax_open_userland(); \
18034 switch (sizeof(*(ptr))) { \
18035 case 1: \
18036 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18037 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18038 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18039 break; \
18040 } \
18041 + pax_close_userland(); \
18042 __ret_pu; \
18043 })
18044
18045 @@ -347,8 +390,10 @@ do { \
18046 } while (0)
18047
18048 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18049 +do { \
18050 + pax_open_userland(); \
18051 asm volatile(ASM_STAC "\n" \
18052 - "1: mov"itype" %2,%"rtype"1\n" \
18053 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18054 "2: " ASM_CLAC "\n" \
18055 ".section .fixup,\"ax\"\n" \
18056 "3: mov %3,%0\n" \
18057 @@ -356,8 +401,10 @@ do { \
18058 " jmp 2b\n" \
18059 ".previous\n" \
18060 _ASM_EXTABLE(1b, 3b) \
18061 - : "=r" (err), ltype(x) \
18062 - : "m" (__m(addr)), "i" (errret), "0" (err))
18063 + : "=r" (err), ltype (x) \
18064 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18065 + pax_close_userland(); \
18066 +} while (0)
18067
18068 #define __get_user_size_ex(x, ptr, size) \
18069 do { \
18070 @@ -381,7 +428,7 @@ do { \
18071 } while (0)
18072
18073 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18074 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18075 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18076 "2:\n" \
18077 _ASM_EXTABLE_EX(1b, 2b) \
18078 : ltype(x) : "m" (__m(addr)))
18079 @@ -398,13 +445,24 @@ do { \
18080 int __gu_err; \
18081 unsigned long __gu_val; \
18082 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18083 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18084 + (x) = (__typeof__(*(ptr)))__gu_val; \
18085 __gu_err; \
18086 })
18087
18088 /* FIXME: this hack is definitely wrong -AK */
18089 struct __large_struct { unsigned long buf[100]; };
18090 -#define __m(x) (*(struct __large_struct __user *)(x))
18091 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18092 +#define ____m(x) \
18093 +({ \
18094 + unsigned long ____x = (unsigned long)(x); \
18095 + if (____x < pax_user_shadow_base) \
18096 + ____x += pax_user_shadow_base; \
18097 + (typeof(x))____x; \
18098 +})
18099 +#else
18100 +#define ____m(x) (x)
18101 +#endif
18102 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18103
18104 /*
18105 * Tell gcc we read from memory instead of writing: this is because
18106 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18107 * aliasing issues.
18108 */
18109 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18110 +do { \
18111 + pax_open_userland(); \
18112 asm volatile(ASM_STAC "\n" \
18113 - "1: mov"itype" %"rtype"1,%2\n" \
18114 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18115 "2: " ASM_CLAC "\n" \
18116 ".section .fixup,\"ax\"\n" \
18117 "3: mov %3,%0\n" \
18118 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18119 ".previous\n" \
18120 _ASM_EXTABLE(1b, 3b) \
18121 : "=r"(err) \
18122 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18123 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18124 + pax_close_userland(); \
18125 +} while (0)
18126
18127 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18128 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18129 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18130 "2:\n" \
18131 _ASM_EXTABLE_EX(1b, 2b) \
18132 : : ltype(x), "m" (__m(addr)))
18133 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18134 */
18135 #define uaccess_try do { \
18136 current_thread_info()->uaccess_err = 0; \
18137 + pax_open_userland(); \
18138 stac(); \
18139 barrier();
18140
18141 #define uaccess_catch(err) \
18142 clac(); \
18143 + pax_close_userland(); \
18144 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18145 } while (0)
18146
18147 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18148 * On error, the variable @x is set to zero.
18149 */
18150
18151 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18152 +#define __get_user(x, ptr) get_user((x), (ptr))
18153 +#else
18154 #define __get_user(x, ptr) \
18155 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18156 +#endif
18157
18158 /**
18159 * __put_user: - Write a simple value into user space, with less checking.
18160 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18161 * Returns zero on success, or -EFAULT on error.
18162 */
18163
18164 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18165 +#define __put_user(x, ptr) put_user((x), (ptr))
18166 +#else
18167 #define __put_user(x, ptr) \
18168 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18169 +#endif
18170
18171 #define __get_user_unaligned __get_user
18172 #define __put_user_unaligned __put_user
18173 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18174 #define get_user_ex(x, ptr) do { \
18175 unsigned long __gue_val; \
18176 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18177 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18178 + (x) = (__typeof__(*(ptr)))__gue_val; \
18179 } while (0)
18180
18181 #define put_user_try uaccess_try
18182 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18183 index 7f760a9..b596b9a 100644
18184 --- a/arch/x86/include/asm/uaccess_32.h
18185 +++ b/arch/x86/include/asm/uaccess_32.h
18186 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18187 static __always_inline unsigned long __must_check
18188 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18189 {
18190 + if ((long)n < 0)
18191 + return n;
18192 +
18193 + check_object_size(from, n, true);
18194 +
18195 if (__builtin_constant_p(n)) {
18196 unsigned long ret;
18197
18198 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18199 __copy_to_user(void __user *to, const void *from, unsigned long n)
18200 {
18201 might_fault();
18202 +
18203 return __copy_to_user_inatomic(to, from, n);
18204 }
18205
18206 static __always_inline unsigned long
18207 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18208 {
18209 + if ((long)n < 0)
18210 + return n;
18211 +
18212 /* Avoid zeroing the tail if the copy fails..
18213 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18214 * but as the zeroing behaviour is only significant when n is not
18215 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18216 __copy_from_user(void *to, const void __user *from, unsigned long n)
18217 {
18218 might_fault();
18219 +
18220 + if ((long)n < 0)
18221 + return n;
18222 +
18223 + check_object_size(to, n, false);
18224 +
18225 if (__builtin_constant_p(n)) {
18226 unsigned long ret;
18227
18228 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18229 const void __user *from, unsigned long n)
18230 {
18231 might_fault();
18232 +
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 if (__builtin_constant_p(n)) {
18237 unsigned long ret;
18238
18239 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18240 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18241 unsigned long n)
18242 {
18243 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18244 + if ((long)n < 0)
18245 + return n;
18246 +
18247 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18248 }
18249
18250 -unsigned long __must_check copy_to_user(void __user *to,
18251 - const void *from, unsigned long n);
18252 -unsigned long __must_check _copy_from_user(void *to,
18253 - const void __user *from,
18254 - unsigned long n);
18255 -
18256 +extern void copy_to_user_overflow(void)
18257 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18258 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18259 +#else
18260 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18261 +#endif
18262 +;
18263
18264 extern void copy_from_user_overflow(void)
18265 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18267 #endif
18268 ;
18269
18270 -static inline unsigned long __must_check copy_from_user(void *to,
18271 - const void __user *from,
18272 - unsigned long n)
18273 +/**
18274 + * copy_to_user: - Copy a block of data into user space.
18275 + * @to: Destination address, in user space.
18276 + * @from: Source address, in kernel space.
18277 + * @n: Number of bytes to copy.
18278 + *
18279 + * Context: User context only. This function may sleep.
18280 + *
18281 + * Copy data from kernel space to user space.
18282 + *
18283 + * Returns number of bytes that could not be copied.
18284 + * On success, this will be zero.
18285 + */
18286 +static inline unsigned long __must_check
18287 +copy_to_user(void __user *to, const void *from, unsigned long n)
18288 {
18289 - int sz = __compiletime_object_size(to);
18290 + size_t sz = __compiletime_object_size(from);
18291
18292 - if (likely(sz == -1 || sz >= n))
18293 - n = _copy_from_user(to, from, n);
18294 - else
18295 + if (unlikely(sz != (size_t)-1 && sz < n))
18296 + copy_to_user_overflow();
18297 + else if (access_ok(VERIFY_WRITE, to, n))
18298 + n = __copy_to_user(to, from, n);
18299 + return n;
18300 +}
18301 +
18302 +/**
18303 + * copy_from_user: - Copy a block of data from user space.
18304 + * @to: Destination address, in kernel space.
18305 + * @from: Source address, in user space.
18306 + * @n: Number of bytes to copy.
18307 + *
18308 + * Context: User context only. This function may sleep.
18309 + *
18310 + * Copy data from user space to kernel space.
18311 + *
18312 + * Returns number of bytes that could not be copied.
18313 + * On success, this will be zero.
18314 + *
18315 + * If some data could not be copied, this function will pad the copied
18316 + * data to the requested size using zero bytes.
18317 + */
18318 +static inline unsigned long __must_check
18319 +copy_from_user(void *to, const void __user *from, unsigned long n)
18320 +{
18321 + size_t sz = __compiletime_object_size(to);
18322 +
18323 + check_object_size(to, n, false);
18324 +
18325 + if (unlikely(sz != (size_t)-1 && sz < n))
18326 copy_from_user_overflow();
18327 -
18328 + else if (access_ok(VERIFY_READ, from, n))
18329 + n = __copy_from_user(to, from, n);
18330 + else if ((long)n > 0)
18331 + memset(to, 0, n);
18332 return n;
18333 }
18334
18335 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18336 index 4f7923d..201b58d 100644
18337 --- a/arch/x86/include/asm/uaccess_64.h
18338 +++ b/arch/x86/include/asm/uaccess_64.h
18339 @@ -10,6 +10,9 @@
18340 #include <asm/alternative.h>
18341 #include <asm/cpufeature.h>
18342 #include <asm/page.h>
18343 +#include <asm/pgtable.h>
18344 +
18345 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18346
18347 /*
18348 * Copy To/From Userspace
18349 @@ -17,14 +20,14 @@
18350
18351 /* Handles exceptions in both to and from, but doesn't do access_ok */
18352 __must_check unsigned long
18353 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18354 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18355 __must_check unsigned long
18356 -copy_user_generic_string(void *to, const void *from, unsigned len);
18357 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18358 __must_check unsigned long
18359 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18360 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18361
18362 -static __always_inline __must_check unsigned long
18363 -copy_user_generic(void *to, const void *from, unsigned len)
18364 +static __always_inline __must_check unsigned long
18365 +copy_user_generic(void *to, const void *from, unsigned long len)
18366 {
18367 unsigned ret;
18368
18369 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18370 return ret;
18371 }
18372
18373 +static __always_inline __must_check unsigned long
18374 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18375 +static __always_inline __must_check unsigned long
18376 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18377 __must_check unsigned long
18378 -_copy_to_user(void __user *to, const void *from, unsigned len);
18379 -__must_check unsigned long
18380 -_copy_from_user(void *to, const void __user *from, unsigned len);
18381 -__must_check unsigned long
18382 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18383 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18384 +
18385 +extern void copy_to_user_overflow(void)
18386 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18387 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18388 +#else
18389 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18390 +#endif
18391 +;
18392 +
18393 +extern void copy_from_user_overflow(void)
18394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18395 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18396 +#else
18397 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18398 +#endif
18399 +;
18400
18401 static inline unsigned long __must_check copy_from_user(void *to,
18402 const void __user *from,
18403 unsigned long n)
18404 {
18405 - int sz = __compiletime_object_size(to);
18406 -
18407 might_fault();
18408 - if (likely(sz == -1 || sz >= n))
18409 - n = _copy_from_user(to, from, n);
18410 -#ifdef CONFIG_DEBUG_VM
18411 - else
18412 - WARN(1, "Buffer overflow detected!\n");
18413 -#endif
18414 +
18415 + check_object_size(to, n, false);
18416 +
18417 + if (access_ok(VERIFY_READ, from, n))
18418 + n = __copy_from_user(to, from, n);
18419 + else if (n < INT_MAX)
18420 + memset(to, 0, n);
18421 return n;
18422 }
18423
18424 static __always_inline __must_check
18425 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18426 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18427 {
18428 might_fault();
18429
18430 - return _copy_to_user(dst, src, size);
18431 + if (access_ok(VERIFY_WRITE, dst, size))
18432 + size = __copy_to_user(dst, src, size);
18433 + return size;
18434 }
18435
18436 static __always_inline __must_check
18437 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18438 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18439 {
18440 - int ret = 0;
18441 + size_t sz = __compiletime_object_size(dst);
18442 + unsigned ret = 0;
18443
18444 might_fault();
18445 +
18446 + if (size > INT_MAX)
18447 + return size;
18448 +
18449 + check_object_size(dst, size, false);
18450 +
18451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18452 + if (!__access_ok(VERIFY_READ, src, size))
18453 + return size;
18454 +#endif
18455 +
18456 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18457 + copy_from_user_overflow();
18458 + return size;
18459 + }
18460 +
18461 if (!__builtin_constant_p(size))
18462 - return copy_user_generic(dst, (__force void *)src, size);
18463 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18464 switch (size) {
18465 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18466 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18467 ret, "b", "b", "=q", 1);
18468 return ret;
18469 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18470 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18471 ret, "w", "w", "=r", 2);
18472 return ret;
18473 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18474 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18475 ret, "l", "k", "=r", 4);
18476 return ret;
18477 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18478 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18479 ret, "q", "", "=r", 8);
18480 return ret;
18481 case 10:
18482 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18483 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18484 ret, "q", "", "=r", 10);
18485 if (unlikely(ret))
18486 return ret;
18487 __get_user_asm(*(u16 *)(8 + (char *)dst),
18488 - (u16 __user *)(8 + (char __user *)src),
18489 + (const u16 __user *)(8 + (const char __user *)src),
18490 ret, "w", "w", "=r", 2);
18491 return ret;
18492 case 16:
18493 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18494 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18495 ret, "q", "", "=r", 16);
18496 if (unlikely(ret))
18497 return ret;
18498 __get_user_asm(*(u64 *)(8 + (char *)dst),
18499 - (u64 __user *)(8 + (char __user *)src),
18500 + (const u64 __user *)(8 + (const char __user *)src),
18501 ret, "q", "", "=r", 8);
18502 return ret;
18503 default:
18504 - return copy_user_generic(dst, (__force void *)src, size);
18505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18506 }
18507 }
18508
18509 static __always_inline __must_check
18510 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18511 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18512 {
18513 - int ret = 0;
18514 + size_t sz = __compiletime_object_size(src);
18515 + unsigned ret = 0;
18516
18517 might_fault();
18518 +
18519 + if (size > INT_MAX)
18520 + return size;
18521 +
18522 + check_object_size(src, size, true);
18523 +
18524 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18525 + if (!__access_ok(VERIFY_WRITE, dst, size))
18526 + return size;
18527 +#endif
18528 +
18529 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18530 + copy_to_user_overflow();
18531 + return size;
18532 + }
18533 +
18534 if (!__builtin_constant_p(size))
18535 - return copy_user_generic((__force void *)dst, src, size);
18536 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18537 switch (size) {
18538 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18539 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18540 ret, "b", "b", "iq", 1);
18541 return ret;
18542 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18543 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18544 ret, "w", "w", "ir", 2);
18545 return ret;
18546 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18547 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18548 ret, "l", "k", "ir", 4);
18549 return ret;
18550 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18551 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18552 ret, "q", "", "er", 8);
18553 return ret;
18554 case 10:
18555 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18556 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18557 ret, "q", "", "er", 10);
18558 if (unlikely(ret))
18559 return ret;
18560 asm("":::"memory");
18561 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18562 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18563 ret, "w", "w", "ir", 2);
18564 return ret;
18565 case 16:
18566 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18567 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18568 ret, "q", "", "er", 16);
18569 if (unlikely(ret))
18570 return ret;
18571 asm("":::"memory");
18572 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18573 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18574 ret, "q", "", "er", 8);
18575 return ret;
18576 default:
18577 - return copy_user_generic((__force void *)dst, src, size);
18578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18579 }
18580 }
18581
18582 static __always_inline __must_check
18583 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18584 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18585 {
18586 - int ret = 0;
18587 + unsigned ret = 0;
18588
18589 might_fault();
18590 +
18591 + if (size > INT_MAX)
18592 + return size;
18593 +
18594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18595 + if (!__access_ok(VERIFY_READ, src, size))
18596 + return size;
18597 + if (!__access_ok(VERIFY_WRITE, dst, size))
18598 + return size;
18599 +#endif
18600 +
18601 if (!__builtin_constant_p(size))
18602 - return copy_user_generic((__force void *)dst,
18603 - (__force void *)src, size);
18604 + return copy_user_generic((__force_kernel void *)____m(dst),
18605 + (__force_kernel const void *)____m(src), size);
18606 switch (size) {
18607 case 1: {
18608 u8 tmp;
18609 - __get_user_asm(tmp, (u8 __user *)src,
18610 + __get_user_asm(tmp, (const u8 __user *)src,
18611 ret, "b", "b", "=q", 1);
18612 if (likely(!ret))
18613 __put_user_asm(tmp, (u8 __user *)dst,
18614 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18615 }
18616 case 2: {
18617 u16 tmp;
18618 - __get_user_asm(tmp, (u16 __user *)src,
18619 + __get_user_asm(tmp, (const u16 __user *)src,
18620 ret, "w", "w", "=r", 2);
18621 if (likely(!ret))
18622 __put_user_asm(tmp, (u16 __user *)dst,
18623 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18624
18625 case 4: {
18626 u32 tmp;
18627 - __get_user_asm(tmp, (u32 __user *)src,
18628 + __get_user_asm(tmp, (const u32 __user *)src,
18629 ret, "l", "k", "=r", 4);
18630 if (likely(!ret))
18631 __put_user_asm(tmp, (u32 __user *)dst,
18632 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18633 }
18634 case 8: {
18635 u64 tmp;
18636 - __get_user_asm(tmp, (u64 __user *)src,
18637 + __get_user_asm(tmp, (const u64 __user *)src,
18638 ret, "q", "", "=r", 8);
18639 if (likely(!ret))
18640 __put_user_asm(tmp, (u64 __user *)dst,
18641 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18642 return ret;
18643 }
18644 default:
18645 - return copy_user_generic((__force void *)dst,
18646 - (__force void *)src, size);
18647 + return copy_user_generic((__force_kernel void *)____m(dst),
18648 + (__force_kernel const void *)____m(src), size);
18649 }
18650 }
18651
18652 -static __must_check __always_inline int
18653 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18654 +static __must_check __always_inline unsigned long
18655 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18656 {
18657 - return copy_user_generic(dst, (__force const void *)src, size);
18658 + if (size > INT_MAX)
18659 + return size;
18660 +
18661 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18662 + if (!__access_ok(VERIFY_READ, src, size))
18663 + return size;
18664 +#endif
18665 +
18666 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18667 }
18668
18669 -static __must_check __always_inline int
18670 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18671 +static __must_check __always_inline unsigned long
18672 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18673 {
18674 - return copy_user_generic((__force void *)dst, src, size);
18675 + if (size > INT_MAX)
18676 + return size;
18677 +
18678 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18679 + if (!__access_ok(VERIFY_WRITE, dst, size))
18680 + return size;
18681 +#endif
18682 +
18683 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18684 }
18685
18686 -extern long __copy_user_nocache(void *dst, const void __user *src,
18687 - unsigned size, int zerorest);
18688 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18689 + unsigned long size, int zerorest);
18690
18691 -static inline int
18692 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18693 +static inline unsigned long
18694 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18695 {
18696 might_fault();
18697 +
18698 + if (size > INT_MAX)
18699 + return size;
18700 +
18701 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18702 + if (!__access_ok(VERIFY_READ, src, size))
18703 + return size;
18704 +#endif
18705 +
18706 return __copy_user_nocache(dst, src, size, 1);
18707 }
18708
18709 -static inline int
18710 +static inline unsigned long
18711 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18712 - unsigned size)
18713 + unsigned long size)
18714 {
18715 + if (size > INT_MAX)
18716 + return size;
18717 +
18718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18719 + if (!__access_ok(VERIFY_READ, src, size))
18720 + return size;
18721 +#endif
18722 +
18723 return __copy_user_nocache(dst, src, size, 0);
18724 }
18725
18726 unsigned long
18727 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18728 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18729
18730 #endif /* _ASM_X86_UACCESS_64_H */
18731 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18732 index 5b238981..77fdd78 100644
18733 --- a/arch/x86/include/asm/word-at-a-time.h
18734 +++ b/arch/x86/include/asm/word-at-a-time.h
18735 @@ -11,7 +11,7 @@
18736 * and shift, for example.
18737 */
18738 struct word_at_a_time {
18739 - const unsigned long one_bits, high_bits;
18740 + unsigned long one_bits, high_bits;
18741 };
18742
18743 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18744 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18745 index 828a156..650e625 100644
18746 --- a/arch/x86/include/asm/x86_init.h
18747 +++ b/arch/x86/include/asm/x86_init.h
18748 @@ -129,7 +129,7 @@ struct x86_init_ops {
18749 struct x86_init_timers timers;
18750 struct x86_init_iommu iommu;
18751 struct x86_init_pci pci;
18752 -};
18753 +} __no_const;
18754
18755 /**
18756 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18757 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18758 void (*setup_percpu_clockev)(void);
18759 void (*early_percpu_clock_init)(void);
18760 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18761 -};
18762 +} __no_const;
18763
18764 struct timespec;
18765
18766 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18767 void (*save_sched_clock_state)(void);
18768 void (*restore_sched_clock_state)(void);
18769 void (*apic_post_init)(void);
18770 -};
18771 +} __no_const;
18772
18773 struct pci_dev;
18774 struct msi_msg;
18775 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18776 void (*teardown_msi_irqs)(struct pci_dev *dev);
18777 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18778 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18779 -};
18780 +} __no_const;
18781
18782 struct IO_APIC_route_entry;
18783 struct io_apic_irq_attr;
18784 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18785 unsigned int destination, int vector,
18786 struct io_apic_irq_attr *attr);
18787 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18788 -};
18789 +} __no_const;
18790
18791 extern struct x86_init_ops x86_init;
18792 extern struct x86_cpuinit_ops x86_cpuinit;
18793 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
18794 index b913915..4f5a581 100644
18795 --- a/arch/x86/include/asm/xen/page.h
18796 +++ b/arch/x86/include/asm/xen/page.h
18797 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
18798 extern struct page *m2p_find_override(unsigned long mfn);
18799 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
18800
18801 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
18802 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
18803 {
18804 unsigned long mfn;
18805
18806 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18807 index 0415cda..3b22adc 100644
18808 --- a/arch/x86/include/asm/xsave.h
18809 +++ b/arch/x86/include/asm/xsave.h
18810 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18811 if (unlikely(err))
18812 return -EFAULT;
18813
18814 + pax_open_userland();
18815 __asm__ __volatile__(ASM_STAC "\n"
18816 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18817 + "1:"
18818 + __copyuser_seg
18819 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18820 "2: " ASM_CLAC "\n"
18821 ".section .fixup,\"ax\"\n"
18822 "3: movl $-1,%[err]\n"
18823 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18824 : [err] "=r" (err)
18825 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18826 : "memory");
18827 + pax_close_userland();
18828 return err;
18829 }
18830
18831 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18832 {
18833 int err;
18834 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18835 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18836 u32 lmask = mask;
18837 u32 hmask = mask >> 32;
18838
18839 + pax_open_userland();
18840 __asm__ __volatile__(ASM_STAC "\n"
18841 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18842 + "1:"
18843 + __copyuser_seg
18844 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18845 "2: " ASM_CLAC "\n"
18846 ".section .fixup,\"ax\"\n"
18847 "3: movl $-1,%[err]\n"
18848 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18849 : [err] "=r" (err)
18850 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18851 : "memory"); /* memory required? */
18852 + pax_close_userland();
18853 return err;
18854 }
18855
18856 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18857 index bbae024..e1528f9 100644
18858 --- a/arch/x86/include/uapi/asm/e820.h
18859 +++ b/arch/x86/include/uapi/asm/e820.h
18860 @@ -63,7 +63,7 @@ struct e820map {
18861 #define ISA_START_ADDRESS 0xa0000
18862 #define ISA_END_ADDRESS 0x100000
18863
18864 -#define BIOS_BEGIN 0x000a0000
18865 +#define BIOS_BEGIN 0x000c0000
18866 #define BIOS_END 0x00100000
18867
18868 #define BIOS_ROM_BASE 0xffe00000
18869 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18870 index a5408b9..5133813 100644
18871 --- a/arch/x86/kernel/Makefile
18872 +++ b/arch/x86/kernel/Makefile
18873 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18874 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18875 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18876 obj-y += probe_roms.o
18877 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18878 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18879 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18880 obj-y += syscall_$(BITS).o
18881 obj-$(CONFIG_X86_64) += vsyscall_64.o
18882 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18883 index 40c7660..f709f4b 100644
18884 --- a/arch/x86/kernel/acpi/boot.c
18885 +++ b/arch/x86/kernel/acpi/boot.c
18886 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18887 * If your system is blacklisted here, but you find that acpi=force
18888 * works for you, please contact linux-acpi@vger.kernel.org
18889 */
18890 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18891 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18892 /*
18893 * Boxes that need ACPI disabled
18894 */
18895 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18896 };
18897
18898 /* second table for DMI checks that should run after early-quirks */
18899 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18900 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18901 /*
18902 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18903 * which includes some code which overrides all temperature
18904 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18905 index 3312010..a65ca7b 100644
18906 --- a/arch/x86/kernel/acpi/sleep.c
18907 +++ b/arch/x86/kernel/acpi/sleep.c
18908 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18909 #else /* CONFIG_64BIT */
18910 #ifdef CONFIG_SMP
18911 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18912 +
18913 + pax_open_kernel();
18914 early_gdt_descr.address =
18915 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18916 + pax_close_kernel();
18917 +
18918 initial_gs = per_cpu_offset(smp_processor_id());
18919 #endif
18920 initial_code = (unsigned long)wakeup_long64;
18921 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18922 index d1daa66..59fecba 100644
18923 --- a/arch/x86/kernel/acpi/wakeup_32.S
18924 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18925 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18926 # and restore the stack ... but you need gdt for this to work
18927 movl saved_context_esp, %esp
18928
18929 - movl %cs:saved_magic, %eax
18930 - cmpl $0x12345678, %eax
18931 + cmpl $0x12345678, saved_magic
18932 jne bogus_magic
18933
18934 # jump to place where we left off
18935 - movl saved_eip, %eax
18936 - jmp *%eax
18937 + jmp *(saved_eip)
18938
18939 bogus_magic:
18940 jmp bogus_magic
18941 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18942 index 15e8563..323cbe1 100644
18943 --- a/arch/x86/kernel/alternative.c
18944 +++ b/arch/x86/kernel/alternative.c
18945 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18946 */
18947 for (a = start; a < end; a++) {
18948 instr = (u8 *)&a->instr_offset + a->instr_offset;
18949 +
18950 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18951 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18952 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18953 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18954 +#endif
18955 +
18956 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18957 BUG_ON(a->replacementlen > a->instrlen);
18958 BUG_ON(a->instrlen > sizeof(insnbuf));
18959 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18960 for (poff = start; poff < end; poff++) {
18961 u8 *ptr = (u8 *)poff + *poff;
18962
18963 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18964 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18965 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18966 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18967 +#endif
18968 +
18969 if (!*poff || ptr < text || ptr >= text_end)
18970 continue;
18971 /* turn DS segment override prefix into lock prefix */
18972 - if (*ptr == 0x3e)
18973 + if (*ktla_ktva(ptr) == 0x3e)
18974 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18975 }
18976 mutex_unlock(&text_mutex);
18977 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18978 for (poff = start; poff < end; poff++) {
18979 u8 *ptr = (u8 *)poff + *poff;
18980
18981 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18982 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18983 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18984 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18985 +#endif
18986 +
18987 if (!*poff || ptr < text || ptr >= text_end)
18988 continue;
18989 /* turn lock prefix into DS segment override prefix */
18990 - if (*ptr == 0xf0)
18991 + if (*ktla_ktva(ptr) == 0xf0)
18992 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18993 }
18994 mutex_unlock(&text_mutex);
18995 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18996
18997 BUG_ON(p->len > MAX_PATCH_LEN);
18998 /* prep the buffer with the original instructions */
18999 - memcpy(insnbuf, p->instr, p->len);
19000 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19001 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19002 (unsigned long)p->instr, p->len);
19003
19004 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19005 if (!uniproc_patched || num_possible_cpus() == 1)
19006 free_init_pages("SMP alternatives",
19007 (unsigned long)__smp_locks,
19008 - (unsigned long)__smp_locks_end);
19009 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19010 #endif
19011
19012 apply_paravirt(__parainstructions, __parainstructions_end);
19013 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19014 * instructions. And on the local CPU you need to be protected again NMI or MCE
19015 * handlers seeing an inconsistent instruction while you patch.
19016 */
19017 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19018 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19019 size_t len)
19020 {
19021 unsigned long flags;
19022 local_irq_save(flags);
19023 - memcpy(addr, opcode, len);
19024 +
19025 + pax_open_kernel();
19026 + memcpy(ktla_ktva(addr), opcode, len);
19027 sync_core();
19028 + pax_close_kernel();
19029 +
19030 local_irq_restore(flags);
19031 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19032 that causes hangs on some VIA CPUs. */
19033 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19034 */
19035 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19036 {
19037 - unsigned long flags;
19038 - char *vaddr;
19039 + unsigned char *vaddr = ktla_ktva(addr);
19040 struct page *pages[2];
19041 - int i;
19042 + size_t i;
19043
19044 if (!core_kernel_text((unsigned long)addr)) {
19045 - pages[0] = vmalloc_to_page(addr);
19046 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19047 + pages[0] = vmalloc_to_page(vaddr);
19048 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19049 } else {
19050 - pages[0] = virt_to_page(addr);
19051 + pages[0] = virt_to_page(vaddr);
19052 WARN_ON(!PageReserved(pages[0]));
19053 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19054 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19055 }
19056 BUG_ON(!pages[0]);
19057 - local_irq_save(flags);
19058 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19059 - if (pages[1])
19060 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19061 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19062 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19063 - clear_fixmap(FIX_TEXT_POKE0);
19064 - if (pages[1])
19065 - clear_fixmap(FIX_TEXT_POKE1);
19066 - local_flush_tlb();
19067 - sync_core();
19068 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19069 - that causes hangs on some VIA CPUs. */
19070 + text_poke_early(addr, opcode, len);
19071 for (i = 0; i < len; i++)
19072 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19073 - local_irq_restore(flags);
19074 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19075 return addr;
19076 }
19077
19078 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19079 if (likely(!bp_patching_in_progress))
19080 return 0;
19081
19082 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19083 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19084 return 0;
19085
19086 /* set up the specified breakpoint handler */
19087 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19088 */
19089 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19090 {
19091 - unsigned char int3 = 0xcc;
19092 + const unsigned char int3 = 0xcc;
19093
19094 bp_int3_handler = handler;
19095 bp_int3_addr = (u8 *)addr + sizeof(int3);
19096 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19097 index a7eb82d..f6e52d4 100644
19098 --- a/arch/x86/kernel/apic/apic.c
19099 +++ b/arch/x86/kernel/apic/apic.c
19100 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19101 /*
19102 * Debug level, exported for io_apic.c
19103 */
19104 -unsigned int apic_verbosity;
19105 +int apic_verbosity;
19106
19107 int pic_mode;
19108
19109 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19110 apic_write(APIC_ESR, 0);
19111 v1 = apic_read(APIC_ESR);
19112 ack_APIC_irq();
19113 - atomic_inc(&irq_err_count);
19114 + atomic_inc_unchecked(&irq_err_count);
19115
19116 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19117 smp_processor_id(), v0 , v1);
19118 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19119 index 00c77cf..2dc6a2d 100644
19120 --- a/arch/x86/kernel/apic/apic_flat_64.c
19121 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19122 @@ -157,7 +157,7 @@ static int flat_probe(void)
19123 return 1;
19124 }
19125
19126 -static struct apic apic_flat = {
19127 +static struct apic apic_flat __read_only = {
19128 .name = "flat",
19129 .probe = flat_probe,
19130 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19131 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19132 return 0;
19133 }
19134
19135 -static struct apic apic_physflat = {
19136 +static struct apic apic_physflat __read_only = {
19137
19138 .name = "physical flat",
19139 .probe = physflat_probe,
19140 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19141 index e145f28..2752888 100644
19142 --- a/arch/x86/kernel/apic/apic_noop.c
19143 +++ b/arch/x86/kernel/apic/apic_noop.c
19144 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19145 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19146 }
19147
19148 -struct apic apic_noop = {
19149 +struct apic apic_noop __read_only = {
19150 .name = "noop",
19151 .probe = noop_probe,
19152 .acpi_madt_oem_check = NULL,
19153 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19154 index d50e364..543bee3 100644
19155 --- a/arch/x86/kernel/apic/bigsmp_32.c
19156 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19157 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19158 return dmi_bigsmp;
19159 }
19160
19161 -static struct apic apic_bigsmp = {
19162 +static struct apic apic_bigsmp __read_only = {
19163
19164 .name = "bigsmp",
19165 .probe = probe_bigsmp,
19166 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19167 index c552247..587a316 100644
19168 --- a/arch/x86/kernel/apic/es7000_32.c
19169 +++ b/arch/x86/kernel/apic/es7000_32.c
19170 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19171 return ret && es7000_apic_is_cluster();
19172 }
19173
19174 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19175 -static struct apic __refdata apic_es7000_cluster = {
19176 +static struct apic apic_es7000_cluster __read_only = {
19177
19178 .name = "es7000",
19179 .probe = probe_es7000,
19180 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19181 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19182 };
19183
19184 -static struct apic __refdata apic_es7000 = {
19185 +static struct apic apic_es7000 __read_only = {
19186
19187 .name = "es7000",
19188 .probe = probe_es7000,
19189 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19190 index e63a5bd..c0babf8 100644
19191 --- a/arch/x86/kernel/apic/io_apic.c
19192 +++ b/arch/x86/kernel/apic/io_apic.c
19193 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19194 }
19195 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19196
19197 -void lock_vector_lock(void)
19198 +void lock_vector_lock(void) __acquires(vector_lock)
19199 {
19200 /* Used to the online set of cpus does not change
19201 * during assign_irq_vector.
19202 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19203 raw_spin_lock(&vector_lock);
19204 }
19205
19206 -void unlock_vector_lock(void)
19207 +void unlock_vector_lock(void) __releases(vector_lock)
19208 {
19209 raw_spin_unlock(&vector_lock);
19210 }
19211 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19212 ack_APIC_irq();
19213 }
19214
19215 -atomic_t irq_mis_count;
19216 +atomic_unchecked_t irq_mis_count;
19217
19218 #ifdef CONFIG_GENERIC_PENDING_IRQ
19219 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19220 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19221 * at the cpu.
19222 */
19223 if (!(v & (1 << (i & 0x1f)))) {
19224 - atomic_inc(&irq_mis_count);
19225 + atomic_inc_unchecked(&irq_mis_count);
19226
19227 eoi_ioapic_irq(irq, cfg);
19228 }
19229 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19230 index 1e42e8f..daacf44 100644
19231 --- a/arch/x86/kernel/apic/numaq_32.c
19232 +++ b/arch/x86/kernel/apic/numaq_32.c
19233 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19234 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19235 }
19236
19237 -/* Use __refdata to keep false positive warning calm. */
19238 -static struct apic __refdata apic_numaq = {
19239 +static struct apic apic_numaq __read_only = {
19240
19241 .name = "NUMAQ",
19242 .probe = probe_numaq,
19243 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19244 index eb35ef9..f184a21 100644
19245 --- a/arch/x86/kernel/apic/probe_32.c
19246 +++ b/arch/x86/kernel/apic/probe_32.c
19247 @@ -72,7 +72,7 @@ static int probe_default(void)
19248 return 1;
19249 }
19250
19251 -static struct apic apic_default = {
19252 +static struct apic apic_default __read_only = {
19253
19254 .name = "default",
19255 .probe = probe_default,
19256 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19257 index 77c95c0..434f8a4 100644
19258 --- a/arch/x86/kernel/apic/summit_32.c
19259 +++ b/arch/x86/kernel/apic/summit_32.c
19260 @@ -486,7 +486,7 @@ void setup_summit(void)
19261 }
19262 #endif
19263
19264 -static struct apic apic_summit = {
19265 +static struct apic apic_summit __read_only = {
19266
19267 .name = "summit",
19268 .probe = probe_summit,
19269 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19270 index 140e29d..d88bc95 100644
19271 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19272 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19273 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19274 return notifier_from_errno(err);
19275 }
19276
19277 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19278 +static struct notifier_block x2apic_cpu_notifier = {
19279 .notifier_call = update_clusterinfo,
19280 };
19281
19282 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19283 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19284 }
19285
19286 -static struct apic apic_x2apic_cluster = {
19287 +static struct apic apic_x2apic_cluster __read_only = {
19288
19289 .name = "cluster x2apic",
19290 .probe = x2apic_cluster_probe,
19291 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19292 index 562a76d..a003c0f 100644
19293 --- a/arch/x86/kernel/apic/x2apic_phys.c
19294 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19295 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19296 return apic == &apic_x2apic_phys;
19297 }
19298
19299 -static struct apic apic_x2apic_phys = {
19300 +static struct apic apic_x2apic_phys __read_only = {
19301
19302 .name = "physical x2apic",
19303 .probe = x2apic_phys_probe,
19304 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19305 index a419814..1dd34a0 100644
19306 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19307 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19308 @@ -357,7 +357,7 @@ static int uv_probe(void)
19309 return apic == &apic_x2apic_uv_x;
19310 }
19311
19312 -static struct apic __refdata apic_x2apic_uv_x = {
19313 +static struct apic apic_x2apic_uv_x __read_only = {
19314
19315 .name = "UV large system",
19316 .probe = uv_probe,
19317 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19318 index 3ab0343..814c4787 100644
19319 --- a/arch/x86/kernel/apm_32.c
19320 +++ b/arch/x86/kernel/apm_32.c
19321 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19322 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19323 * even though they are called in protected mode.
19324 */
19325 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19326 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19327 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19328
19329 static const char driver_version[] = "1.16ac"; /* no spaces */
19330 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19331 BUG_ON(cpu != 0);
19332 gdt = get_cpu_gdt_table(cpu);
19333 save_desc_40 = gdt[0x40 / 8];
19334 +
19335 + pax_open_kernel();
19336 gdt[0x40 / 8] = bad_bios_desc;
19337 + pax_close_kernel();
19338
19339 apm_irq_save(flags);
19340 APM_DO_SAVE_SEGS;
19341 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19342 &call->esi);
19343 APM_DO_RESTORE_SEGS;
19344 apm_irq_restore(flags);
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = save_desc_40;
19348 + pax_close_kernel();
19349 +
19350 put_cpu();
19351
19352 return call->eax & 0xff;
19353 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19354 BUG_ON(cpu != 0);
19355 gdt = get_cpu_gdt_table(cpu);
19356 save_desc_40 = gdt[0x40 / 8];
19357 +
19358 + pax_open_kernel();
19359 gdt[0x40 / 8] = bad_bios_desc;
19360 + pax_close_kernel();
19361
19362 apm_irq_save(flags);
19363 APM_DO_SAVE_SEGS;
19364 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19365 &call->eax);
19366 APM_DO_RESTORE_SEGS;
19367 apm_irq_restore(flags);
19368 +
19369 + pax_open_kernel();
19370 gdt[0x40 / 8] = save_desc_40;
19371 + pax_close_kernel();
19372 +
19373 put_cpu();
19374 return error;
19375 }
19376 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19377 * code to that CPU.
19378 */
19379 gdt = get_cpu_gdt_table(0);
19380 +
19381 + pax_open_kernel();
19382 set_desc_base(&gdt[APM_CS >> 3],
19383 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19384 set_desc_base(&gdt[APM_CS_16 >> 3],
19385 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19386 set_desc_base(&gdt[APM_DS >> 3],
19387 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19388 + pax_close_kernel();
19389
19390 proc_create("apm", 0, NULL, &apm_file_ops);
19391
19392 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19393 index 2861082..6d4718e 100644
19394 --- a/arch/x86/kernel/asm-offsets.c
19395 +++ b/arch/x86/kernel/asm-offsets.c
19396 @@ -33,6 +33,8 @@ void common(void) {
19397 OFFSET(TI_status, thread_info, status);
19398 OFFSET(TI_addr_limit, thread_info, addr_limit);
19399 OFFSET(TI_preempt_count, thread_info, preempt_count);
19400 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19401 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19402
19403 BLANK();
19404 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19405 @@ -53,8 +55,26 @@ void common(void) {
19406 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19407 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19408 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19409 +
19410 +#ifdef CONFIG_PAX_KERNEXEC
19411 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19412 #endif
19413
19414 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19415 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19416 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19417 +#ifdef CONFIG_X86_64
19418 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19419 +#endif
19420 +#endif
19421 +
19422 +#endif
19423 +
19424 + BLANK();
19425 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19426 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19427 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19428 +
19429 #ifdef CONFIG_XEN
19430 BLANK();
19431 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19432 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19433 index e7c798b..2b2019b 100644
19434 --- a/arch/x86/kernel/asm-offsets_64.c
19435 +++ b/arch/x86/kernel/asm-offsets_64.c
19436 @@ -77,6 +77,7 @@ int main(void)
19437 BLANK();
19438 #undef ENTRY
19439
19440 + DEFINE(TSS_size, sizeof(struct tss_struct));
19441 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19442 BLANK();
19443
19444 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19445 index 47b56a7..efc2bc6 100644
19446 --- a/arch/x86/kernel/cpu/Makefile
19447 +++ b/arch/x86/kernel/cpu/Makefile
19448 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19449 CFLAGS_REMOVE_perf_event.o = -pg
19450 endif
19451
19452 -# Make sure load_percpu_segment has no stackprotector
19453 -nostackp := $(call cc-option, -fno-stack-protector)
19454 -CFLAGS_common.o := $(nostackp)
19455 -
19456 obj-y := intel_cacheinfo.o scattered.o topology.o
19457 obj-y += proc.o capflags.o powerflags.o common.o
19458 obj-y += rdrand.o
19459 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19460 index 903a264..fc955f3 100644
19461 --- a/arch/x86/kernel/cpu/amd.c
19462 +++ b/arch/x86/kernel/cpu/amd.c
19463 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19464 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19465 {
19466 /* AMD errata T13 (order #21922) */
19467 - if ((c->x86 == 6)) {
19468 + if (c->x86 == 6) {
19469 /* Duron Rev A0 */
19470 if (c->x86_model == 3 && c->x86_mask == 0)
19471 size = 64;
19472 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19473 index 2793d1f..5c04a30 100644
19474 --- a/arch/x86/kernel/cpu/common.c
19475 +++ b/arch/x86/kernel/cpu/common.c
19476 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19477
19478 static const struct cpu_dev *this_cpu = &default_cpu;
19479
19480 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19481 -#ifdef CONFIG_X86_64
19482 - /*
19483 - * We need valid kernel segments for data and code in long mode too
19484 - * IRET will check the segment types kkeil 2000/10/28
19485 - * Also sysret mandates a special GDT layout
19486 - *
19487 - * TLS descriptors are currently at a different place compared to i386.
19488 - * Hopefully nobody expects them at a fixed place (Wine?)
19489 - */
19490 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19491 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19492 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19493 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19494 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19495 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19496 -#else
19497 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19498 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19499 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19500 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19501 - /*
19502 - * Segments used for calling PnP BIOS have byte granularity.
19503 - * They code segments and data segments have fixed 64k limits,
19504 - * the transfer segment sizes are set at run time.
19505 - */
19506 - /* 32-bit code */
19507 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19508 - /* 16-bit code */
19509 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19510 - /* 16-bit data */
19511 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19512 - /* 16-bit data */
19513 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19514 - /* 16-bit data */
19515 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19516 - /*
19517 - * The APM segments have byte granularity and their bases
19518 - * are set at run time. All have 64k limits.
19519 - */
19520 - /* 32-bit code */
19521 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19522 - /* 16-bit code */
19523 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19524 - /* data */
19525 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19526 -
19527 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19528 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19529 - GDT_STACK_CANARY_INIT
19530 -#endif
19531 -} };
19532 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19533 -
19534 static int __init x86_xsave_setup(char *s)
19535 {
19536 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19537 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19538 set_in_cr4(X86_CR4_SMAP);
19539 }
19540
19541 +#ifdef CONFIG_X86_64
19542 +static __init int setup_disable_pcid(char *arg)
19543 +{
19544 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19545 +
19546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19547 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19548 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19549 +#endif
19550 +
19551 + return 1;
19552 +}
19553 +__setup("nopcid", setup_disable_pcid);
19554 +
19555 +static void setup_pcid(struct cpuinfo_x86 *c)
19556 +{
19557 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19558 +
19559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19560 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19561 + pax_open_kernel();
19562 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19563 + pax_close_kernel();
19564 + printk("PAX: slow and weak UDEREF enabled\n");
19565 + } else
19566 + printk("PAX: UDEREF disabled\n");
19567 +#endif
19568 +
19569 + return;
19570 + }
19571 +
19572 + printk("PAX: PCID detected\n");
19573 + set_in_cr4(X86_CR4_PCIDE);
19574 +
19575 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19576 + pax_open_kernel();
19577 + clone_pgd_mask = ~(pgdval_t)0UL;
19578 + pax_close_kernel();
19579 + if (pax_user_shadow_base)
19580 + printk("PAX: weak UDEREF enabled\n");
19581 + else {
19582 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19583 + printk("PAX: strong UDEREF enabled\n");
19584 + }
19585 +#endif
19586 +
19587 + if (cpu_has(c, X86_FEATURE_INVPCID))
19588 + printk("PAX: INVPCID detected\n");
19589 +}
19590 +#endif
19591 +
19592 /*
19593 * Some CPU features depend on higher CPUID levels, which may not always
19594 * be available due to CPUID level capping or broken virtualization
19595 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19596 {
19597 struct desc_ptr gdt_descr;
19598
19599 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19600 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19601 gdt_descr.size = GDT_SIZE - 1;
19602 load_gdt(&gdt_descr);
19603 /* Reload the per-cpu base */
19604 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19605 setup_smep(c);
19606 setup_smap(c);
19607
19608 +#ifdef CONFIG_X86_64
19609 + setup_pcid(c);
19610 +#endif
19611 +
19612 /*
19613 * The vendor-specific functions might have changed features.
19614 * Now we do "generic changes."
19615 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19616 /* Filter out anything that depends on CPUID levels we don't have */
19617 filter_cpuid_features(c, true);
19618
19619 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19620 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19621 +#endif
19622 +
19623 /* If the model name is still unset, do table lookup. */
19624 if (!c->x86_model_id[0]) {
19625 const char *p;
19626 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19627 }
19628 __setup("clearcpuid=", setup_disablecpuid);
19629
19630 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19631 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19632 +
19633 #ifdef CONFIG_X86_64
19634 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19635 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19636 - (unsigned long) debug_idt_table };
19637 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19638 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19639
19640 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19641 irq_stack_union) __aligned(PAGE_SIZE) __visible;
19642 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19643 EXPORT_PER_CPU_SYMBOL(current_task);
19644
19645 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19646 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19647 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19648 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19649
19650 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19651 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19652 load_ucode_ap();
19653
19654 cpu = stack_smp_processor_id();
19655 - t = &per_cpu(init_tss, cpu);
19656 + t = init_tss + cpu;
19657 oist = &per_cpu(orig_ist, cpu);
19658
19659 #ifdef CONFIG_NUMA
19660 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19661 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19662 barrier();
19663
19664 - x86_configure_nx();
19665 enable_x2apic();
19666
19667 /*
19668 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19669 {
19670 int cpu = smp_processor_id();
19671 struct task_struct *curr = current;
19672 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19673 + struct tss_struct *t = init_tss + cpu;
19674 struct thread_struct *thread = &curr->thread;
19675
19676 show_ucode_info_early();
19677 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19678 index 1414c90..1159406 100644
19679 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19680 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19681 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19682 };
19683
19684 #ifdef CONFIG_AMD_NB
19685 +static struct attribute *default_attrs_amd_nb[] = {
19686 + &type.attr,
19687 + &level.attr,
19688 + &coherency_line_size.attr,
19689 + &physical_line_partition.attr,
19690 + &ways_of_associativity.attr,
19691 + &number_of_sets.attr,
19692 + &size.attr,
19693 + &shared_cpu_map.attr,
19694 + &shared_cpu_list.attr,
19695 + NULL,
19696 + NULL,
19697 + NULL,
19698 + NULL
19699 +};
19700 +
19701 static struct attribute **amd_l3_attrs(void)
19702 {
19703 static struct attribute **attrs;
19704 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19705
19706 n = ARRAY_SIZE(default_attrs);
19707
19708 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19709 - n += 2;
19710 -
19711 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19712 - n += 1;
19713 -
19714 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19715 - if (attrs == NULL)
19716 - return attrs = default_attrs;
19717 -
19718 - for (n = 0; default_attrs[n]; n++)
19719 - attrs[n] = default_attrs[n];
19720 + attrs = default_attrs_amd_nb;
19721
19722 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19723 attrs[n++] = &cache_disable_0.attr;
19724 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19725 .default_attrs = default_attrs,
19726 };
19727
19728 +#ifdef CONFIG_AMD_NB
19729 +static struct kobj_type ktype_cache_amd_nb = {
19730 + .sysfs_ops = &sysfs_ops,
19731 + .default_attrs = default_attrs_amd_nb,
19732 +};
19733 +#endif
19734 +
19735 static struct kobj_type ktype_percpu_entry = {
19736 .sysfs_ops = &sysfs_ops,
19737 };
19738 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19739 return retval;
19740 }
19741
19742 +#ifdef CONFIG_AMD_NB
19743 + amd_l3_attrs();
19744 +#endif
19745 +
19746 for (i = 0; i < num_cache_leaves; i++) {
19747 + struct kobj_type *ktype;
19748 +
19749 this_object = INDEX_KOBJECT_PTR(cpu, i);
19750 this_object->cpu = cpu;
19751 this_object->index = i;
19752
19753 this_leaf = CPUID4_INFO_IDX(cpu, i);
19754
19755 - ktype_cache.default_attrs = default_attrs;
19756 + ktype = &ktype_cache;
19757 #ifdef CONFIG_AMD_NB
19758 if (this_leaf->base.nb)
19759 - ktype_cache.default_attrs = amd_l3_attrs();
19760 + ktype = &ktype_cache_amd_nb;
19761 #endif
19762 retval = kobject_init_and_add(&(this_object->kobj),
19763 - &ktype_cache,
19764 + ktype,
19765 per_cpu(ici_cache_kobject, cpu),
19766 "index%1lu", i);
19767 if (unlikely(retval)) {
19768 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19769 index b3218cd..99a75de 100644
19770 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19771 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19772 @@ -45,6 +45,7 @@
19773 #include <asm/processor.h>
19774 #include <asm/mce.h>
19775 #include <asm/msr.h>
19776 +#include <asm/local.h>
19777
19778 #include "mce-internal.h"
19779
19780 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
19781 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19782 m->cs, m->ip);
19783
19784 - if (m->cs == __KERNEL_CS)
19785 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19786 print_symbol("{%s}", m->ip);
19787 pr_cont("\n");
19788 }
19789 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
19790
19791 #define PANIC_TIMEOUT 5 /* 5 seconds */
19792
19793 -static atomic_t mce_paniced;
19794 +static atomic_unchecked_t mce_paniced;
19795
19796 static int fake_panic;
19797 -static atomic_t mce_fake_paniced;
19798 +static atomic_unchecked_t mce_fake_paniced;
19799
19800 /* Panic in progress. Enable interrupts and wait for final IPI */
19801 static void wait_for_panic(void)
19802 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19803 /*
19804 * Make sure only one CPU runs in machine check panic
19805 */
19806 - if (atomic_inc_return(&mce_paniced) > 1)
19807 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19808 wait_for_panic();
19809 barrier();
19810
19811 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19812 console_verbose();
19813 } else {
19814 /* Don't log too much for fake panic */
19815 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19816 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19817 return;
19818 }
19819 /* First print corrected ones that are still unlogged */
19820 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19821 if (!fake_panic) {
19822 if (panic_timeout == 0)
19823 panic_timeout = mca_cfg.panic_timeout;
19824 - panic(msg);
19825 + panic("%s", msg);
19826 } else
19827 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19828 }
19829 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
19830 * might have been modified by someone else.
19831 */
19832 rmb();
19833 - if (atomic_read(&mce_paniced))
19834 + if (atomic_read_unchecked(&mce_paniced))
19835 wait_for_panic();
19836 if (!mca_cfg.monarch_timeout)
19837 goto out;
19838 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19839 }
19840
19841 /* Call the installed machine check handler for this CPU setup. */
19842 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19843 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19844 unexpected_machine_check;
19845
19846 /*
19847 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19848 return;
19849 }
19850
19851 + pax_open_kernel();
19852 machine_check_vector = do_machine_check;
19853 + pax_close_kernel();
19854
19855 __mcheck_cpu_init_generic();
19856 __mcheck_cpu_init_vendor(c);
19857 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19858 */
19859
19860 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19861 -static int mce_chrdev_open_count; /* #times opened */
19862 +static local_t mce_chrdev_open_count; /* #times opened */
19863 static int mce_chrdev_open_exclu; /* already open exclusive? */
19864
19865 static int mce_chrdev_open(struct inode *inode, struct file *file)
19866 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19867 spin_lock(&mce_chrdev_state_lock);
19868
19869 if (mce_chrdev_open_exclu ||
19870 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19871 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19872 spin_unlock(&mce_chrdev_state_lock);
19873
19874 return -EBUSY;
19875 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19876
19877 if (file->f_flags & O_EXCL)
19878 mce_chrdev_open_exclu = 1;
19879 - mce_chrdev_open_count++;
19880 + local_inc(&mce_chrdev_open_count);
19881
19882 spin_unlock(&mce_chrdev_state_lock);
19883
19884 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19885 {
19886 spin_lock(&mce_chrdev_state_lock);
19887
19888 - mce_chrdev_open_count--;
19889 + local_dec(&mce_chrdev_open_count);
19890 mce_chrdev_open_exclu = 0;
19891
19892 spin_unlock(&mce_chrdev_state_lock);
19893 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
19894
19895 for (i = 0; i < mca_cfg.banks; i++) {
19896 struct mce_bank *b = &mce_banks[i];
19897 - struct device_attribute *a = &b->attr;
19898 + device_attribute_no_const *a = &b->attr;
19899
19900 sysfs_attr_init(&a->attr);
19901 a->attr.name = b->attrname;
19902 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
19903 static void mce_reset(void)
19904 {
19905 cpu_missing = 0;
19906 - atomic_set(&mce_fake_paniced, 0);
19907 + atomic_set_unchecked(&mce_fake_paniced, 0);
19908 atomic_set(&mce_executing, 0);
19909 atomic_set(&mce_callin, 0);
19910 atomic_set(&global_nwo, 0);
19911 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19912 index 1c044b1..37a2a43 100644
19913 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19914 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19915 @@ -11,6 +11,7 @@
19916 #include <asm/processor.h>
19917 #include <asm/mce.h>
19918 #include <asm/msr.h>
19919 +#include <asm/pgtable.h>
19920
19921 /* By default disabled */
19922 int mce_p5_enabled __read_mostly;
19923 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19924 if (!cpu_has(c, X86_FEATURE_MCE))
19925 return;
19926
19927 + pax_open_kernel();
19928 machine_check_vector = pentium_machine_check;
19929 + pax_close_kernel();
19930 /* Make sure the vector pointer is visible before we enable MCEs: */
19931 wmb();
19932
19933 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19934 index e9a701a..35317d6 100644
19935 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19936 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19937 @@ -10,6 +10,7 @@
19938 #include <asm/processor.h>
19939 #include <asm/mce.h>
19940 #include <asm/msr.h>
19941 +#include <asm/pgtable.h>
19942
19943 /* Machine check handler for WinChip C6: */
19944 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19945 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19946 {
19947 u32 lo, hi;
19948
19949 + pax_open_kernel();
19950 machine_check_vector = winchip_machine_check;
19951 + pax_close_kernel();
19952 /* Make sure the vector pointer is visible before we enable MCEs: */
19953 wmb();
19954
19955 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19956 index f961de9..8a9d332 100644
19957 --- a/arch/x86/kernel/cpu/mtrr/main.c
19958 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19959 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19960 u64 size_or_mask, size_and_mask;
19961 static bool mtrr_aps_delayed_init;
19962
19963 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19964 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19965
19966 const struct mtrr_ops *mtrr_if;
19967
19968 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19969 index df5e41f..816c719 100644
19970 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19971 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19972 @@ -25,7 +25,7 @@ struct mtrr_ops {
19973 int (*validate_add_page)(unsigned long base, unsigned long size,
19974 unsigned int type);
19975 int (*have_wrcomb)(void);
19976 -};
19977 +} __do_const;
19978
19979 extern int generic_get_free_region(unsigned long base, unsigned long size,
19980 int replace_reg);
19981 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19982 index 8a87a32..682a22a 100644
19983 --- a/arch/x86/kernel/cpu/perf_event.c
19984 +++ b/arch/x86/kernel/cpu/perf_event.c
19985 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19986 pr_info("no hardware sampling interrupt available.\n");
19987 }
19988
19989 -static struct attribute_group x86_pmu_format_group = {
19990 +static attribute_group_no_const x86_pmu_format_group = {
19991 .name = "format",
19992 .attrs = NULL,
19993 };
19994 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19995 NULL,
19996 };
19997
19998 -static struct attribute_group x86_pmu_events_group = {
19999 +static attribute_group_no_const x86_pmu_events_group = {
20000 .name = "events",
20001 .attrs = events_attr,
20002 };
20003 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20004 if (idx > GDT_ENTRIES)
20005 return 0;
20006
20007 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20008 + desc = get_cpu_gdt_table(smp_processor_id());
20009 }
20010
20011 return get_desc_base(desc + idx);
20012 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20013 break;
20014
20015 perf_callchain_store(entry, frame.return_address);
20016 - fp = frame.next_frame;
20017 + fp = (const void __force_user *)frame.next_frame;
20018 }
20019 }
20020
20021 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20022 index 639d128..e92d7e5 100644
20023 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20024 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20025 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20026 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20027 {
20028 struct attribute **attrs;
20029 - struct attribute_group *attr_group;
20030 + attribute_group_no_const *attr_group;
20031 int i = 0, j;
20032
20033 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20034 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20035 index f31a165..7b46cd8 100644
20036 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20037 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20038 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20039 * v2 and above have a perf capabilities MSR
20040 */
20041 if (version > 1) {
20042 - u64 capabilities;
20043 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20044
20045 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20046 - x86_pmu.intel_cap.capabilities = capabilities;
20047 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20048 + x86_pmu.intel_cap.capabilities = capabilities;
20049 }
20050
20051 intel_ds_init();
20052 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20053 index 4118f9f..f91d0ab 100644
20054 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20055 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20056 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20057 static int __init uncore_type_init(struct intel_uncore_type *type)
20058 {
20059 struct intel_uncore_pmu *pmus;
20060 - struct attribute_group *attr_group;
20061 + attribute_group_no_const *attr_group;
20062 struct attribute **attrs;
20063 int i, j;
20064
20065 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20066 index a80ab71..4089da5 100644
20067 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20068 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20069 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20070 struct uncore_event_desc {
20071 struct kobj_attribute attr;
20072 const char *config;
20073 -};
20074 +} __do_const;
20075
20076 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20077 { \
20078 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20079 index 7d9481c..99c7e4b 100644
20080 --- a/arch/x86/kernel/cpuid.c
20081 +++ b/arch/x86/kernel/cpuid.c
20082 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20083 return notifier_from_errno(err);
20084 }
20085
20086 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20087 +static struct notifier_block cpuid_class_cpu_notifier =
20088 {
20089 .notifier_call = cpuid_class_cpu_callback,
20090 };
20091 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20092 index 18677a9..f67c45b 100644
20093 --- a/arch/x86/kernel/crash.c
20094 +++ b/arch/x86/kernel/crash.c
20095 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20096 {
20097 #ifdef CONFIG_X86_32
20098 struct pt_regs fixed_regs;
20099 -#endif
20100
20101 -#ifdef CONFIG_X86_32
20102 - if (!user_mode_vm(regs)) {
20103 + if (!user_mode(regs)) {
20104 crash_fixup_ss_esp(&fixed_regs, regs);
20105 regs = &fixed_regs;
20106 }
20107 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20108 index afa64ad..dce67dd 100644
20109 --- a/arch/x86/kernel/crash_dump_64.c
20110 +++ b/arch/x86/kernel/crash_dump_64.c
20111 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20112 return -ENOMEM;
20113
20114 if (userbuf) {
20115 - if (copy_to_user(buf, vaddr + offset, csize)) {
20116 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20117 iounmap(vaddr);
20118 return -EFAULT;
20119 }
20120 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20121 index 5d3fe8d..02e1429 100644
20122 --- a/arch/x86/kernel/doublefault.c
20123 +++ b/arch/x86/kernel/doublefault.c
20124 @@ -13,7 +13,7 @@
20125
20126 #define DOUBLEFAULT_STACKSIZE (1024)
20127 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20128 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20129 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20130
20131 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20132
20133 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20134 unsigned long gdt, tss;
20135
20136 native_store_gdt(&gdt_desc);
20137 - gdt = gdt_desc.address;
20138 + gdt = (unsigned long)gdt_desc.address;
20139
20140 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20141
20142 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20143 /* 0x2 bit is always set */
20144 .flags = X86_EFLAGS_SF | 0x2,
20145 .sp = STACK_START,
20146 - .es = __USER_DS,
20147 + .es = __KERNEL_DS,
20148 .cs = __KERNEL_CS,
20149 .ss = __KERNEL_DS,
20150 - .ds = __USER_DS,
20151 + .ds = __KERNEL_DS,
20152 .fs = __KERNEL_PERCPU,
20153
20154 .__cr3 = __pa_nodebug(swapper_pg_dir),
20155 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20156 index deb6421..76bbc12 100644
20157 --- a/arch/x86/kernel/dumpstack.c
20158 +++ b/arch/x86/kernel/dumpstack.c
20159 @@ -2,6 +2,9 @@
20160 * Copyright (C) 1991, 1992 Linus Torvalds
20161 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20162 */
20163 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20164 +#define __INCLUDED_BY_HIDESYM 1
20165 +#endif
20166 #include <linux/kallsyms.h>
20167 #include <linux/kprobes.h>
20168 #include <linux/uaccess.h>
20169 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20170 static void
20171 print_ftrace_graph_addr(unsigned long addr, void *data,
20172 const struct stacktrace_ops *ops,
20173 - struct thread_info *tinfo, int *graph)
20174 + struct task_struct *task, int *graph)
20175 {
20176 - struct task_struct *task;
20177 unsigned long ret_addr;
20178 int index;
20179
20180 if (addr != (unsigned long)return_to_handler)
20181 return;
20182
20183 - task = tinfo->task;
20184 index = task->curr_ret_stack;
20185
20186 if (!task->ret_stack || index < *graph)
20187 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20188 static inline void
20189 print_ftrace_graph_addr(unsigned long addr, void *data,
20190 const struct stacktrace_ops *ops,
20191 - struct thread_info *tinfo, int *graph)
20192 + struct task_struct *task, int *graph)
20193 { }
20194 #endif
20195
20196 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20197 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20198 */
20199
20200 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20201 - void *p, unsigned int size, void *end)
20202 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20203 {
20204 - void *t = tinfo;
20205 if (end) {
20206 if (p < end && p >= (end-THREAD_SIZE))
20207 return 1;
20208 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20209 }
20210
20211 unsigned long
20212 -print_context_stack(struct thread_info *tinfo,
20213 +print_context_stack(struct task_struct *task, void *stack_start,
20214 unsigned long *stack, unsigned long bp,
20215 const struct stacktrace_ops *ops, void *data,
20216 unsigned long *end, int *graph)
20217 {
20218 struct stack_frame *frame = (struct stack_frame *)bp;
20219
20220 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20221 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20222 unsigned long addr;
20223
20224 addr = *stack;
20225 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20226 } else {
20227 ops->address(data, addr, 0);
20228 }
20229 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20230 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20231 }
20232 stack++;
20233 }
20234 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20235 EXPORT_SYMBOL_GPL(print_context_stack);
20236
20237 unsigned long
20238 -print_context_stack_bp(struct thread_info *tinfo,
20239 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20240 unsigned long *stack, unsigned long bp,
20241 const struct stacktrace_ops *ops, void *data,
20242 unsigned long *end, int *graph)
20243 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20244 struct stack_frame *frame = (struct stack_frame *)bp;
20245 unsigned long *ret_addr = &frame->return_address;
20246
20247 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20248 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20249 unsigned long addr = *ret_addr;
20250
20251 if (!__kernel_text_address(addr))
20252 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20253 ops->address(data, addr, 1);
20254 frame = frame->next_frame;
20255 ret_addr = &frame->return_address;
20256 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20257 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20258 }
20259
20260 return (unsigned long)frame;
20261 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20262 static void print_trace_address(void *data, unsigned long addr, int reliable)
20263 {
20264 touch_nmi_watchdog();
20265 - printk(data);
20266 + printk("%s", (char *)data);
20267 printk_address(addr, reliable);
20268 }
20269
20270 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20271 }
20272 EXPORT_SYMBOL_GPL(oops_begin);
20273
20274 +extern void gr_handle_kernel_exploit(void);
20275 +
20276 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20277 {
20278 if (regs && kexec_should_crash(current))
20279 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20280 panic("Fatal exception in interrupt");
20281 if (panic_on_oops)
20282 panic("Fatal exception");
20283 - do_exit(signr);
20284 +
20285 + gr_handle_kernel_exploit();
20286 +
20287 + do_group_exit(signr);
20288 }
20289
20290 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20291 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20292 print_modules();
20293 show_regs(regs);
20294 #ifdef CONFIG_X86_32
20295 - if (user_mode_vm(regs)) {
20296 + if (user_mode(regs)) {
20297 sp = regs->sp;
20298 ss = regs->ss & 0xffff;
20299 } else {
20300 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20301 unsigned long flags = oops_begin();
20302 int sig = SIGSEGV;
20303
20304 - if (!user_mode_vm(regs))
20305 + if (!user_mode(regs))
20306 report_bug(regs->ip, regs);
20307
20308 if (__die(str, regs, err))
20309 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20310 index f2a1770..540657f 100644
20311 --- a/arch/x86/kernel/dumpstack_32.c
20312 +++ b/arch/x86/kernel/dumpstack_32.c
20313 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20314 bp = stack_frame(task, regs);
20315
20316 for (;;) {
20317 - struct thread_info *context;
20318 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20319
20320 - context = (struct thread_info *)
20321 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20322 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20323 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20324
20325 - stack = (unsigned long *)context->previous_esp;
20326 - if (!stack)
20327 + if (stack_start == task_stack_page(task))
20328 break;
20329 + stack = *(unsigned long **)stack_start;
20330 if (ops->stack(data, "IRQ") < 0)
20331 break;
20332 touch_nmi_watchdog();
20333 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20334 int i;
20335
20336 show_regs_print_info(KERN_EMERG);
20337 - __show_regs(regs, !user_mode_vm(regs));
20338 + __show_regs(regs, !user_mode(regs));
20339
20340 /*
20341 * When in-kernel, we also print out the stack and code at the
20342 * time of the fault..
20343 */
20344 - if (!user_mode_vm(regs)) {
20345 + if (!user_mode(regs)) {
20346 unsigned int code_prologue = code_bytes * 43 / 64;
20347 unsigned int code_len = code_bytes;
20348 unsigned char c;
20349 u8 *ip;
20350 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20351
20352 pr_emerg("Stack:\n");
20353 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20354
20355 pr_emerg("Code:");
20356
20357 - ip = (u8 *)regs->ip - code_prologue;
20358 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20359 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20360 /* try starting at IP */
20361 - ip = (u8 *)regs->ip;
20362 + ip = (u8 *)regs->ip + cs_base;
20363 code_len = code_len - code_prologue + 1;
20364 }
20365 for (i = 0; i < code_len; i++, ip++) {
20366 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20367 pr_cont(" Bad EIP value.");
20368 break;
20369 }
20370 - if (ip == (u8 *)regs->ip)
20371 + if (ip == (u8 *)regs->ip + cs_base)
20372 pr_cont(" <%02x>", c);
20373 else
20374 pr_cont(" %02x", c);
20375 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20376 {
20377 unsigned short ud2;
20378
20379 + ip = ktla_ktva(ip);
20380 if (ip < PAGE_OFFSET)
20381 return 0;
20382 if (probe_kernel_address((unsigned short *)ip, ud2))
20383 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20384
20385 return ud2 == 0x0b0f;
20386 }
20387 +
20388 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20389 +void pax_check_alloca(unsigned long size)
20390 +{
20391 + unsigned long sp = (unsigned long)&sp, stack_left;
20392 +
20393 + /* all kernel stacks are of the same size */
20394 + stack_left = sp & (THREAD_SIZE - 1);
20395 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20396 +}
20397 +EXPORT_SYMBOL(pax_check_alloca);
20398 +#endif
20399 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20400 index addb207..99635fa 100644
20401 --- a/arch/x86/kernel/dumpstack_64.c
20402 +++ b/arch/x86/kernel/dumpstack_64.c
20403 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20404 unsigned long *irq_stack_end =
20405 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20406 unsigned used = 0;
20407 - struct thread_info *tinfo;
20408 int graph = 0;
20409 unsigned long dummy;
20410 + void *stack_start;
20411
20412 if (!task)
20413 task = current;
20414 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20415 * current stack address. If the stacks consist of nested
20416 * exceptions
20417 */
20418 - tinfo = task_thread_info(task);
20419 for (;;) {
20420 char *id;
20421 unsigned long *estack_end;
20422 +
20423 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20424 &used, &id);
20425
20426 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20427 if (ops->stack(data, id) < 0)
20428 break;
20429
20430 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20431 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20432 data, estack_end, &graph);
20433 ops->stack(data, "<EOE>");
20434 /*
20435 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20436 * second-to-last pointer (index -2 to end) in the
20437 * exception stack:
20438 */
20439 + if ((u16)estack_end[-1] != __KERNEL_DS)
20440 + goto out;
20441 stack = (unsigned long *) estack_end[-2];
20442 continue;
20443 }
20444 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20445 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20446 if (ops->stack(data, "IRQ") < 0)
20447 break;
20448 - bp = ops->walk_stack(tinfo, stack, bp,
20449 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20450 ops, data, irq_stack_end, &graph);
20451 /*
20452 * We link to the next stack (which would be
20453 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20454 /*
20455 * This handles the process stack:
20456 */
20457 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20458 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20459 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20460 +out:
20461 put_cpu();
20462 }
20463 EXPORT_SYMBOL(dump_trace);
20464 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20465
20466 return ud2 == 0x0b0f;
20467 }
20468 +
20469 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20470 +void pax_check_alloca(unsigned long size)
20471 +{
20472 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20473 + unsigned cpu, used;
20474 + char *id;
20475 +
20476 + /* check the process stack first */
20477 + stack_start = (unsigned long)task_stack_page(current);
20478 + stack_end = stack_start + THREAD_SIZE;
20479 + if (likely(stack_start <= sp && sp < stack_end)) {
20480 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + cpu = get_cpu();
20486 +
20487 + /* check the irq stacks */
20488 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20489 + stack_start = stack_end - IRQ_STACK_SIZE;
20490 + if (stack_start <= sp && sp < stack_end) {
20491 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20492 + put_cpu();
20493 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20494 + return;
20495 + }
20496 +
20497 + /* check the exception stacks */
20498 + used = 0;
20499 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20500 + stack_start = stack_end - EXCEPTION_STKSZ;
20501 + if (stack_end && stack_start <= sp && sp < stack_end) {
20502 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20503 + put_cpu();
20504 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20505 + return;
20506 + }
20507 +
20508 + put_cpu();
20509 +
20510 + /* unknown stack */
20511 + BUG();
20512 +}
20513 +EXPORT_SYMBOL(pax_check_alloca);
20514 +#endif
20515 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20516 index 174da5f..5e55606 100644
20517 --- a/arch/x86/kernel/e820.c
20518 +++ b/arch/x86/kernel/e820.c
20519 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20520
20521 static void early_panic(char *msg)
20522 {
20523 - early_printk(msg);
20524 - panic(msg);
20525 + early_printk("%s", msg);
20526 + panic("%s", msg);
20527 }
20528
20529 static int userdef __initdata;
20530 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20531 index d15f575..d692043 100644
20532 --- a/arch/x86/kernel/early_printk.c
20533 +++ b/arch/x86/kernel/early_printk.c
20534 @@ -7,6 +7,7 @@
20535 #include <linux/pci_regs.h>
20536 #include <linux/pci_ids.h>
20537 #include <linux/errno.h>
20538 +#include <linux/sched.h>
20539 #include <asm/io.h>
20540 #include <asm/processor.h>
20541 #include <asm/fcntl.h>
20542 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20543 index f0dcb0c..9f39b80 100644
20544 --- a/arch/x86/kernel/entry_32.S
20545 +++ b/arch/x86/kernel/entry_32.S
20546 @@ -177,13 +177,153 @@
20547 /*CFI_REL_OFFSET gs, PT_GS*/
20548 .endm
20549 .macro SET_KERNEL_GS reg
20550 +
20551 +#ifdef CONFIG_CC_STACKPROTECTOR
20552 movl $(__KERNEL_STACK_CANARY), \reg
20553 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20554 + movl $(__USER_DS), \reg
20555 +#else
20556 + xorl \reg, \reg
20557 +#endif
20558 +
20559 movl \reg, %gs
20560 .endm
20561
20562 #endif /* CONFIG_X86_32_LAZY_GS */
20563
20564 -.macro SAVE_ALL
20565 +.macro pax_enter_kernel
20566 +#ifdef CONFIG_PAX_KERNEXEC
20567 + call pax_enter_kernel
20568 +#endif
20569 +.endm
20570 +
20571 +.macro pax_exit_kernel
20572 +#ifdef CONFIG_PAX_KERNEXEC
20573 + call pax_exit_kernel
20574 +#endif
20575 +.endm
20576 +
20577 +#ifdef CONFIG_PAX_KERNEXEC
20578 +ENTRY(pax_enter_kernel)
20579 +#ifdef CONFIG_PARAVIRT
20580 + pushl %eax
20581 + pushl %ecx
20582 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20583 + mov %eax, %esi
20584 +#else
20585 + mov %cr0, %esi
20586 +#endif
20587 + bts $16, %esi
20588 + jnc 1f
20589 + mov %cs, %esi
20590 + cmp $__KERNEL_CS, %esi
20591 + jz 3f
20592 + ljmp $__KERNEL_CS, $3f
20593 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20594 +2:
20595 +#ifdef CONFIG_PARAVIRT
20596 + mov %esi, %eax
20597 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20598 +#else
20599 + mov %esi, %cr0
20600 +#endif
20601 +3:
20602 +#ifdef CONFIG_PARAVIRT
20603 + popl %ecx
20604 + popl %eax
20605 +#endif
20606 + ret
20607 +ENDPROC(pax_enter_kernel)
20608 +
20609 +ENTRY(pax_exit_kernel)
20610 +#ifdef CONFIG_PARAVIRT
20611 + pushl %eax
20612 + pushl %ecx
20613 +#endif
20614 + mov %cs, %esi
20615 + cmp $__KERNEXEC_KERNEL_CS, %esi
20616 + jnz 2f
20617 +#ifdef CONFIG_PARAVIRT
20618 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20619 + mov %eax, %esi
20620 +#else
20621 + mov %cr0, %esi
20622 +#endif
20623 + btr $16, %esi
20624 + ljmp $__KERNEL_CS, $1f
20625 +1:
20626 +#ifdef CONFIG_PARAVIRT
20627 + mov %esi, %eax
20628 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20629 +#else
20630 + mov %esi, %cr0
20631 +#endif
20632 +2:
20633 +#ifdef CONFIG_PARAVIRT
20634 + popl %ecx
20635 + popl %eax
20636 +#endif
20637 + ret
20638 +ENDPROC(pax_exit_kernel)
20639 +#endif
20640 +
20641 + .macro pax_erase_kstack
20642 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20643 + call pax_erase_kstack
20644 +#endif
20645 + .endm
20646 +
20647 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20648 +/*
20649 + * ebp: thread_info
20650 + */
20651 +ENTRY(pax_erase_kstack)
20652 + pushl %edi
20653 + pushl %ecx
20654 + pushl %eax
20655 +
20656 + mov TI_lowest_stack(%ebp), %edi
20657 + mov $-0xBEEF, %eax
20658 + std
20659 +
20660 +1: mov %edi, %ecx
20661 + and $THREAD_SIZE_asm - 1, %ecx
20662 + shr $2, %ecx
20663 + repne scasl
20664 + jecxz 2f
20665 +
20666 + cmp $2*16, %ecx
20667 + jc 2f
20668 +
20669 + mov $2*16, %ecx
20670 + repe scasl
20671 + jecxz 2f
20672 + jne 1b
20673 +
20674 +2: cld
20675 + mov %esp, %ecx
20676 + sub %edi, %ecx
20677 +
20678 + cmp $THREAD_SIZE_asm, %ecx
20679 + jb 3f
20680 + ud2
20681 +3:
20682 +
20683 + shr $2, %ecx
20684 + rep stosl
20685 +
20686 + mov TI_task_thread_sp0(%ebp), %edi
20687 + sub $128, %edi
20688 + mov %edi, TI_lowest_stack(%ebp)
20689 +
20690 + popl %eax
20691 + popl %ecx
20692 + popl %edi
20693 + ret
20694 +ENDPROC(pax_erase_kstack)
20695 +#endif
20696 +
20697 +.macro __SAVE_ALL _DS
20698 cld
20699 PUSH_GS
20700 pushl_cfi %fs
20701 @@ -206,7 +346,7 @@
20702 CFI_REL_OFFSET ecx, 0
20703 pushl_cfi %ebx
20704 CFI_REL_OFFSET ebx, 0
20705 - movl $(__USER_DS), %edx
20706 + movl $\_DS, %edx
20707 movl %edx, %ds
20708 movl %edx, %es
20709 movl $(__KERNEL_PERCPU), %edx
20710 @@ -214,6 +354,15 @@
20711 SET_KERNEL_GS %edx
20712 .endm
20713
20714 +.macro SAVE_ALL
20715 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20716 + __SAVE_ALL __KERNEL_DS
20717 + pax_enter_kernel
20718 +#else
20719 + __SAVE_ALL __USER_DS
20720 +#endif
20721 +.endm
20722 +
20723 .macro RESTORE_INT_REGS
20724 popl_cfi %ebx
20725 CFI_RESTORE ebx
20726 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20727 popfl_cfi
20728 jmp syscall_exit
20729 CFI_ENDPROC
20730 -END(ret_from_fork)
20731 +ENDPROC(ret_from_fork)
20732
20733 ENTRY(ret_from_kernel_thread)
20734 CFI_STARTPROC
20735 @@ -344,7 +493,15 @@ ret_from_intr:
20736 andl $SEGMENT_RPL_MASK, %eax
20737 #endif
20738 cmpl $USER_RPL, %eax
20739 +
20740 +#ifdef CONFIG_PAX_KERNEXEC
20741 + jae resume_userspace
20742 +
20743 + pax_exit_kernel
20744 + jmp resume_kernel
20745 +#else
20746 jb resume_kernel # not returning to v8086 or userspace
20747 +#endif
20748
20749 ENTRY(resume_userspace)
20750 LOCKDEP_SYS_EXIT
20751 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20752 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20753 # int/exception return?
20754 jne work_pending
20755 - jmp restore_all
20756 -END(ret_from_exception)
20757 + jmp restore_all_pax
20758 +ENDPROC(ret_from_exception)
20759
20760 #ifdef CONFIG_PREEMPT
20761 ENTRY(resume_kernel)
20762 @@ -372,7 +529,7 @@ need_resched:
20763 jz restore_all
20764 call preempt_schedule_irq
20765 jmp need_resched
20766 -END(resume_kernel)
20767 +ENDPROC(resume_kernel)
20768 #endif
20769 CFI_ENDPROC
20770 /*
20771 @@ -406,30 +563,45 @@ sysenter_past_esp:
20772 /*CFI_REL_OFFSET cs, 0*/
20773 /*
20774 * Push current_thread_info()->sysenter_return to the stack.
20775 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20776 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20777 */
20778 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20779 + pushl_cfi $0
20780 CFI_REL_OFFSET eip, 0
20781
20782 pushl_cfi %eax
20783 SAVE_ALL
20784 + GET_THREAD_INFO(%ebp)
20785 + movl TI_sysenter_return(%ebp),%ebp
20786 + movl %ebp,PT_EIP(%esp)
20787 ENABLE_INTERRUPTS(CLBR_NONE)
20788
20789 /*
20790 * Load the potential sixth argument from user stack.
20791 * Careful about security.
20792 */
20793 + movl PT_OLDESP(%esp),%ebp
20794 +
20795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20796 + mov PT_OLDSS(%esp),%ds
20797 +1: movl %ds:(%ebp),%ebp
20798 + push %ss
20799 + pop %ds
20800 +#else
20801 cmpl $__PAGE_OFFSET-3,%ebp
20802 jae syscall_fault
20803 ASM_STAC
20804 1: movl (%ebp),%ebp
20805 ASM_CLAC
20806 +#endif
20807 +
20808 movl %ebp,PT_EBP(%esp)
20809 _ASM_EXTABLE(1b,syscall_fault)
20810
20811 GET_THREAD_INFO(%ebp)
20812
20813 +#ifdef CONFIG_PAX_RANDKSTACK
20814 + pax_erase_kstack
20815 +#endif
20816 +
20817 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20818 jnz sysenter_audit
20819 sysenter_do_call:
20820 @@ -444,12 +616,24 @@ sysenter_do_call:
20821 testl $_TIF_ALLWORK_MASK, %ecx
20822 jne sysexit_audit
20823 sysenter_exit:
20824 +
20825 +#ifdef CONFIG_PAX_RANDKSTACK
20826 + pushl_cfi %eax
20827 + movl %esp, %eax
20828 + call pax_randomize_kstack
20829 + popl_cfi %eax
20830 +#endif
20831 +
20832 + pax_erase_kstack
20833 +
20834 /* if something modifies registers it must also disable sysexit */
20835 movl PT_EIP(%esp), %edx
20836 movl PT_OLDESP(%esp), %ecx
20837 xorl %ebp,%ebp
20838 TRACE_IRQS_ON
20839 1: mov PT_FS(%esp), %fs
20840 +2: mov PT_DS(%esp), %ds
20841 +3: mov PT_ES(%esp), %es
20842 PTGS_TO_GS
20843 ENABLE_INTERRUPTS_SYSEXIT
20844
20845 @@ -466,6 +650,9 @@ sysenter_audit:
20846 movl %eax,%edx /* 2nd arg: syscall number */
20847 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20848 call __audit_syscall_entry
20849 +
20850 + pax_erase_kstack
20851 +
20852 pushl_cfi %ebx
20853 movl PT_EAX(%esp),%eax /* reload syscall number */
20854 jmp sysenter_do_call
20855 @@ -491,10 +678,16 @@ sysexit_audit:
20856
20857 CFI_ENDPROC
20858 .pushsection .fixup,"ax"
20859 -2: movl $0,PT_FS(%esp)
20860 +4: movl $0,PT_FS(%esp)
20861 + jmp 1b
20862 +5: movl $0,PT_DS(%esp)
20863 + jmp 1b
20864 +6: movl $0,PT_ES(%esp)
20865 jmp 1b
20866 .popsection
20867 - _ASM_EXTABLE(1b,2b)
20868 + _ASM_EXTABLE(1b,4b)
20869 + _ASM_EXTABLE(2b,5b)
20870 + _ASM_EXTABLE(3b,6b)
20871 PTGS_TO_GS_EX
20872 ENDPROC(ia32_sysenter_target)
20873
20874 @@ -509,6 +702,11 @@ ENTRY(system_call)
20875 pushl_cfi %eax # save orig_eax
20876 SAVE_ALL
20877 GET_THREAD_INFO(%ebp)
20878 +
20879 +#ifdef CONFIG_PAX_RANDKSTACK
20880 + pax_erase_kstack
20881 +#endif
20882 +
20883 # system call tracing in operation / emulation
20884 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20885 jnz syscall_trace_entry
20886 @@ -527,6 +725,15 @@ syscall_exit:
20887 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20888 jne syscall_exit_work
20889
20890 +restore_all_pax:
20891 +
20892 +#ifdef CONFIG_PAX_RANDKSTACK
20893 + movl %esp, %eax
20894 + call pax_randomize_kstack
20895 +#endif
20896 +
20897 + pax_erase_kstack
20898 +
20899 restore_all:
20900 TRACE_IRQS_IRET
20901 restore_all_notrace:
20902 @@ -583,14 +790,34 @@ ldt_ss:
20903 * compensating for the offset by changing to the ESPFIX segment with
20904 * a base address that matches for the difference.
20905 */
20906 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20907 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20908 mov %esp, %edx /* load kernel esp */
20909 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20910 mov %dx, %ax /* eax: new kernel esp */
20911 sub %eax, %edx /* offset (low word is 0) */
20912 +#ifdef CONFIG_SMP
20913 + movl PER_CPU_VAR(cpu_number), %ebx
20914 + shll $PAGE_SHIFT_asm, %ebx
20915 + addl $cpu_gdt_table, %ebx
20916 +#else
20917 + movl $cpu_gdt_table, %ebx
20918 +#endif
20919 shr $16, %edx
20920 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20921 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20922 +
20923 +#ifdef CONFIG_PAX_KERNEXEC
20924 + mov %cr0, %esi
20925 + btr $16, %esi
20926 + mov %esi, %cr0
20927 +#endif
20928 +
20929 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20930 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20931 +
20932 +#ifdef CONFIG_PAX_KERNEXEC
20933 + bts $16, %esi
20934 + mov %esi, %cr0
20935 +#endif
20936 +
20937 pushl_cfi $__ESPFIX_SS
20938 pushl_cfi %eax /* new kernel esp */
20939 /* Disable interrupts, but do not irqtrace this section: we
20940 @@ -619,20 +846,18 @@ work_resched:
20941 movl TI_flags(%ebp), %ecx
20942 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20943 # than syscall tracing?
20944 - jz restore_all
20945 + jz restore_all_pax
20946 testb $_TIF_NEED_RESCHED, %cl
20947 jnz work_resched
20948
20949 work_notifysig: # deal with pending signals and
20950 # notify-resume requests
20951 + movl %esp, %eax
20952 #ifdef CONFIG_VM86
20953 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20954 - movl %esp, %eax
20955 jne work_notifysig_v86 # returning to kernel-space or
20956 # vm86-space
20957 1:
20958 -#else
20959 - movl %esp, %eax
20960 #endif
20961 TRACE_IRQS_ON
20962 ENABLE_INTERRUPTS(CLBR_NONE)
20963 @@ -653,7 +878,7 @@ work_notifysig_v86:
20964 movl %eax, %esp
20965 jmp 1b
20966 #endif
20967 -END(work_pending)
20968 +ENDPROC(work_pending)
20969
20970 # perform syscall exit tracing
20971 ALIGN
20972 @@ -661,11 +886,14 @@ syscall_trace_entry:
20973 movl $-ENOSYS,PT_EAX(%esp)
20974 movl %esp, %eax
20975 call syscall_trace_enter
20976 +
20977 + pax_erase_kstack
20978 +
20979 /* What it returned is what we'll actually use. */
20980 cmpl $(NR_syscalls), %eax
20981 jnae syscall_call
20982 jmp syscall_exit
20983 -END(syscall_trace_entry)
20984 +ENDPROC(syscall_trace_entry)
20985
20986 # perform syscall exit tracing
20987 ALIGN
20988 @@ -678,21 +906,25 @@ syscall_exit_work:
20989 movl %esp, %eax
20990 call syscall_trace_leave
20991 jmp resume_userspace
20992 -END(syscall_exit_work)
20993 +ENDPROC(syscall_exit_work)
20994 CFI_ENDPROC
20995
20996 RING0_INT_FRAME # can't unwind into user space anyway
20997 syscall_fault:
20998 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20999 + push %ss
21000 + pop %ds
21001 +#endif
21002 ASM_CLAC
21003 GET_THREAD_INFO(%ebp)
21004 movl $-EFAULT,PT_EAX(%esp)
21005 jmp resume_userspace
21006 -END(syscall_fault)
21007 +ENDPROC(syscall_fault)
21008
21009 syscall_badsys:
21010 movl $-ENOSYS,PT_EAX(%esp)
21011 jmp resume_userspace
21012 -END(syscall_badsys)
21013 +ENDPROC(syscall_badsys)
21014 CFI_ENDPROC
21015 /*
21016 * End of kprobes section
21017 @@ -708,8 +940,15 @@ END(syscall_badsys)
21018 * normal stack and adjusts ESP with the matching offset.
21019 */
21020 /* fixup the stack */
21021 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21022 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21023 +#ifdef CONFIG_SMP
21024 + movl PER_CPU_VAR(cpu_number), %ebx
21025 + shll $PAGE_SHIFT_asm, %ebx
21026 + addl $cpu_gdt_table, %ebx
21027 +#else
21028 + movl $cpu_gdt_table, %ebx
21029 +#endif
21030 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21031 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21032 shl $16, %eax
21033 addl %esp, %eax /* the adjusted stack pointer */
21034 pushl_cfi $__KERNEL_DS
21035 @@ -762,7 +1001,7 @@ vector=vector+1
21036 .endr
21037 2: jmp common_interrupt
21038 .endr
21039 -END(irq_entries_start)
21040 +ENDPROC(irq_entries_start)
21041
21042 .previous
21043 END(interrupt)
21044 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21045 pushl_cfi $do_coprocessor_error
21046 jmp error_code
21047 CFI_ENDPROC
21048 -END(coprocessor_error)
21049 +ENDPROC(coprocessor_error)
21050
21051 ENTRY(simd_coprocessor_error)
21052 RING0_INT_FRAME
21053 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21054 .section .altinstructions,"a"
21055 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21056 .previous
21057 -.section .altinstr_replacement,"ax"
21058 +.section .altinstr_replacement,"a"
21059 663: pushl $do_simd_coprocessor_error
21060 664:
21061 .previous
21062 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21063 #endif
21064 jmp error_code
21065 CFI_ENDPROC
21066 -END(simd_coprocessor_error)
21067 +ENDPROC(simd_coprocessor_error)
21068
21069 ENTRY(device_not_available)
21070 RING0_INT_FRAME
21071 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21072 pushl_cfi $do_device_not_available
21073 jmp error_code
21074 CFI_ENDPROC
21075 -END(device_not_available)
21076 +ENDPROC(device_not_available)
21077
21078 #ifdef CONFIG_PARAVIRT
21079 ENTRY(native_iret)
21080 iret
21081 _ASM_EXTABLE(native_iret, iret_exc)
21082 -END(native_iret)
21083 +ENDPROC(native_iret)
21084
21085 ENTRY(native_irq_enable_sysexit)
21086 sti
21087 sysexit
21088 -END(native_irq_enable_sysexit)
21089 +ENDPROC(native_irq_enable_sysexit)
21090 #endif
21091
21092 ENTRY(overflow)
21093 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21094 pushl_cfi $do_overflow
21095 jmp error_code
21096 CFI_ENDPROC
21097 -END(overflow)
21098 +ENDPROC(overflow)
21099
21100 ENTRY(bounds)
21101 RING0_INT_FRAME
21102 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21103 pushl_cfi $do_bounds
21104 jmp error_code
21105 CFI_ENDPROC
21106 -END(bounds)
21107 +ENDPROC(bounds)
21108
21109 ENTRY(invalid_op)
21110 RING0_INT_FRAME
21111 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21112 pushl_cfi $do_invalid_op
21113 jmp error_code
21114 CFI_ENDPROC
21115 -END(invalid_op)
21116 +ENDPROC(invalid_op)
21117
21118 ENTRY(coprocessor_segment_overrun)
21119 RING0_INT_FRAME
21120 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21121 pushl_cfi $do_coprocessor_segment_overrun
21122 jmp error_code
21123 CFI_ENDPROC
21124 -END(coprocessor_segment_overrun)
21125 +ENDPROC(coprocessor_segment_overrun)
21126
21127 ENTRY(invalid_TSS)
21128 RING0_EC_FRAME
21129 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21130 pushl_cfi $do_invalid_TSS
21131 jmp error_code
21132 CFI_ENDPROC
21133 -END(invalid_TSS)
21134 +ENDPROC(invalid_TSS)
21135
21136 ENTRY(segment_not_present)
21137 RING0_EC_FRAME
21138 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21139 pushl_cfi $do_segment_not_present
21140 jmp error_code
21141 CFI_ENDPROC
21142 -END(segment_not_present)
21143 +ENDPROC(segment_not_present)
21144
21145 ENTRY(stack_segment)
21146 RING0_EC_FRAME
21147 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21148 pushl_cfi $do_stack_segment
21149 jmp error_code
21150 CFI_ENDPROC
21151 -END(stack_segment)
21152 +ENDPROC(stack_segment)
21153
21154 ENTRY(alignment_check)
21155 RING0_EC_FRAME
21156 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21157 pushl_cfi $do_alignment_check
21158 jmp error_code
21159 CFI_ENDPROC
21160 -END(alignment_check)
21161 +ENDPROC(alignment_check)
21162
21163 ENTRY(divide_error)
21164 RING0_INT_FRAME
21165 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21166 pushl_cfi $do_divide_error
21167 jmp error_code
21168 CFI_ENDPROC
21169 -END(divide_error)
21170 +ENDPROC(divide_error)
21171
21172 #ifdef CONFIG_X86_MCE
21173 ENTRY(machine_check)
21174 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21175 pushl_cfi machine_check_vector
21176 jmp error_code
21177 CFI_ENDPROC
21178 -END(machine_check)
21179 +ENDPROC(machine_check)
21180 #endif
21181
21182 ENTRY(spurious_interrupt_bug)
21183 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21184 pushl_cfi $do_spurious_interrupt_bug
21185 jmp error_code
21186 CFI_ENDPROC
21187 -END(spurious_interrupt_bug)
21188 +ENDPROC(spurious_interrupt_bug)
21189 /*
21190 * End of kprobes section
21191 */
21192 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21193
21194 ENTRY(mcount)
21195 ret
21196 -END(mcount)
21197 +ENDPROC(mcount)
21198
21199 ENTRY(ftrace_caller)
21200 cmpl $0, function_trace_stop
21201 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21202 .globl ftrace_stub
21203 ftrace_stub:
21204 ret
21205 -END(ftrace_caller)
21206 +ENDPROC(ftrace_caller)
21207
21208 ENTRY(ftrace_regs_caller)
21209 pushf /* push flags before compare (in cs location) */
21210 @@ -1210,7 +1449,7 @@ trace:
21211 popl %ecx
21212 popl %eax
21213 jmp ftrace_stub
21214 -END(mcount)
21215 +ENDPROC(mcount)
21216 #endif /* CONFIG_DYNAMIC_FTRACE */
21217 #endif /* CONFIG_FUNCTION_TRACER */
21218
21219 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21220 popl %ecx
21221 popl %eax
21222 ret
21223 -END(ftrace_graph_caller)
21224 +ENDPROC(ftrace_graph_caller)
21225
21226 .globl return_to_handler
21227 return_to_handler:
21228 @@ -1284,15 +1523,18 @@ error_code:
21229 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21230 REG_TO_PTGS %ecx
21231 SET_KERNEL_GS %ecx
21232 - movl $(__USER_DS), %ecx
21233 + movl $(__KERNEL_DS), %ecx
21234 movl %ecx, %ds
21235 movl %ecx, %es
21236 +
21237 + pax_enter_kernel
21238 +
21239 TRACE_IRQS_OFF
21240 movl %esp,%eax # pt_regs pointer
21241 call *%edi
21242 jmp ret_from_exception
21243 CFI_ENDPROC
21244 -END(page_fault)
21245 +ENDPROC(page_fault)
21246
21247 /*
21248 * Debug traps and NMI can happen at the one SYSENTER instruction
21249 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21250 call do_debug
21251 jmp ret_from_exception
21252 CFI_ENDPROC
21253 -END(debug)
21254 +ENDPROC(debug)
21255
21256 /*
21257 * NMI is doubly nasty. It can happen _while_ we're handling
21258 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21259 xorl %edx,%edx # zero error code
21260 movl %esp,%eax # pt_regs pointer
21261 call do_nmi
21262 +
21263 + pax_exit_kernel
21264 +
21265 jmp restore_all_notrace
21266 CFI_ENDPROC
21267
21268 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21269 FIXUP_ESPFIX_STACK # %eax == %esp
21270 xorl %edx,%edx # zero error code
21271 call do_nmi
21272 +
21273 + pax_exit_kernel
21274 +
21275 RESTORE_REGS
21276 lss 12+4(%esp), %esp # back to espfix stack
21277 CFI_ADJUST_CFA_OFFSET -24
21278 jmp irq_return
21279 CFI_ENDPROC
21280 -END(nmi)
21281 +ENDPROC(nmi)
21282
21283 ENTRY(int3)
21284 RING0_INT_FRAME
21285 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21286 call do_int3
21287 jmp ret_from_exception
21288 CFI_ENDPROC
21289 -END(int3)
21290 +ENDPROC(int3)
21291
21292 ENTRY(general_protection)
21293 RING0_EC_FRAME
21294 pushl_cfi $do_general_protection
21295 jmp error_code
21296 CFI_ENDPROC
21297 -END(general_protection)
21298 +ENDPROC(general_protection)
21299
21300 #ifdef CONFIG_KVM_GUEST
21301 ENTRY(async_page_fault)
21302 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
21303 pushl_cfi $do_async_page_fault
21304 jmp error_code
21305 CFI_ENDPROC
21306 -END(async_page_fault)
21307 +ENDPROC(async_page_fault)
21308 #endif
21309
21310 /*
21311 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21312 index b077f4c..feb26c1 100644
21313 --- a/arch/x86/kernel/entry_64.S
21314 +++ b/arch/x86/kernel/entry_64.S
21315 @@ -59,6 +59,8 @@
21316 #include <asm/context_tracking.h>
21317 #include <asm/smap.h>
21318 #include <linux/err.h>
21319 +#include <asm/pgtable.h>
21320 +#include <asm/alternative-asm.h>
21321
21322 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21323 #include <linux/elf-em.h>
21324 @@ -80,8 +82,9 @@
21325 #ifdef CONFIG_DYNAMIC_FTRACE
21326
21327 ENTRY(function_hook)
21328 + pax_force_retaddr
21329 retq
21330 -END(function_hook)
21331 +ENDPROC(function_hook)
21332
21333 /* skip is set if stack has been adjusted */
21334 .macro ftrace_caller_setup skip=0
21335 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21336 #endif
21337
21338 GLOBAL(ftrace_stub)
21339 + pax_force_retaddr
21340 retq
21341 -END(ftrace_caller)
21342 +ENDPROC(ftrace_caller)
21343
21344 ENTRY(ftrace_regs_caller)
21345 /* Save the current flags before compare (in SS location)*/
21346 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21347 popfq
21348 jmp ftrace_stub
21349
21350 -END(ftrace_regs_caller)
21351 +ENDPROC(ftrace_regs_caller)
21352
21353
21354 #else /* ! CONFIG_DYNAMIC_FTRACE */
21355 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21356 #endif
21357
21358 GLOBAL(ftrace_stub)
21359 + pax_force_retaddr
21360 retq
21361
21362 trace:
21363 @@ -225,12 +230,13 @@ trace:
21364 #endif
21365 subq $MCOUNT_INSN_SIZE, %rdi
21366
21367 + pax_force_fptr ftrace_trace_function
21368 call *ftrace_trace_function
21369
21370 MCOUNT_RESTORE_FRAME
21371
21372 jmp ftrace_stub
21373 -END(function_hook)
21374 +ENDPROC(function_hook)
21375 #endif /* CONFIG_DYNAMIC_FTRACE */
21376 #endif /* CONFIG_FUNCTION_TRACER */
21377
21378 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21379
21380 MCOUNT_RESTORE_FRAME
21381
21382 + pax_force_retaddr
21383 retq
21384 -END(ftrace_graph_caller)
21385 +ENDPROC(ftrace_graph_caller)
21386
21387 GLOBAL(return_to_handler)
21388 subq $24, %rsp
21389 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21390 movq 8(%rsp), %rdx
21391 movq (%rsp), %rax
21392 addq $24, %rsp
21393 + pax_force_fptr %rdi
21394 jmp *%rdi
21395 +ENDPROC(return_to_handler)
21396 #endif
21397
21398
21399 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21400 ENDPROC(native_usergs_sysret64)
21401 #endif /* CONFIG_PARAVIRT */
21402
21403 + .macro ljmpq sel, off
21404 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21405 + .byte 0x48; ljmp *1234f(%rip)
21406 + .pushsection .rodata
21407 + .align 16
21408 + 1234: .quad \off; .word \sel
21409 + .popsection
21410 +#else
21411 + pushq $\sel
21412 + pushq $\off
21413 + lretq
21414 +#endif
21415 + .endm
21416 +
21417 + .macro pax_enter_kernel
21418 + pax_set_fptr_mask
21419 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21420 + call pax_enter_kernel
21421 +#endif
21422 + .endm
21423 +
21424 + .macro pax_exit_kernel
21425 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21426 + call pax_exit_kernel
21427 +#endif
21428 +
21429 + .endm
21430 +
21431 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21432 +ENTRY(pax_enter_kernel)
21433 + pushq %rdi
21434 +
21435 +#ifdef CONFIG_PARAVIRT
21436 + PV_SAVE_REGS(CLBR_RDI)
21437 +#endif
21438 +
21439 +#ifdef CONFIG_PAX_KERNEXEC
21440 + GET_CR0_INTO_RDI
21441 + bts $16,%rdi
21442 + jnc 3f
21443 + mov %cs,%edi
21444 + cmp $__KERNEL_CS,%edi
21445 + jnz 2f
21446 +1:
21447 +#endif
21448 +
21449 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21450 + 661: jmp 111f
21451 + .pushsection .altinstr_replacement, "a"
21452 + 662: ASM_NOP2
21453 + .popsection
21454 + .pushsection .altinstructions, "a"
21455 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21456 + .popsection
21457 + GET_CR3_INTO_RDI
21458 + cmp $0,%dil
21459 + jnz 112f
21460 + mov $__KERNEL_DS,%edi
21461 + mov %edi,%ss
21462 + jmp 111f
21463 +112: cmp $1,%dil
21464 + jz 113f
21465 + ud2
21466 +113: sub $4097,%rdi
21467 + bts $63,%rdi
21468 + SET_RDI_INTO_CR3
21469 + mov $__UDEREF_KERNEL_DS,%edi
21470 + mov %edi,%ss
21471 +111:
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PARAVIRT
21475 + PV_RESTORE_REGS(CLBR_RDI)
21476 +#endif
21477 +
21478 + popq %rdi
21479 + pax_force_retaddr
21480 + retq
21481 +
21482 +#ifdef CONFIG_PAX_KERNEXEC
21483 +2: ljmpq __KERNEL_CS,1b
21484 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21485 +4: SET_RDI_INTO_CR0
21486 + jmp 1b
21487 +#endif
21488 +ENDPROC(pax_enter_kernel)
21489 +
21490 +ENTRY(pax_exit_kernel)
21491 + pushq %rdi
21492 +
21493 +#ifdef CONFIG_PARAVIRT
21494 + PV_SAVE_REGS(CLBR_RDI)
21495 +#endif
21496 +
21497 +#ifdef CONFIG_PAX_KERNEXEC
21498 + mov %cs,%rdi
21499 + cmp $__KERNEXEC_KERNEL_CS,%edi
21500 + jz 2f
21501 + GET_CR0_INTO_RDI
21502 + bts $16,%rdi
21503 + jnc 4f
21504 +1:
21505 +#endif
21506 +
21507 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21508 + 661: jmp 111f
21509 + .pushsection .altinstr_replacement, "a"
21510 + 662: ASM_NOP2
21511 + .popsection
21512 + .pushsection .altinstructions, "a"
21513 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21514 + .popsection
21515 + mov %ss,%edi
21516 + cmp $__UDEREF_KERNEL_DS,%edi
21517 + jnz 111f
21518 + GET_CR3_INTO_RDI
21519 + cmp $0,%dil
21520 + jz 112f
21521 + ud2
21522 +112: add $4097,%rdi
21523 + bts $63,%rdi
21524 + SET_RDI_INTO_CR3
21525 + mov $__KERNEL_DS,%edi
21526 + mov %edi,%ss
21527 +111:
21528 +#endif
21529 +
21530 +#ifdef CONFIG_PARAVIRT
21531 + PV_RESTORE_REGS(CLBR_RDI);
21532 +#endif
21533 +
21534 + popq %rdi
21535 + pax_force_retaddr
21536 + retq
21537 +
21538 +#ifdef CONFIG_PAX_KERNEXEC
21539 +2: GET_CR0_INTO_RDI
21540 + btr $16,%rdi
21541 + jnc 4f
21542 + ljmpq __KERNEL_CS,3f
21543 +3: SET_RDI_INTO_CR0
21544 + jmp 1b
21545 +4: ud2
21546 + jmp 4b
21547 +#endif
21548 +ENDPROC(pax_exit_kernel)
21549 +#endif
21550 +
21551 + .macro pax_enter_kernel_user
21552 + pax_set_fptr_mask
21553 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21554 + call pax_enter_kernel_user
21555 +#endif
21556 + .endm
21557 +
21558 + .macro pax_exit_kernel_user
21559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21560 + call pax_exit_kernel_user
21561 +#endif
21562 +#ifdef CONFIG_PAX_RANDKSTACK
21563 + pushq %rax
21564 + pushq %r11
21565 + call pax_randomize_kstack
21566 + popq %r11
21567 + popq %rax
21568 +#endif
21569 + .endm
21570 +
21571 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21572 +ENTRY(pax_enter_kernel_user)
21573 + pushq %rdi
21574 + pushq %rbx
21575 +
21576 +#ifdef CONFIG_PARAVIRT
21577 + PV_SAVE_REGS(CLBR_RDI)
21578 +#endif
21579 +
21580 + 661: jmp 111f
21581 + .pushsection .altinstr_replacement, "a"
21582 + 662: ASM_NOP2
21583 + .popsection
21584 + .pushsection .altinstructions, "a"
21585 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21586 + .popsection
21587 + GET_CR3_INTO_RDI
21588 + cmp $1,%dil
21589 + jnz 4f
21590 + sub $4097,%rdi
21591 + bts $63,%rdi
21592 + SET_RDI_INTO_CR3
21593 + jmp 3f
21594 +111:
21595 +
21596 + GET_CR3_INTO_RDI
21597 + mov %rdi,%rbx
21598 + add $__START_KERNEL_map,%rbx
21599 + sub phys_base(%rip),%rbx
21600 +
21601 +#ifdef CONFIG_PARAVIRT
21602 + cmpl $0, pv_info+PARAVIRT_enabled
21603 + jz 1f
21604 + pushq %rdi
21605 + i = 0
21606 + .rept USER_PGD_PTRS
21607 + mov i*8(%rbx),%rsi
21608 + mov $0,%sil
21609 + lea i*8(%rbx),%rdi
21610 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21611 + i = i + 1
21612 + .endr
21613 + popq %rdi
21614 + jmp 2f
21615 +1:
21616 +#endif
21617 +
21618 + i = 0
21619 + .rept USER_PGD_PTRS
21620 + movb $0,i*8(%rbx)
21621 + i = i + 1
21622 + .endr
21623 +
21624 +2: SET_RDI_INTO_CR3
21625 +
21626 +#ifdef CONFIG_PAX_KERNEXEC
21627 + GET_CR0_INTO_RDI
21628 + bts $16,%rdi
21629 + SET_RDI_INTO_CR0
21630 +#endif
21631 +
21632 +3:
21633 +
21634 +#ifdef CONFIG_PARAVIRT
21635 + PV_RESTORE_REGS(CLBR_RDI)
21636 +#endif
21637 +
21638 + popq %rbx
21639 + popq %rdi
21640 + pax_force_retaddr
21641 + retq
21642 +4: ud2
21643 +ENDPROC(pax_enter_kernel_user)
21644 +
21645 +ENTRY(pax_exit_kernel_user)
21646 + pushq %rdi
21647 + pushq %rbx
21648 +
21649 +#ifdef CONFIG_PARAVIRT
21650 + PV_SAVE_REGS(CLBR_RDI)
21651 +#endif
21652 +
21653 + GET_CR3_INTO_RDI
21654 + 661: jmp 1f
21655 + .pushsection .altinstr_replacement, "a"
21656 + 662: ASM_NOP2
21657 + .popsection
21658 + .pushsection .altinstructions, "a"
21659 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21660 + .popsection
21661 + cmp $0,%dil
21662 + jnz 3f
21663 + add $4097,%rdi
21664 + bts $63,%rdi
21665 + SET_RDI_INTO_CR3
21666 + jmp 2f
21667 +1:
21668 +
21669 + mov %rdi,%rbx
21670 +
21671 +#ifdef CONFIG_PAX_KERNEXEC
21672 + GET_CR0_INTO_RDI
21673 + btr $16,%rdi
21674 + jnc 3f
21675 + SET_RDI_INTO_CR0
21676 +#endif
21677 +
21678 + add $__START_KERNEL_map,%rbx
21679 + sub phys_base(%rip),%rbx
21680 +
21681 +#ifdef CONFIG_PARAVIRT
21682 + cmpl $0, pv_info+PARAVIRT_enabled
21683 + jz 1f
21684 + i = 0
21685 + .rept USER_PGD_PTRS
21686 + mov i*8(%rbx),%rsi
21687 + mov $0x67,%sil
21688 + lea i*8(%rbx),%rdi
21689 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21690 + i = i + 1
21691 + .endr
21692 + jmp 2f
21693 +1:
21694 +#endif
21695 +
21696 + i = 0
21697 + .rept USER_PGD_PTRS
21698 + movb $0x67,i*8(%rbx)
21699 + i = i + 1
21700 + .endr
21701 +2:
21702 +
21703 +#ifdef CONFIG_PARAVIRT
21704 + PV_RESTORE_REGS(CLBR_RDI)
21705 +#endif
21706 +
21707 + popq %rbx
21708 + popq %rdi
21709 + pax_force_retaddr
21710 + retq
21711 +3: ud2
21712 +ENDPROC(pax_exit_kernel_user)
21713 +#endif
21714 +
21715 + .macro pax_enter_kernel_nmi
21716 + pax_set_fptr_mask
21717 +
21718 +#ifdef CONFIG_PAX_KERNEXEC
21719 + GET_CR0_INTO_RDI
21720 + bts $16,%rdi
21721 + jc 110f
21722 + SET_RDI_INTO_CR0
21723 + or $2,%ebx
21724 +110:
21725 +#endif
21726 +
21727 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21728 + 661: jmp 111f
21729 + .pushsection .altinstr_replacement, "a"
21730 + 662: ASM_NOP2
21731 + .popsection
21732 + .pushsection .altinstructions, "a"
21733 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21734 + .popsection
21735 + GET_CR3_INTO_RDI
21736 + cmp $0,%dil
21737 + jz 111f
21738 + sub $4097,%rdi
21739 + or $4,%ebx
21740 + bts $63,%rdi
21741 + SET_RDI_INTO_CR3
21742 + mov $__UDEREF_KERNEL_DS,%edi
21743 + mov %edi,%ss
21744 +111:
21745 +#endif
21746 + .endm
21747 +
21748 + .macro pax_exit_kernel_nmi
21749 +#ifdef CONFIG_PAX_KERNEXEC
21750 + btr $1,%ebx
21751 + jnc 110f
21752 + GET_CR0_INTO_RDI
21753 + btr $16,%rdi
21754 + SET_RDI_INTO_CR0
21755 +110:
21756 +#endif
21757 +
21758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21759 + btr $2,%ebx
21760 + jnc 111f
21761 + GET_CR3_INTO_RDI
21762 + add $4097,%rdi
21763 + bts $63,%rdi
21764 + SET_RDI_INTO_CR3
21765 + mov $__KERNEL_DS,%edi
21766 + mov %edi,%ss
21767 +111:
21768 +#endif
21769 + .endm
21770 +
21771 + .macro pax_erase_kstack
21772 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21773 + call pax_erase_kstack
21774 +#endif
21775 + .endm
21776 +
21777 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21778 +ENTRY(pax_erase_kstack)
21779 + pushq %rdi
21780 + pushq %rcx
21781 + pushq %rax
21782 + pushq %r11
21783 +
21784 + GET_THREAD_INFO(%r11)
21785 + mov TI_lowest_stack(%r11), %rdi
21786 + mov $-0xBEEF, %rax
21787 + std
21788 +
21789 +1: mov %edi, %ecx
21790 + and $THREAD_SIZE_asm - 1, %ecx
21791 + shr $3, %ecx
21792 + repne scasq
21793 + jecxz 2f
21794 +
21795 + cmp $2*8, %ecx
21796 + jc 2f
21797 +
21798 + mov $2*8, %ecx
21799 + repe scasq
21800 + jecxz 2f
21801 + jne 1b
21802 +
21803 +2: cld
21804 + mov %esp, %ecx
21805 + sub %edi, %ecx
21806 +
21807 + cmp $THREAD_SIZE_asm, %rcx
21808 + jb 3f
21809 + ud2
21810 +3:
21811 +
21812 + shr $3, %ecx
21813 + rep stosq
21814 +
21815 + mov TI_task_thread_sp0(%r11), %rdi
21816 + sub $256, %rdi
21817 + mov %rdi, TI_lowest_stack(%r11)
21818 +
21819 + popq %r11
21820 + popq %rax
21821 + popq %rcx
21822 + popq %rdi
21823 + pax_force_retaddr
21824 + ret
21825 +ENDPROC(pax_erase_kstack)
21826 +#endif
21827
21828 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21829 #ifdef CONFIG_TRACE_IRQFLAGS
21830 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21831 .endm
21832
21833 .macro UNFAKE_STACK_FRAME
21834 - addq $8*6, %rsp
21835 - CFI_ADJUST_CFA_OFFSET -(6*8)
21836 + addq $8*6 + ARG_SKIP, %rsp
21837 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21838 .endm
21839
21840 /*
21841 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21842 movq %rsp, %rsi
21843
21844 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21845 - testl $3, CS-RBP(%rsi)
21846 + testb $3, CS-RBP(%rsi)
21847 je 1f
21848 SWAPGS
21849 /*
21850 @@ -514,9 +947,10 @@ ENTRY(save_paranoid)
21851 js 1f /* negative -> in kernel */
21852 SWAPGS
21853 xorl %ebx,%ebx
21854 -1: ret
21855 +1: pax_force_retaddr_bts
21856 + ret
21857 CFI_ENDPROC
21858 -END(save_paranoid)
21859 +ENDPROC(save_paranoid)
21860 .popsection
21861
21862 /*
21863 @@ -538,7 +972,7 @@ ENTRY(ret_from_fork)
21864
21865 RESTORE_REST
21866
21867 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21868 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21869 jz 1f
21870
21871 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21872 @@ -556,7 +990,7 @@ ENTRY(ret_from_fork)
21873 RESTORE_REST
21874 jmp int_ret_from_sys_call
21875 CFI_ENDPROC
21876 -END(ret_from_fork)
21877 +ENDPROC(ret_from_fork)
21878
21879 /*
21880 * System call entry. Up to 6 arguments in registers are supported.
21881 @@ -593,7 +1027,7 @@ END(ret_from_fork)
21882 ENTRY(system_call)
21883 CFI_STARTPROC simple
21884 CFI_SIGNAL_FRAME
21885 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21886 + CFI_DEF_CFA rsp,0
21887 CFI_REGISTER rip,rcx
21888 /*CFI_REGISTER rflags,r11*/
21889 SWAPGS_UNSAFE_STACK
21890 @@ -606,16 +1040,23 @@ GLOBAL(system_call_after_swapgs)
21891
21892 movq %rsp,PER_CPU_VAR(old_rsp)
21893 movq PER_CPU_VAR(kernel_stack),%rsp
21894 + SAVE_ARGS 8*6,0
21895 + pax_enter_kernel_user
21896 +
21897 +#ifdef CONFIG_PAX_RANDKSTACK
21898 + pax_erase_kstack
21899 +#endif
21900 +
21901 /*
21902 * No need to follow this irqs off/on section - it's straight
21903 * and short:
21904 */
21905 ENABLE_INTERRUPTS(CLBR_NONE)
21906 - SAVE_ARGS 8,0
21907 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21908 movq %rcx,RIP-ARGOFFSET(%rsp)
21909 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21910 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21911 + GET_THREAD_INFO(%rcx)
21912 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21913 jnz tracesys
21914 system_call_fastpath:
21915 #if __SYSCALL_MASK == ~0
21916 @@ -625,7 +1066,7 @@ system_call_fastpath:
21917 cmpl $__NR_syscall_max,%eax
21918 #endif
21919 ja badsys
21920 - movq %r10,%rcx
21921 + movq R10-ARGOFFSET(%rsp),%rcx
21922 call *sys_call_table(,%rax,8) # XXX: rip relative
21923 movq %rax,RAX-ARGOFFSET(%rsp)
21924 /*
21925 @@ -639,10 +1080,13 @@ sysret_check:
21926 LOCKDEP_SYS_EXIT
21927 DISABLE_INTERRUPTS(CLBR_NONE)
21928 TRACE_IRQS_OFF
21929 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21930 + GET_THREAD_INFO(%rcx)
21931 + movl TI_flags(%rcx),%edx
21932 andl %edi,%edx
21933 jnz sysret_careful
21934 CFI_REMEMBER_STATE
21935 + pax_exit_kernel_user
21936 + pax_erase_kstack
21937 /*
21938 * sysretq will re-enable interrupts:
21939 */
21940 @@ -694,14 +1138,18 @@ badsys:
21941 * jump back to the normal fast path.
21942 */
21943 auditsys:
21944 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21945 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21946 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21947 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21948 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21949 movq %rax,%rsi /* 2nd arg: syscall number */
21950 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21951 call __audit_syscall_entry
21952 +
21953 + pax_erase_kstack
21954 +
21955 LOAD_ARGS 0 /* reload call-clobbered registers */
21956 + pax_set_fptr_mask
21957 jmp system_call_fastpath
21958
21959 /*
21960 @@ -722,7 +1170,7 @@ sysret_audit:
21961 /* Do syscall tracing */
21962 tracesys:
21963 #ifdef CONFIG_AUDITSYSCALL
21964 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21965 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21966 jz auditsys
21967 #endif
21968 SAVE_REST
21969 @@ -730,12 +1178,16 @@ tracesys:
21970 FIXUP_TOP_OF_STACK %rdi
21971 movq %rsp,%rdi
21972 call syscall_trace_enter
21973 +
21974 + pax_erase_kstack
21975 +
21976 /*
21977 * Reload arg registers from stack in case ptrace changed them.
21978 * We don't reload %rax because syscall_trace_enter() returned
21979 * the value it wants us to use in the table lookup.
21980 */
21981 LOAD_ARGS ARGOFFSET, 1
21982 + pax_set_fptr_mask
21983 RESTORE_REST
21984 #if __SYSCALL_MASK == ~0
21985 cmpq $__NR_syscall_max,%rax
21986 @@ -744,7 +1196,7 @@ tracesys:
21987 cmpl $__NR_syscall_max,%eax
21988 #endif
21989 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21990 - movq %r10,%rcx /* fixup for C */
21991 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21992 call *sys_call_table(,%rax,8)
21993 movq %rax,RAX-ARGOFFSET(%rsp)
21994 /* Use IRET because user could have changed frame */
21995 @@ -765,7 +1217,9 @@ GLOBAL(int_with_check)
21996 andl %edi,%edx
21997 jnz int_careful
21998 andl $~TS_COMPAT,TI_status(%rcx)
21999 - jmp retint_swapgs
22000 + pax_exit_kernel_user
22001 + pax_erase_kstack
22002 + jmp retint_swapgs_pax
22003
22004 /* Either reschedule or signal or syscall exit tracking needed. */
22005 /* First do a reschedule test. */
22006 @@ -811,7 +1265,7 @@ int_restore_rest:
22007 TRACE_IRQS_OFF
22008 jmp int_with_check
22009 CFI_ENDPROC
22010 -END(system_call)
22011 +ENDPROC(system_call)
22012
22013 .macro FORK_LIKE func
22014 ENTRY(stub_\func)
22015 @@ -824,9 +1278,10 @@ ENTRY(stub_\func)
22016 DEFAULT_FRAME 0 8 /* offset 8: return address */
22017 call sys_\func
22018 RESTORE_TOP_OF_STACK %r11, 8
22019 + pax_force_retaddr
22020 ret $REST_SKIP /* pop extended registers */
22021 CFI_ENDPROC
22022 -END(stub_\func)
22023 +ENDPROC(stub_\func)
22024 .endm
22025
22026 .macro FIXED_FRAME label,func
22027 @@ -836,9 +1291,10 @@ ENTRY(\label)
22028 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22029 call \func
22030 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22031 + pax_force_retaddr
22032 ret
22033 CFI_ENDPROC
22034 -END(\label)
22035 +ENDPROC(\label)
22036 .endm
22037
22038 FORK_LIKE clone
22039 @@ -855,9 +1311,10 @@ ENTRY(ptregscall_common)
22040 movq_cfi_restore R12+8, r12
22041 movq_cfi_restore RBP+8, rbp
22042 movq_cfi_restore RBX+8, rbx
22043 + pax_force_retaddr
22044 ret $REST_SKIP /* pop extended registers */
22045 CFI_ENDPROC
22046 -END(ptregscall_common)
22047 +ENDPROC(ptregscall_common)
22048
22049 ENTRY(stub_execve)
22050 CFI_STARTPROC
22051 @@ -870,7 +1327,7 @@ ENTRY(stub_execve)
22052 RESTORE_REST
22053 jmp int_ret_from_sys_call
22054 CFI_ENDPROC
22055 -END(stub_execve)
22056 +ENDPROC(stub_execve)
22057
22058 /*
22059 * sigreturn is special because it needs to restore all registers on return.
22060 @@ -887,7 +1344,7 @@ ENTRY(stub_rt_sigreturn)
22061 RESTORE_REST
22062 jmp int_ret_from_sys_call
22063 CFI_ENDPROC
22064 -END(stub_rt_sigreturn)
22065 +ENDPROC(stub_rt_sigreturn)
22066
22067 #ifdef CONFIG_X86_X32_ABI
22068 ENTRY(stub_x32_rt_sigreturn)
22069 @@ -901,7 +1358,7 @@ ENTRY(stub_x32_rt_sigreturn)
22070 RESTORE_REST
22071 jmp int_ret_from_sys_call
22072 CFI_ENDPROC
22073 -END(stub_x32_rt_sigreturn)
22074 +ENDPROC(stub_x32_rt_sigreturn)
22075
22076 ENTRY(stub_x32_execve)
22077 CFI_STARTPROC
22078 @@ -915,7 +1372,7 @@ ENTRY(stub_x32_execve)
22079 RESTORE_REST
22080 jmp int_ret_from_sys_call
22081 CFI_ENDPROC
22082 -END(stub_x32_execve)
22083 +ENDPROC(stub_x32_execve)
22084
22085 #endif
22086
22087 @@ -952,7 +1409,7 @@ vector=vector+1
22088 2: jmp common_interrupt
22089 .endr
22090 CFI_ENDPROC
22091 -END(irq_entries_start)
22092 +ENDPROC(irq_entries_start)
22093
22094 .previous
22095 END(interrupt)
22096 @@ -972,6 +1429,16 @@ END(interrupt)
22097 subq $ORIG_RAX-RBP, %rsp
22098 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22099 SAVE_ARGS_IRQ
22100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22101 + testb $3, CS(%rdi)
22102 + jnz 1f
22103 + pax_enter_kernel
22104 + jmp 2f
22105 +1: pax_enter_kernel_user
22106 +2:
22107 +#else
22108 + pax_enter_kernel
22109 +#endif
22110 call \func
22111 .endm
22112
22113 @@ -1004,7 +1471,7 @@ ret_from_intr:
22114
22115 exit_intr:
22116 GET_THREAD_INFO(%rcx)
22117 - testl $3,CS-ARGOFFSET(%rsp)
22118 + testb $3,CS-ARGOFFSET(%rsp)
22119 je retint_kernel
22120
22121 /* Interrupt came from user space */
22122 @@ -1026,12 +1493,16 @@ retint_swapgs: /* return to user-space */
22123 * The iretq could re-enable interrupts:
22124 */
22125 DISABLE_INTERRUPTS(CLBR_ANY)
22126 + pax_exit_kernel_user
22127 +retint_swapgs_pax:
22128 TRACE_IRQS_IRETQ
22129 SWAPGS
22130 jmp restore_args
22131
22132 retint_restore_args: /* return to kernel space */
22133 DISABLE_INTERRUPTS(CLBR_ANY)
22134 + pax_exit_kernel
22135 + pax_force_retaddr (RIP-ARGOFFSET)
22136 /*
22137 * The iretq could re-enable interrupts:
22138 */
22139 @@ -1114,7 +1585,7 @@ ENTRY(retint_kernel)
22140 #endif
22141
22142 CFI_ENDPROC
22143 -END(common_interrupt)
22144 +ENDPROC(common_interrupt)
22145 /*
22146 * End of kprobes section
22147 */
22148 @@ -1132,7 +1603,7 @@ ENTRY(\sym)
22149 interrupt \do_sym
22150 jmp ret_from_intr
22151 CFI_ENDPROC
22152 -END(\sym)
22153 +ENDPROC(\sym)
22154 .endm
22155
22156 #ifdef CONFIG_TRACING
22157 @@ -1215,12 +1686,22 @@ ENTRY(\sym)
22158 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22159 call error_entry
22160 DEFAULT_FRAME 0
22161 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22162 + testb $3, CS(%rsp)
22163 + jnz 1f
22164 + pax_enter_kernel
22165 + jmp 2f
22166 +1: pax_enter_kernel_user
22167 +2:
22168 +#else
22169 + pax_enter_kernel
22170 +#endif
22171 movq %rsp,%rdi /* pt_regs pointer */
22172 xorl %esi,%esi /* no error code */
22173 call \do_sym
22174 jmp error_exit /* %ebx: no swapgs flag */
22175 CFI_ENDPROC
22176 -END(\sym)
22177 +ENDPROC(\sym)
22178 .endm
22179
22180 .macro paranoidzeroentry sym do_sym
22181 @@ -1233,15 +1714,25 @@ ENTRY(\sym)
22182 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22183 call save_paranoid
22184 TRACE_IRQS_OFF
22185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22186 + testb $3, CS(%rsp)
22187 + jnz 1f
22188 + pax_enter_kernel
22189 + jmp 2f
22190 +1: pax_enter_kernel_user
22191 +2:
22192 +#else
22193 + pax_enter_kernel
22194 +#endif
22195 movq %rsp,%rdi /* pt_regs pointer */
22196 xorl %esi,%esi /* no error code */
22197 call \do_sym
22198 jmp paranoid_exit /* %ebx: no swapgs flag */
22199 CFI_ENDPROC
22200 -END(\sym)
22201 +ENDPROC(\sym)
22202 .endm
22203
22204 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22205 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22206 .macro paranoidzeroentry_ist sym do_sym ist
22207 ENTRY(\sym)
22208 INTR_FRAME
22209 @@ -1252,14 +1743,30 @@ ENTRY(\sym)
22210 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22211 call save_paranoid
22212 TRACE_IRQS_OFF_DEBUG
22213 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22214 + testb $3, CS(%rsp)
22215 + jnz 1f
22216 + pax_enter_kernel
22217 + jmp 2f
22218 +1: pax_enter_kernel_user
22219 +2:
22220 +#else
22221 + pax_enter_kernel
22222 +#endif
22223 movq %rsp,%rdi /* pt_regs pointer */
22224 xorl %esi,%esi /* no error code */
22225 +#ifdef CONFIG_SMP
22226 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22227 + lea init_tss(%r12), %r12
22228 +#else
22229 + lea init_tss(%rip), %r12
22230 +#endif
22231 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22232 call \do_sym
22233 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22234 jmp paranoid_exit /* %ebx: no swapgs flag */
22235 CFI_ENDPROC
22236 -END(\sym)
22237 +ENDPROC(\sym)
22238 .endm
22239
22240 .macro errorentry sym do_sym
22241 @@ -1271,13 +1778,23 @@ ENTRY(\sym)
22242 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22243 call error_entry
22244 DEFAULT_FRAME 0
22245 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22246 + testb $3, CS(%rsp)
22247 + jnz 1f
22248 + pax_enter_kernel
22249 + jmp 2f
22250 +1: pax_enter_kernel_user
22251 +2:
22252 +#else
22253 + pax_enter_kernel
22254 +#endif
22255 movq %rsp,%rdi /* pt_regs pointer */
22256 movq ORIG_RAX(%rsp),%rsi /* get error code */
22257 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22258 call \do_sym
22259 jmp error_exit /* %ebx: no swapgs flag */
22260 CFI_ENDPROC
22261 -END(\sym)
22262 +ENDPROC(\sym)
22263 .endm
22264
22265 /* error code is on the stack already */
22266 @@ -1291,13 +1808,23 @@ ENTRY(\sym)
22267 call save_paranoid
22268 DEFAULT_FRAME 0
22269 TRACE_IRQS_OFF
22270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22271 + testb $3, CS(%rsp)
22272 + jnz 1f
22273 + pax_enter_kernel
22274 + jmp 2f
22275 +1: pax_enter_kernel_user
22276 +2:
22277 +#else
22278 + pax_enter_kernel
22279 +#endif
22280 movq %rsp,%rdi /* pt_regs pointer */
22281 movq ORIG_RAX(%rsp),%rsi /* get error code */
22282 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22283 call \do_sym
22284 jmp paranoid_exit /* %ebx: no swapgs flag */
22285 CFI_ENDPROC
22286 -END(\sym)
22287 +ENDPROC(\sym)
22288 .endm
22289
22290 zeroentry divide_error do_divide_error
22291 @@ -1327,9 +1854,10 @@ gs_change:
22292 2: mfence /* workaround */
22293 SWAPGS
22294 popfq_cfi
22295 + pax_force_retaddr
22296 ret
22297 CFI_ENDPROC
22298 -END(native_load_gs_index)
22299 +ENDPROC(native_load_gs_index)
22300
22301 _ASM_EXTABLE(gs_change,bad_gs)
22302 .section .fixup,"ax"
22303 @@ -1357,9 +1885,10 @@ ENTRY(call_softirq)
22304 CFI_DEF_CFA_REGISTER rsp
22305 CFI_ADJUST_CFA_OFFSET -8
22306 decl PER_CPU_VAR(irq_count)
22307 + pax_force_retaddr
22308 ret
22309 CFI_ENDPROC
22310 -END(call_softirq)
22311 +ENDPROC(call_softirq)
22312
22313 #ifdef CONFIG_XEN
22314 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22315 @@ -1397,7 +1926,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22316 decl PER_CPU_VAR(irq_count)
22317 jmp error_exit
22318 CFI_ENDPROC
22319 -END(xen_do_hypervisor_callback)
22320 +ENDPROC(xen_do_hypervisor_callback)
22321
22322 /*
22323 * Hypervisor uses this for application faults while it executes.
22324 @@ -1456,7 +1985,7 @@ ENTRY(xen_failsafe_callback)
22325 SAVE_ALL
22326 jmp error_exit
22327 CFI_ENDPROC
22328 -END(xen_failsafe_callback)
22329 +ENDPROC(xen_failsafe_callback)
22330
22331 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22332 xen_hvm_callback_vector xen_evtchn_do_upcall
22333 @@ -1508,18 +2037,33 @@ ENTRY(paranoid_exit)
22334 DEFAULT_FRAME
22335 DISABLE_INTERRUPTS(CLBR_NONE)
22336 TRACE_IRQS_OFF_DEBUG
22337 - testl %ebx,%ebx /* swapgs needed? */
22338 + testl $1,%ebx /* swapgs needed? */
22339 jnz paranoid_restore
22340 - testl $3,CS(%rsp)
22341 + testb $3,CS(%rsp)
22342 jnz paranoid_userspace
22343 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22344 + pax_exit_kernel
22345 + TRACE_IRQS_IRETQ 0
22346 + SWAPGS_UNSAFE_STACK
22347 + RESTORE_ALL 8
22348 + pax_force_retaddr_bts
22349 + jmp irq_return
22350 +#endif
22351 paranoid_swapgs:
22352 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22353 + pax_exit_kernel_user
22354 +#else
22355 + pax_exit_kernel
22356 +#endif
22357 TRACE_IRQS_IRETQ 0
22358 SWAPGS_UNSAFE_STACK
22359 RESTORE_ALL 8
22360 jmp irq_return
22361 paranoid_restore:
22362 + pax_exit_kernel
22363 TRACE_IRQS_IRETQ_DEBUG 0
22364 RESTORE_ALL 8
22365 + pax_force_retaddr_bts
22366 jmp irq_return
22367 paranoid_userspace:
22368 GET_THREAD_INFO(%rcx)
22369 @@ -1548,7 +2092,7 @@ paranoid_schedule:
22370 TRACE_IRQS_OFF
22371 jmp paranoid_userspace
22372 CFI_ENDPROC
22373 -END(paranoid_exit)
22374 +ENDPROC(paranoid_exit)
22375
22376 /*
22377 * Exception entry point. This expects an error code/orig_rax on the stack.
22378 @@ -1575,12 +2119,13 @@ ENTRY(error_entry)
22379 movq_cfi r14, R14+8
22380 movq_cfi r15, R15+8
22381 xorl %ebx,%ebx
22382 - testl $3,CS+8(%rsp)
22383 + testb $3,CS+8(%rsp)
22384 je error_kernelspace
22385 error_swapgs:
22386 SWAPGS
22387 error_sti:
22388 TRACE_IRQS_OFF
22389 + pax_force_retaddr_bts
22390 ret
22391
22392 /*
22393 @@ -1607,7 +2152,7 @@ bstep_iret:
22394 movq %rcx,RIP+8(%rsp)
22395 jmp error_swapgs
22396 CFI_ENDPROC
22397 -END(error_entry)
22398 +ENDPROC(error_entry)
22399
22400
22401 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22402 @@ -1618,7 +2163,7 @@ ENTRY(error_exit)
22403 DISABLE_INTERRUPTS(CLBR_NONE)
22404 TRACE_IRQS_OFF
22405 GET_THREAD_INFO(%rcx)
22406 - testl %eax,%eax
22407 + testl $1,%eax
22408 jne retint_kernel
22409 LOCKDEP_SYS_EXIT_IRQ
22410 movl TI_flags(%rcx),%edx
22411 @@ -1627,7 +2172,7 @@ ENTRY(error_exit)
22412 jnz retint_careful
22413 jmp retint_swapgs
22414 CFI_ENDPROC
22415 -END(error_exit)
22416 +ENDPROC(error_exit)
22417
22418 /*
22419 * Test if a given stack is an NMI stack or not.
22420 @@ -1685,9 +2230,11 @@ ENTRY(nmi)
22421 * If %cs was not the kernel segment, then the NMI triggered in user
22422 * space, which means it is definitely not nested.
22423 */
22424 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22425 + je 1f
22426 cmpl $__KERNEL_CS, 16(%rsp)
22427 jne first_nmi
22428 -
22429 +1:
22430 /*
22431 * Check the special variable on the stack to see if NMIs are
22432 * executing.
22433 @@ -1721,8 +2268,7 @@ nested_nmi:
22434
22435 1:
22436 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22437 - leaq -1*8(%rsp), %rdx
22438 - movq %rdx, %rsp
22439 + subq $8, %rsp
22440 CFI_ADJUST_CFA_OFFSET 1*8
22441 leaq -10*8(%rsp), %rdx
22442 pushq_cfi $__KERNEL_DS
22443 @@ -1740,6 +2286,7 @@ nested_nmi_out:
22444 CFI_RESTORE rdx
22445
22446 /* No need to check faults here */
22447 +# pax_force_retaddr_bts
22448 INTERRUPT_RETURN
22449
22450 CFI_RESTORE_STATE
22451 @@ -1856,6 +2403,8 @@ end_repeat_nmi:
22452 */
22453 movq %cr2, %r12
22454
22455 + pax_enter_kernel_nmi
22456 +
22457 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22458 movq %rsp,%rdi
22459 movq $-1,%rsi
22460 @@ -1868,26 +2417,31 @@ end_repeat_nmi:
22461 movq %r12, %cr2
22462 1:
22463
22464 - testl %ebx,%ebx /* swapgs needed? */
22465 + testl $1,%ebx /* swapgs needed? */
22466 jnz nmi_restore
22467 nmi_swapgs:
22468 SWAPGS_UNSAFE_STACK
22469 nmi_restore:
22470 + pax_exit_kernel_nmi
22471 /* Pop the extra iret frame at once */
22472 RESTORE_ALL 6*8
22473 + testb $3, 8(%rsp)
22474 + jnz 1f
22475 + pax_force_retaddr_bts
22476 +1:
22477
22478 /* Clear the NMI executing stack variable */
22479 movq $0, 5*8(%rsp)
22480 jmp irq_return
22481 CFI_ENDPROC
22482 -END(nmi)
22483 +ENDPROC(nmi)
22484
22485 ENTRY(ignore_sysret)
22486 CFI_STARTPROC
22487 mov $-ENOSYS,%eax
22488 sysret
22489 CFI_ENDPROC
22490 -END(ignore_sysret)
22491 +ENDPROC(ignore_sysret)
22492
22493 /*
22494 * End of kprobes section
22495 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22496 index d4bdd25..912664c 100644
22497 --- a/arch/x86/kernel/ftrace.c
22498 +++ b/arch/x86/kernel/ftrace.c
22499 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22500 {
22501 unsigned char replaced[MCOUNT_INSN_SIZE];
22502
22503 + ip = ktla_ktva(ip);
22504 +
22505 /*
22506 * Note: Due to modules and __init, code can
22507 * disappear and change, we need to protect against faulting
22508 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22509 unsigned char old[MCOUNT_INSN_SIZE], *new;
22510 int ret;
22511
22512 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22513 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22514 new = ftrace_call_replace(ip, (unsigned long)func);
22515
22516 /* See comment above by declaration of modifying_ftrace_code */
22517 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22518 /* Also update the regs callback function */
22519 if (!ret) {
22520 ip = (unsigned long)(&ftrace_regs_call);
22521 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22522 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22523 new = ftrace_call_replace(ip, (unsigned long)func);
22524 ret = ftrace_modify_code(ip, old, new);
22525 }
22526 @@ -291,7 +293,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22527 * kernel identity mapping to modify code.
22528 */
22529 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22530 - ip = (unsigned long)__va(__pa_symbol(ip));
22531 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22532
22533 return probe_kernel_write((void *)ip, val, size);
22534 }
22535 @@ -301,7 +303,7 @@ static int add_break(unsigned long ip, const char *old)
22536 unsigned char replaced[MCOUNT_INSN_SIZE];
22537 unsigned char brk = BREAKPOINT_INSTRUCTION;
22538
22539 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22540 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22541 return -EFAULT;
22542
22543 /* Make sure it is what we expect it to be */
22544 @@ -649,7 +651,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22545 return ret;
22546
22547 fail_update:
22548 - probe_kernel_write((void *)ip, &old_code[0], 1);
22549 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22550 goto out;
22551 }
22552
22553 @@ -682,6 +684,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22554 {
22555 unsigned char code[MCOUNT_INSN_SIZE];
22556
22557 + ip = ktla_ktva(ip);
22558 +
22559 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22560 return -EFAULT;
22561
22562 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22563 index 1be8e43..d9b9ef6 100644
22564 --- a/arch/x86/kernel/head64.c
22565 +++ b/arch/x86/kernel/head64.c
22566 @@ -67,12 +67,12 @@ again:
22567 pgd = *pgd_p;
22568
22569 /*
22570 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22571 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22572 + * The use of __early_va rather than __va here is critical:
22573 + * __va would point us back into the dynamic
22574 * range and we might end up looping forever...
22575 */
22576 if (pgd)
22577 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22578 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22579 else {
22580 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22581 reset_early_page_tables();
22582 @@ -82,13 +82,13 @@ again:
22583 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22584 for (i = 0; i < PTRS_PER_PUD; i++)
22585 pud_p[i] = 0;
22586 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22587 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22588 }
22589 pud_p += pud_index(address);
22590 pud = *pud_p;
22591
22592 if (pud)
22593 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22594 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22595 else {
22596 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22597 reset_early_page_tables();
22598 @@ -98,7 +98,7 @@ again:
22599 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22600 for (i = 0; i < PTRS_PER_PMD; i++)
22601 pmd_p[i] = 0;
22602 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22603 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22604 }
22605 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22606 pmd_p[pmd_index(address)] = pmd;
22607 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
22608 if (console_loglevel == 10)
22609 early_printk("Kernel alive\n");
22610
22611 - clear_page(init_level4_pgt);
22612 /* set init_level4_pgt kernel high mapping*/
22613 init_level4_pgt[511] = early_level4_pgt[511];
22614
22615 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22616 index 81ba276..30c5411 100644
22617 --- a/arch/x86/kernel/head_32.S
22618 +++ b/arch/x86/kernel/head_32.S
22619 @@ -26,6 +26,12 @@
22620 /* Physical address */
22621 #define pa(X) ((X) - __PAGE_OFFSET)
22622
22623 +#ifdef CONFIG_PAX_KERNEXEC
22624 +#define ta(X) (X)
22625 +#else
22626 +#define ta(X) ((X) - __PAGE_OFFSET)
22627 +#endif
22628 +
22629 /*
22630 * References to members of the new_cpu_data structure.
22631 */
22632 @@ -55,11 +61,7 @@
22633 * and small than max_low_pfn, otherwise will waste some page table entries
22634 */
22635
22636 -#if PTRS_PER_PMD > 1
22637 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22638 -#else
22639 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22640 -#endif
22641 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22642
22643 /* Number of possible pages in the lowmem region */
22644 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22645 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22646 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22647
22648 /*
22649 + * Real beginning of normal "text" segment
22650 + */
22651 +ENTRY(stext)
22652 +ENTRY(_stext)
22653 +
22654 +/*
22655 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22656 * %esi points to the real-mode code as a 32-bit pointer.
22657 * CS and DS must be 4 GB flat segments, but we don't depend on
22658 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22659 * can.
22660 */
22661 __HEAD
22662 +
22663 +#ifdef CONFIG_PAX_KERNEXEC
22664 + jmp startup_32
22665 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22666 +.fill PAGE_SIZE-5,1,0xcc
22667 +#endif
22668 +
22669 ENTRY(startup_32)
22670 movl pa(stack_start),%ecx
22671
22672 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22673 2:
22674 leal -__PAGE_OFFSET(%ecx),%esp
22675
22676 +#ifdef CONFIG_SMP
22677 + movl $pa(cpu_gdt_table),%edi
22678 + movl $__per_cpu_load,%eax
22679 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22680 + rorl $16,%eax
22681 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22682 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22683 + movl $__per_cpu_end - 1,%eax
22684 + subl $__per_cpu_start,%eax
22685 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22689 + movl $NR_CPUS,%ecx
22690 + movl $pa(cpu_gdt_table),%edi
22691 +1:
22692 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22693 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22694 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22695 + addl $PAGE_SIZE_asm,%edi
22696 + loop 1b
22697 +#endif
22698 +
22699 +#ifdef CONFIG_PAX_KERNEXEC
22700 + movl $pa(boot_gdt),%edi
22701 + movl $__LOAD_PHYSICAL_ADDR,%eax
22702 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22703 + rorl $16,%eax
22704 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22705 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22706 + rorl $16,%eax
22707 +
22708 + ljmp $(__BOOT_CS),$1f
22709 +1:
22710 +
22711 + movl $NR_CPUS,%ecx
22712 + movl $pa(cpu_gdt_table),%edi
22713 + addl $__PAGE_OFFSET,%eax
22714 +1:
22715 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22716 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22717 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22718 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22719 + rorl $16,%eax
22720 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22721 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22722 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22723 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22724 + rorl $16,%eax
22725 + addl $PAGE_SIZE_asm,%edi
22726 + loop 1b
22727 +#endif
22728 +
22729 /*
22730 * Clear BSS first so that there are no surprises...
22731 */
22732 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22733 movl %eax, pa(max_pfn_mapped)
22734
22735 /* Do early initialization of the fixmap area */
22736 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22737 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22738 +#ifdef CONFIG_COMPAT_VDSO
22739 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22740 +#else
22741 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22742 +#endif
22743 #else /* Not PAE */
22744
22745 page_pde_offset = (__PAGE_OFFSET >> 20);
22746 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22747 movl %eax, pa(max_pfn_mapped)
22748
22749 /* Do early initialization of the fixmap area */
22750 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22751 - movl %eax,pa(initial_page_table+0xffc)
22752 +#ifdef CONFIG_COMPAT_VDSO
22753 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22754 +#else
22755 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22756 +#endif
22757 #endif
22758
22759 #ifdef CONFIG_PARAVIRT
22760 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22761 cmpl $num_subarch_entries, %eax
22762 jae bad_subarch
22763
22764 - movl pa(subarch_entries)(,%eax,4), %eax
22765 - subl $__PAGE_OFFSET, %eax
22766 - jmp *%eax
22767 + jmp *pa(subarch_entries)(,%eax,4)
22768
22769 bad_subarch:
22770 WEAK(lguest_entry)
22771 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22772 __INITDATA
22773
22774 subarch_entries:
22775 - .long default_entry /* normal x86/PC */
22776 - .long lguest_entry /* lguest hypervisor */
22777 - .long xen_entry /* Xen hypervisor */
22778 - .long default_entry /* Moorestown MID */
22779 + .long ta(default_entry) /* normal x86/PC */
22780 + .long ta(lguest_entry) /* lguest hypervisor */
22781 + .long ta(xen_entry) /* Xen hypervisor */
22782 + .long ta(default_entry) /* Moorestown MID */
22783 num_subarch_entries = (. - subarch_entries) / 4
22784 .previous
22785 #else
22786 @@ -354,6 +426,7 @@ default_entry:
22787 movl pa(mmu_cr4_features),%eax
22788 movl %eax,%cr4
22789
22790 +#ifdef CONFIG_X86_PAE
22791 testb $X86_CR4_PAE, %al # check if PAE is enabled
22792 jz enable_paging
22793
22794 @@ -382,6 +455,9 @@ default_entry:
22795 /* Make changes effective */
22796 wrmsr
22797
22798 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22799 +#endif
22800 +
22801 enable_paging:
22802
22803 /*
22804 @@ -449,14 +525,20 @@ is486:
22805 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22806 movl %eax,%ss # after changing gdt.
22807
22808 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22809 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22810 movl %eax,%ds
22811 movl %eax,%es
22812
22813 movl $(__KERNEL_PERCPU), %eax
22814 movl %eax,%fs # set this cpu's percpu
22815
22816 +#ifdef CONFIG_CC_STACKPROTECTOR
22817 movl $(__KERNEL_STACK_CANARY),%eax
22818 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22819 + movl $(__USER_DS),%eax
22820 +#else
22821 + xorl %eax,%eax
22822 +#endif
22823 movl %eax,%gs
22824
22825 xorl %eax,%eax # Clear LDT
22826 @@ -512,8 +594,11 @@ setup_once:
22827 * relocation. Manually set base address in stack canary
22828 * segment descriptor.
22829 */
22830 - movl $gdt_page,%eax
22831 + movl $cpu_gdt_table,%eax
22832 movl $stack_canary,%ecx
22833 +#ifdef CONFIG_SMP
22834 + addl $__per_cpu_load,%ecx
22835 +#endif
22836 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22837 shrl $16, %ecx
22838 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22839 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22840 /* This is global to keep gas from relaxing the jumps */
22841 ENTRY(early_idt_handler)
22842 cld
22843 - cmpl $2,%ss:early_recursion_flag
22844 + cmpl $1,%ss:early_recursion_flag
22845 je hlt_loop
22846 incl %ss:early_recursion_flag
22847
22848 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22849 pushl (20+6*4)(%esp) /* trapno */
22850 pushl $fault_msg
22851 call printk
22852 -#endif
22853 call dump_stack
22854 +#endif
22855 hlt_loop:
22856 hlt
22857 jmp hlt_loop
22858 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22859 /* This is the default interrupt "handler" :-) */
22860 ALIGN
22861 ignore_int:
22862 - cld
22863 #ifdef CONFIG_PRINTK
22864 + cmpl $2,%ss:early_recursion_flag
22865 + je hlt_loop
22866 + incl %ss:early_recursion_flag
22867 + cld
22868 pushl %eax
22869 pushl %ecx
22870 pushl %edx
22871 @@ -612,9 +700,6 @@ ignore_int:
22872 movl $(__KERNEL_DS),%eax
22873 movl %eax,%ds
22874 movl %eax,%es
22875 - cmpl $2,early_recursion_flag
22876 - je hlt_loop
22877 - incl early_recursion_flag
22878 pushl 16(%esp)
22879 pushl 24(%esp)
22880 pushl 32(%esp)
22881 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22882 /*
22883 * BSS section
22884 */
22885 -__PAGE_ALIGNED_BSS
22886 - .align PAGE_SIZE
22887 #ifdef CONFIG_X86_PAE
22888 +.section .initial_pg_pmd,"a",@progbits
22889 initial_pg_pmd:
22890 .fill 1024*KPMDS,4,0
22891 #else
22892 +.section .initial_page_table,"a",@progbits
22893 ENTRY(initial_page_table)
22894 .fill 1024,4,0
22895 #endif
22896 +.section .initial_pg_fixmap,"a",@progbits
22897 initial_pg_fixmap:
22898 .fill 1024,4,0
22899 +.section .empty_zero_page,"a",@progbits
22900 ENTRY(empty_zero_page)
22901 .fill 4096,1,0
22902 +.section .swapper_pg_dir,"a",@progbits
22903 ENTRY(swapper_pg_dir)
22904 +#ifdef CONFIG_X86_PAE
22905 + .fill 4,8,0
22906 +#else
22907 .fill 1024,4,0
22908 +#endif
22909
22910 /*
22911 * This starts the data section.
22912 */
22913 #ifdef CONFIG_X86_PAE
22914 -__PAGE_ALIGNED_DATA
22915 - /* Page-aligned for the benefit of paravirt? */
22916 - .align PAGE_SIZE
22917 +.section .initial_page_table,"a",@progbits
22918 ENTRY(initial_page_table)
22919 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22920 # if KPMDS == 3
22921 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22922 # error "Kernel PMDs should be 1, 2 or 3"
22923 # endif
22924 .align PAGE_SIZE /* needs to be page-sized too */
22925 +
22926 +#ifdef CONFIG_PAX_PER_CPU_PGD
22927 +ENTRY(cpu_pgd)
22928 + .rept 2*NR_CPUS
22929 + .fill 4,8,0
22930 + .endr
22931 +#endif
22932 +
22933 #endif
22934
22935 .data
22936 .balign 4
22937 ENTRY(stack_start)
22938 - .long init_thread_union+THREAD_SIZE
22939 + .long init_thread_union+THREAD_SIZE-8
22940
22941 __INITRODATA
22942 int_msg:
22943 @@ -722,7 +820,7 @@ fault_msg:
22944 * segment size, and 32-bit linear address value:
22945 */
22946
22947 - .data
22948 +.section .rodata,"a",@progbits
22949 .globl boot_gdt_descr
22950 .globl idt_descr
22951
22952 @@ -731,7 +829,7 @@ fault_msg:
22953 .word 0 # 32 bit align gdt_desc.address
22954 boot_gdt_descr:
22955 .word __BOOT_DS+7
22956 - .long boot_gdt - __PAGE_OFFSET
22957 + .long pa(boot_gdt)
22958
22959 .word 0 # 32-bit align idt_desc.address
22960 idt_descr:
22961 @@ -742,7 +840,7 @@ idt_descr:
22962 .word 0 # 32 bit align gdt_desc.address
22963 ENTRY(early_gdt_descr)
22964 .word GDT_ENTRIES*8-1
22965 - .long gdt_page /* Overwritten for secondary CPUs */
22966 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22967
22968 /*
22969 * The boot_gdt must mirror the equivalent in setup.S and is
22970 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22971 .align L1_CACHE_BYTES
22972 ENTRY(boot_gdt)
22973 .fill GDT_ENTRY_BOOT_CS,8,0
22974 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22975 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22976 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22977 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22978 +
22979 + .align PAGE_SIZE_asm
22980 +ENTRY(cpu_gdt_table)
22981 + .rept NR_CPUS
22982 + .quad 0x0000000000000000 /* NULL descriptor */
22983 + .quad 0x0000000000000000 /* 0x0b reserved */
22984 + .quad 0x0000000000000000 /* 0x13 reserved */
22985 + .quad 0x0000000000000000 /* 0x1b reserved */
22986 +
22987 +#ifdef CONFIG_PAX_KERNEXEC
22988 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22989 +#else
22990 + .quad 0x0000000000000000 /* 0x20 unused */
22991 +#endif
22992 +
22993 + .quad 0x0000000000000000 /* 0x28 unused */
22994 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22995 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22996 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22997 + .quad 0x0000000000000000 /* 0x4b reserved */
22998 + .quad 0x0000000000000000 /* 0x53 reserved */
22999 + .quad 0x0000000000000000 /* 0x5b reserved */
23000 +
23001 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23002 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23003 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23004 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23005 +
23006 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23007 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23008 +
23009 + /*
23010 + * Segments used for calling PnP BIOS have byte granularity.
23011 + * The code segments and data segments have fixed 64k limits,
23012 + * the transfer segment sizes are set at run time.
23013 + */
23014 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23015 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23016 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23017 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23018 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23019 +
23020 + /*
23021 + * The APM segments have byte granularity and their bases
23022 + * are set at run time. All have 64k limits.
23023 + */
23024 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23025 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23026 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23027 +
23028 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23029 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23030 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23031 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23032 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23033 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23034 +
23035 + /* Be sure this is zeroed to avoid false validations in Xen */
23036 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23037 + .endr
23038 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23039 index e1aabdb..fee4fee 100644
23040 --- a/arch/x86/kernel/head_64.S
23041 +++ b/arch/x86/kernel/head_64.S
23042 @@ -20,6 +20,8 @@
23043 #include <asm/processor-flags.h>
23044 #include <asm/percpu.h>
23045 #include <asm/nops.h>
23046 +#include <asm/cpufeature.h>
23047 +#include <asm/alternative-asm.h>
23048
23049 #ifdef CONFIG_PARAVIRT
23050 #include <asm/asm-offsets.h>
23051 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23052 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23053 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23054 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23055 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23056 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23057 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23058 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23059 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23060 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23061
23062 .text
23063 __HEAD
23064 @@ -89,11 +97,24 @@ startup_64:
23065 * Fixup the physical addresses in the page table
23066 */
23067 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23068 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23069 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23070 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23071 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23072 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23073
23074 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23075 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23076 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23077 +#ifndef CONFIG_XEN
23078 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23079 +#endif
23080 +
23081 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23082 +
23083 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23084 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23085
23086 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23087 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23088
23089 /*
23090 * Set up the identity mapping for the switchover. These
23091 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23092 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23093 1:
23094
23095 - /* Enable PAE mode and PGE */
23096 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23097 + /* Enable PAE mode and PSE/PGE */
23098 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23099 movq %rcx, %cr4
23100
23101 /* Setup early boot stage 4 level pagetables. */
23102 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23103 movl $MSR_EFER, %ecx
23104 rdmsr
23105 btsl $_EFER_SCE, %eax /* Enable System Call */
23106 - btl $20,%edi /* No Execute supported? */
23107 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23108 jnc 1f
23109 btsl $_EFER_NX, %eax
23110 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23111 +#ifndef CONFIG_EFI
23112 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23113 +#endif
23114 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23115 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23116 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23117 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23118 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23119 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23120 1: wrmsr /* Make changes effective */
23121
23122 /* Setup cr0 */
23123 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23124 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23125 * address given in m16:64.
23126 */
23127 + pax_set_fptr_mask
23128 movq initial_code(%rip),%rax
23129 pushq $0 # fake return address to stop unwinder
23130 pushq $__KERNEL_CS # set correct cs
23131 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23132 call dump_stack
23133 #ifdef CONFIG_KALLSYMS
23134 leaq early_idt_ripmsg(%rip),%rdi
23135 - movq 40(%rsp),%rsi # %rip again
23136 + movq 88(%rsp),%rsi # %rip again
23137 call __print_symbol
23138 #endif
23139 #endif /* EARLY_PRINTK */
23140 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23141 early_recursion_flag:
23142 .long 0
23143
23144 + .section .rodata,"a",@progbits
23145 #ifdef CONFIG_EARLY_PRINTK
23146 early_idt_msg:
23147 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23148 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23149 NEXT_PAGE(early_dynamic_pgts)
23150 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23151
23152 - .data
23153 + .section .rodata,"a",@progbits
23154
23155 -#ifndef CONFIG_XEN
23156 NEXT_PAGE(init_level4_pgt)
23157 - .fill 512,8,0
23158 -#else
23159 -NEXT_PAGE(init_level4_pgt)
23160 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23161 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23162 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23163 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23164 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23166 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23167 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23168 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23169 .org init_level4_pgt + L4_START_KERNEL*8, 0
23170 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23171 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23172
23173 +#ifdef CONFIG_PAX_PER_CPU_PGD
23174 +NEXT_PAGE(cpu_pgd)
23175 + .rept 2*NR_CPUS
23176 + .fill 512,8,0
23177 + .endr
23178 +#endif
23179 +
23180 NEXT_PAGE(level3_ident_pgt)
23181 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23182 +#ifdef CONFIG_XEN
23183 .fill 511, 8, 0
23184 +#else
23185 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23186 + .fill 510,8,0
23187 +#endif
23188 +
23189 +NEXT_PAGE(level3_vmalloc_start_pgt)
23190 + .fill 512,8,0
23191 +
23192 +NEXT_PAGE(level3_vmalloc_end_pgt)
23193 + .fill 512,8,0
23194 +
23195 +NEXT_PAGE(level3_vmemmap_pgt)
23196 + .fill L3_VMEMMAP_START,8,0
23197 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23198 +
23199 NEXT_PAGE(level2_ident_pgt)
23200 - /* Since I easily can, map the first 1G.
23201 + /* Since I easily can, map the first 2G.
23202 * Don't set NX because code runs from these pages.
23203 */
23204 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23205 -#endif
23206 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23207
23208 NEXT_PAGE(level3_kernel_pgt)
23209 .fill L3_START_KERNEL,8,0
23210 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23211 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23212 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23213
23214 +NEXT_PAGE(level2_vmemmap_pgt)
23215 + .fill 512,8,0
23216 +
23217 NEXT_PAGE(level2_kernel_pgt)
23218 /*
23219 * 512 MB kernel mapping. We spend a full page on this pagetable
23220 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
23221 NEXT_PAGE(level2_fixmap_pgt)
23222 .fill 506,8,0
23223 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23224 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23225 - .fill 5,8,0
23226 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23227 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23228 + .fill 4,8,0
23229
23230 NEXT_PAGE(level1_fixmap_pgt)
23231 .fill 512,8,0
23232
23233 +NEXT_PAGE(level1_vsyscall_pgt)
23234 + .fill 512,8,0
23235 +
23236 #undef PMDS
23237
23238 - .data
23239 + .align PAGE_SIZE
23240 +ENTRY(cpu_gdt_table)
23241 + .rept NR_CPUS
23242 + .quad 0x0000000000000000 /* NULL descriptor */
23243 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23244 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23245 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23246 + .quad 0x00cffb000000ffff /* __USER32_CS */
23247 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23248 + .quad 0x00affb000000ffff /* __USER_CS */
23249 +
23250 +#ifdef CONFIG_PAX_KERNEXEC
23251 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23252 +#else
23253 + .quad 0x0 /* unused */
23254 +#endif
23255 +
23256 + .quad 0,0 /* TSS */
23257 + .quad 0,0 /* LDT */
23258 + .quad 0,0,0 /* three TLS descriptors */
23259 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23260 + /* asm/segment.h:GDT_ENTRIES must match this */
23261 +
23262 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23263 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23264 +#else
23265 + .quad 0x0 /* unused */
23266 +#endif
23267 +
23268 + /* zero the remaining page */
23269 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23270 + .endr
23271 +
23272 .align 16
23273 .globl early_gdt_descr
23274 early_gdt_descr:
23275 .word GDT_ENTRIES*8-1
23276 early_gdt_descr_base:
23277 - .quad INIT_PER_CPU_VAR(gdt_page)
23278 + .quad cpu_gdt_table
23279
23280 ENTRY(phys_base)
23281 /* This must match the first entry in level2_kernel_pgt */
23282 .quad 0x0000000000000000
23283
23284 #include "../../x86/xen/xen-head.S"
23285 -
23286 - __PAGE_ALIGNED_BSS
23287 +
23288 + .section .rodata,"a",@progbits
23289 NEXT_PAGE(empty_zero_page)
23290 .skip PAGE_SIZE
23291 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23292 index 0fa6912..b37438b 100644
23293 --- a/arch/x86/kernel/i386_ksyms_32.c
23294 +++ b/arch/x86/kernel/i386_ksyms_32.c
23295 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23296 EXPORT_SYMBOL(cmpxchg8b_emu);
23297 #endif
23298
23299 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23300 +
23301 /* Networking helper routines. */
23302 EXPORT_SYMBOL(csum_partial_copy_generic);
23303 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23304 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23305
23306 EXPORT_SYMBOL(__get_user_1);
23307 EXPORT_SYMBOL(__get_user_2);
23308 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23309
23310 EXPORT_SYMBOL(csum_partial);
23311 EXPORT_SYMBOL(empty_zero_page);
23312 +
23313 +#ifdef CONFIG_PAX_KERNEXEC
23314 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23315 +#endif
23316 +
23317 +#ifdef CONFIG_PAX_PER_CPU_PGD
23318 +EXPORT_SYMBOL(cpu_pgd);
23319 +#endif
23320 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23321 index 5d576ab..1403a03 100644
23322 --- a/arch/x86/kernel/i387.c
23323 +++ b/arch/x86/kernel/i387.c
23324 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23325 static inline bool interrupted_user_mode(void)
23326 {
23327 struct pt_regs *regs = get_irq_regs();
23328 - return regs && user_mode_vm(regs);
23329 + return regs && user_mode(regs);
23330 }
23331
23332 /*
23333 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23334 index 9a5c460..84868423 100644
23335 --- a/arch/x86/kernel/i8259.c
23336 +++ b/arch/x86/kernel/i8259.c
23337 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23338 static void make_8259A_irq(unsigned int irq)
23339 {
23340 disable_irq_nosync(irq);
23341 - io_apic_irqs &= ~(1<<irq);
23342 + io_apic_irqs &= ~(1UL<<irq);
23343 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23344 i8259A_chip.name);
23345 enable_irq(irq);
23346 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23347 "spurious 8259A interrupt: IRQ%d.\n", irq);
23348 spurious_irq_mask |= irqmask;
23349 }
23350 - atomic_inc(&irq_err_count);
23351 + atomic_inc_unchecked(&irq_err_count);
23352 /*
23353 * Theoretically we do not have to handle this IRQ,
23354 * but in Linux this does not cause problems and is
23355 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23356 /* (slave's support for AEOI in flat mode is to be investigated) */
23357 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23358
23359 + pax_open_kernel();
23360 if (auto_eoi)
23361 /*
23362 * In AEOI mode we just have to mask the interrupt
23363 * when acking.
23364 */
23365 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23366 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23367 else
23368 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23369 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23370 + pax_close_kernel();
23371
23372 udelay(100); /* wait for 8259A to initialize */
23373
23374 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23375 index a979b5b..1d6db75 100644
23376 --- a/arch/x86/kernel/io_delay.c
23377 +++ b/arch/x86/kernel/io_delay.c
23378 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23379 * Quirk table for systems that misbehave (lock up, etc.) if port
23380 * 0x80 is used:
23381 */
23382 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23383 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23384 {
23385 .callback = dmi_io_delay_0xed_port,
23386 .ident = "Compaq Presario V6000",
23387 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23388 index 4ddaf66..6292f4e 100644
23389 --- a/arch/x86/kernel/ioport.c
23390 +++ b/arch/x86/kernel/ioport.c
23391 @@ -6,6 +6,7 @@
23392 #include <linux/sched.h>
23393 #include <linux/kernel.h>
23394 #include <linux/capability.h>
23395 +#include <linux/security.h>
23396 #include <linux/errno.h>
23397 #include <linux/types.h>
23398 #include <linux/ioport.h>
23399 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23400
23401 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23402 return -EINVAL;
23403 +#ifdef CONFIG_GRKERNSEC_IO
23404 + if (turn_on && grsec_disable_privio) {
23405 + gr_handle_ioperm();
23406 + return -EPERM;
23407 + }
23408 +#endif
23409 if (turn_on && !capable(CAP_SYS_RAWIO))
23410 return -EPERM;
23411
23412 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23413 * because the ->io_bitmap_max value must match the bitmap
23414 * contents:
23415 */
23416 - tss = &per_cpu(init_tss, get_cpu());
23417 + tss = init_tss + get_cpu();
23418
23419 if (turn_on)
23420 bitmap_clear(t->io_bitmap_ptr, from, num);
23421 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23422 return -EINVAL;
23423 /* Trying to gain more privileges? */
23424 if (level > old) {
23425 +#ifdef CONFIG_GRKERNSEC_IO
23426 + if (grsec_disable_privio) {
23427 + gr_handle_iopl();
23428 + return -EPERM;
23429 + }
23430 +#endif
23431 if (!capable(CAP_SYS_RAWIO))
23432 return -EPERM;
23433 }
23434 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23435 index 22d0687..e07b2a5 100644
23436 --- a/arch/x86/kernel/irq.c
23437 +++ b/arch/x86/kernel/irq.c
23438 @@ -21,7 +21,7 @@
23439 #define CREATE_TRACE_POINTS
23440 #include <asm/trace/irq_vectors.h>
23441
23442 -atomic_t irq_err_count;
23443 +atomic_unchecked_t irq_err_count;
23444
23445 /* Function pointer for generic interrupt vector handling */
23446 void (*x86_platform_ipi_callback)(void) = NULL;
23447 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23448 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23449 seq_printf(p, " Machine check polls\n");
23450 #endif
23451 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23452 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23453 #if defined(CONFIG_X86_IO_APIC)
23454 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23455 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23456 #endif
23457 return 0;
23458 }
23459 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23460
23461 u64 arch_irq_stat(void)
23462 {
23463 - u64 sum = atomic_read(&irq_err_count);
23464 + u64 sum = atomic_read_unchecked(&irq_err_count);
23465 return sum;
23466 }
23467
23468 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23469 index 4186755..784efa0 100644
23470 --- a/arch/x86/kernel/irq_32.c
23471 +++ b/arch/x86/kernel/irq_32.c
23472 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23473 __asm__ __volatile__("andl %%esp,%0" :
23474 "=r" (sp) : "0" (THREAD_SIZE - 1));
23475
23476 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23477 + return sp < STACK_WARN;
23478 }
23479
23480 static void print_stack_overflow(void)
23481 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23482 * per-CPU IRQ handling contexts (thread information and stack)
23483 */
23484 union irq_ctx {
23485 - struct thread_info tinfo;
23486 - u32 stack[THREAD_SIZE/sizeof(u32)];
23487 + unsigned long previous_esp;
23488 + u32 stack[THREAD_SIZE/sizeof(u32)];
23489 } __attribute__((aligned(THREAD_SIZE)));
23490
23491 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23492 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23493 static inline int
23494 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23495 {
23496 - union irq_ctx *curctx, *irqctx;
23497 + union irq_ctx *irqctx;
23498 u32 *isp, arg1, arg2;
23499
23500 - curctx = (union irq_ctx *) current_thread_info();
23501 irqctx = __this_cpu_read(hardirq_ctx);
23502
23503 /*
23504 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23505 * handler) we can't do that and just have to keep using the
23506 * current stack (which is the irq stack already after all)
23507 */
23508 - if (unlikely(curctx == irqctx))
23509 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23510 return 0;
23511
23512 /* build the stack frame on the IRQ stack */
23513 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23514 - irqctx->tinfo.task = curctx->tinfo.task;
23515 - irqctx->tinfo.previous_esp = current_stack_pointer;
23516 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23517 + irqctx->previous_esp = current_stack_pointer;
23518
23519 - /* Copy the preempt_count so that the [soft]irq checks work. */
23520 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(MAKE_MM_SEG(0));
23523 +#endif
23524
23525 if (unlikely(overflow))
23526 call_on_stack(print_stack_overflow, isp);
23527 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23528 : "0" (irq), "1" (desc), "2" (isp),
23529 "D" (desc->handle_irq)
23530 : "memory", "cc", "ecx");
23531 +
23532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23533 + __set_fs(current_thread_info()->addr_limit);
23534 +#endif
23535 +
23536 return 1;
23537 }
23538
23539 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23540 */
23541 void irq_ctx_init(int cpu)
23542 {
23543 - union irq_ctx *irqctx;
23544 -
23545 if (per_cpu(hardirq_ctx, cpu))
23546 return;
23547
23548 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23549 - THREADINFO_GFP,
23550 - THREAD_SIZE_ORDER));
23551 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23552 - irqctx->tinfo.cpu = cpu;
23553 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23556 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23557
23558 - per_cpu(hardirq_ctx, cpu) = irqctx;
23559 -
23560 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23561 - THREADINFO_GFP,
23562 - THREAD_SIZE_ORDER));
23563 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23564 - irqctx->tinfo.cpu = cpu;
23565 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23566 -
23567 - per_cpu(softirq_ctx, cpu) = irqctx;
23568 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23569 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23570
23571 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23572 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23573 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23574 asmlinkage void do_softirq(void)
23575 {
23576 unsigned long flags;
23577 - struct thread_info *curctx;
23578 union irq_ctx *irqctx;
23579 u32 *isp;
23580
23581 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23582 local_irq_save(flags);
23583
23584 if (local_softirq_pending()) {
23585 - curctx = current_thread_info();
23586 irqctx = __this_cpu_read(softirq_ctx);
23587 - irqctx->tinfo.task = curctx->task;
23588 - irqctx->tinfo.previous_esp = current_stack_pointer;
23589 + irqctx->previous_esp = current_stack_pointer;
23590
23591 /* build the stack frame on the softirq stack */
23592 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23593 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23594 +
23595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23596 + __set_fs(MAKE_MM_SEG(0));
23597 +#endif
23598
23599 call_on_stack(__do_softirq, isp);
23600 +
23601 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23602 + __set_fs(current_thread_info()->addr_limit);
23603 +#endif
23604 +
23605 /*
23606 * Shouldn't happen, we returned above if in_interrupt():
23607 */
23608 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23609 if (unlikely(!desc))
23610 return false;
23611
23612 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23613 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23614 if (unlikely(overflow))
23615 print_stack_overflow();
23616 desc->handle_irq(irq, desc);
23617 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23618 index d04d3ec..ea4b374 100644
23619 --- a/arch/x86/kernel/irq_64.c
23620 +++ b/arch/x86/kernel/irq_64.c
23621 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23622 u64 estack_top, estack_bottom;
23623 u64 curbase = (u64)task_stack_page(current);
23624
23625 - if (user_mode_vm(regs))
23626 + if (user_mode(regs))
23627 return;
23628
23629 if (regs->sp >= curbase + sizeof(struct thread_info) +
23630 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
23631 index ee11b7d..4df4d0c 100644
23632 --- a/arch/x86/kernel/jump_label.c
23633 +++ b/arch/x86/kernel/jump_label.c
23634 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
23635 * We are enabling this jump label. If it is not a nop
23636 * then something must have gone wrong.
23637 */
23638 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
23639 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
23640 bug_at((void *)entry->code, __LINE__);
23641
23642 code.jump = 0xe9;
23643 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
23644 */
23645 if (init) {
23646 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
23647 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
23648 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
23649 bug_at((void *)entry->code, __LINE__);
23650 } else {
23651 code.jump = 0xe9;
23652 code.offset = entry->target -
23653 (entry->code + JUMP_LABEL_NOP_SIZE);
23654 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
23655 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
23656 bug_at((void *)entry->code, __LINE__);
23657 }
23658 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
23659 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23660 index 836f832..a8bda67 100644
23661 --- a/arch/x86/kernel/kgdb.c
23662 +++ b/arch/x86/kernel/kgdb.c
23663 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23664 #ifdef CONFIG_X86_32
23665 switch (regno) {
23666 case GDB_SS:
23667 - if (!user_mode_vm(regs))
23668 + if (!user_mode(regs))
23669 *(unsigned long *)mem = __KERNEL_DS;
23670 break;
23671 case GDB_SP:
23672 - if (!user_mode_vm(regs))
23673 + if (!user_mode(regs))
23674 *(unsigned long *)mem = kernel_stack_pointer(regs);
23675 break;
23676 case GDB_GS:
23677 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23678 bp->attr.bp_addr = breakinfo[breakno].addr;
23679 bp->attr.bp_len = breakinfo[breakno].len;
23680 bp->attr.bp_type = breakinfo[breakno].type;
23681 - info->address = breakinfo[breakno].addr;
23682 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23683 + info->address = ktla_ktva(breakinfo[breakno].addr);
23684 + else
23685 + info->address = breakinfo[breakno].addr;
23686 info->len = breakinfo[breakno].len;
23687 info->type = breakinfo[breakno].type;
23688 val = arch_install_hw_breakpoint(bp);
23689 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23690 case 'k':
23691 /* clear the trace bit */
23692 linux_regs->flags &= ~X86_EFLAGS_TF;
23693 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23694 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23695
23696 /* set the trace bit if we're stepping */
23697 if (remcomInBuffer[0] == 's') {
23698 linux_regs->flags |= X86_EFLAGS_TF;
23699 - atomic_set(&kgdb_cpu_doing_single_step,
23700 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23701 raw_smp_processor_id());
23702 }
23703
23704 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23705
23706 switch (cmd) {
23707 case DIE_DEBUG:
23708 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23709 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23710 if (user_mode(regs))
23711 return single_step_cont(regs, args);
23712 break;
23713 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23714 #endif /* CONFIG_DEBUG_RODATA */
23715
23716 bpt->type = BP_BREAKPOINT;
23717 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23718 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23719 BREAK_INSTR_SIZE);
23720 if (err)
23721 return err;
23722 - err = probe_kernel_write((char *)bpt->bpt_addr,
23723 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23724 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23725 #ifdef CONFIG_DEBUG_RODATA
23726 if (!err)
23727 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23728 return -EBUSY;
23729 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23730 BREAK_INSTR_SIZE);
23731 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23732 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23733 if (err)
23734 return err;
23735 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23736 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23737 if (mutex_is_locked(&text_mutex))
23738 goto knl_write;
23739 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23740 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23741 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23742 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23743 goto knl_write;
23744 return err;
23745 knl_write:
23746 #endif /* CONFIG_DEBUG_RODATA */
23747 - return probe_kernel_write((char *)bpt->bpt_addr,
23748 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23749 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23750 }
23751
23752 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23753 index 79a3f96..6ba030a 100644
23754 --- a/arch/x86/kernel/kprobes/core.c
23755 +++ b/arch/x86/kernel/kprobes/core.c
23756 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23757 s32 raddr;
23758 } __packed *insn;
23759
23760 - insn = (struct __arch_relative_insn *)from;
23761 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23762 +
23763 + pax_open_kernel();
23764 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23765 insn->op = op;
23766 + pax_close_kernel();
23767 }
23768
23769 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23770 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23771 kprobe_opcode_t opcode;
23772 kprobe_opcode_t *orig_opcodes = opcodes;
23773
23774 - if (search_exception_tables((unsigned long)opcodes))
23775 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23776 return 0; /* Page fault may occur on this address. */
23777
23778 retry:
23779 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23780 * for the first byte, we can recover the original instruction
23781 * from it and kp->opcode.
23782 */
23783 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23784 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23785 buf[0] = kp->opcode;
23786 - return (unsigned long)buf;
23787 + return ktva_ktla((unsigned long)buf);
23788 }
23789
23790 /*
23791 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23792 /* Another subsystem puts a breakpoint, failed to recover */
23793 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23794 return 0;
23795 + pax_open_kernel();
23796 memcpy(dest, insn.kaddr, insn.length);
23797 + pax_close_kernel();
23798
23799 #ifdef CONFIG_X86_64
23800 if (insn_rip_relative(&insn)) {
23801 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23802 return 0;
23803 }
23804 disp = (u8 *) dest + insn_offset_displacement(&insn);
23805 + pax_open_kernel();
23806 *(s32 *) disp = (s32) newdisp;
23807 + pax_close_kernel();
23808 }
23809 #endif
23810 return insn.length;
23811 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23812 * nor set current_kprobe, because it doesn't use single
23813 * stepping.
23814 */
23815 - regs->ip = (unsigned long)p->ainsn.insn;
23816 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23817 preempt_enable_no_resched();
23818 return;
23819 }
23820 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23821 regs->flags &= ~X86_EFLAGS_IF;
23822 /* single step inline if the instruction is an int3 */
23823 if (p->opcode == BREAKPOINT_INSTRUCTION)
23824 - regs->ip = (unsigned long)p->addr;
23825 + regs->ip = ktla_ktva((unsigned long)p->addr);
23826 else
23827 - regs->ip = (unsigned long)p->ainsn.insn;
23828 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23829 }
23830
23831 /*
23832 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23833 setup_singlestep(p, regs, kcb, 0);
23834 return 1;
23835 }
23836 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23837 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23838 /*
23839 * The breakpoint instruction was removed right
23840 * after we hit it. Another cpu has removed
23841 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23842 " movq %rax, 152(%rsp)\n"
23843 RESTORE_REGS_STRING
23844 " popfq\n"
23845 +#ifdef KERNEXEC_PLUGIN
23846 + " btsq $63,(%rsp)\n"
23847 +#endif
23848 #else
23849 " pushf\n"
23850 SAVE_REGS_STRING
23851 @@ -779,7 +789,7 @@ static void __kprobes
23852 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23853 {
23854 unsigned long *tos = stack_addr(regs);
23855 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23856 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23857 unsigned long orig_ip = (unsigned long)p->addr;
23858 kprobe_opcode_t *insn = p->ainsn.insn;
23859
23860 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23861 struct die_args *args = data;
23862 int ret = NOTIFY_DONE;
23863
23864 - if (args->regs && user_mode_vm(args->regs))
23865 + if (args->regs && user_mode(args->regs))
23866 return ret;
23867
23868 switch (val) {
23869 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23870 index 898160b..758cde8 100644
23871 --- a/arch/x86/kernel/kprobes/opt.c
23872 +++ b/arch/x86/kernel/kprobes/opt.c
23873 @@ -79,6 +79,7 @@ found:
23874 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23875 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23876 {
23877 + pax_open_kernel();
23878 #ifdef CONFIG_X86_64
23879 *addr++ = 0x48;
23880 *addr++ = 0xbf;
23881 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23882 *addr++ = 0xb8;
23883 #endif
23884 *(unsigned long *)addr = val;
23885 + pax_close_kernel();
23886 }
23887
23888 asm (
23889 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23890 * Verify if the address gap is in 2GB range, because this uses
23891 * a relative jump.
23892 */
23893 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23894 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23895 if (abs(rel) > 0x7fffffff)
23896 return -ERANGE;
23897
23898 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23899 op->optinsn.size = ret;
23900
23901 /* Copy arch-dep-instance from template */
23902 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23903 + pax_open_kernel();
23904 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23905 + pax_close_kernel();
23906
23907 /* Set probe information */
23908 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23909
23910 /* Set probe function call */
23911 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23912 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23913
23914 /* Set returning jmp instruction at the tail of out-of-line buffer */
23915 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23916 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23917 (u8 *)op->kp.addr + op->optinsn.size);
23918
23919 flush_icache_range((unsigned long) buf,
23920 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
23921 WARN_ON(kprobe_disabled(&op->kp));
23922
23923 /* Backup instructions which will be replaced by jump address */
23924 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23925 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23926 RELATIVE_ADDR_SIZE);
23927
23928 insn_buf[0] = RELATIVEJUMP_OPCODE;
23929 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23930 /* This kprobe is really able to run optimized path. */
23931 op = container_of(p, struct optimized_kprobe, kp);
23932 /* Detour through copied instructions */
23933 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23934 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23935 if (!reenter)
23936 reset_current_kprobe();
23937 preempt_enable_no_resched();
23938 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23939 index ebc9873..1b9724b 100644
23940 --- a/arch/x86/kernel/ldt.c
23941 +++ b/arch/x86/kernel/ldt.c
23942 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23943 if (reload) {
23944 #ifdef CONFIG_SMP
23945 preempt_disable();
23946 - load_LDT(pc);
23947 + load_LDT_nolock(pc);
23948 if (!cpumask_equal(mm_cpumask(current->mm),
23949 cpumask_of(smp_processor_id())))
23950 smp_call_function(flush_ldt, current->mm, 1);
23951 preempt_enable();
23952 #else
23953 - load_LDT(pc);
23954 + load_LDT_nolock(pc);
23955 #endif
23956 }
23957 if (oldsize) {
23958 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23959 return err;
23960
23961 for (i = 0; i < old->size; i++)
23962 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23963 + write_ldt_entry(new->ldt, i, old->ldt + i);
23964 return 0;
23965 }
23966
23967 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23968 retval = copy_ldt(&mm->context, &old_mm->context);
23969 mutex_unlock(&old_mm->context.lock);
23970 }
23971 +
23972 + if (tsk == current) {
23973 + mm->context.vdso = 0;
23974 +
23975 +#ifdef CONFIG_X86_32
23976 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23977 + mm->context.user_cs_base = 0UL;
23978 + mm->context.user_cs_limit = ~0UL;
23979 +
23980 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23981 + cpus_clear(mm->context.cpu_user_cs_mask);
23982 +#endif
23983 +
23984 +#endif
23985 +#endif
23986 +
23987 + }
23988 +
23989 return retval;
23990 }
23991
23992 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23993 }
23994 }
23995
23996 +#ifdef CONFIG_PAX_SEGMEXEC
23997 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23998 + error = -EINVAL;
23999 + goto out_unlock;
24000 + }
24001 +#endif
24002 +
24003 fill_ldt(&ldt, &ldt_info);
24004 if (oldmode)
24005 ldt.avl = 0;
24006 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24007 index 5b19e4d..6476a76 100644
24008 --- a/arch/x86/kernel/machine_kexec_32.c
24009 +++ b/arch/x86/kernel/machine_kexec_32.c
24010 @@ -26,7 +26,7 @@
24011 #include <asm/cacheflush.h>
24012 #include <asm/debugreg.h>
24013
24014 -static void set_idt(void *newidt, __u16 limit)
24015 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24016 {
24017 struct desc_ptr curidt;
24018
24019 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24020 }
24021
24022
24023 -static void set_gdt(void *newgdt, __u16 limit)
24024 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24025 {
24026 struct desc_ptr curgdt;
24027
24028 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24029 }
24030
24031 control_page = page_address(image->control_code_page);
24032 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24033 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24034
24035 relocate_kernel_ptr = control_page;
24036 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24037 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24038 index 15c9876..0a43909 100644
24039 --- a/arch/x86/kernel/microcode_core.c
24040 +++ b/arch/x86/kernel/microcode_core.c
24041 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24042 return NOTIFY_OK;
24043 }
24044
24045 -static struct notifier_block __refdata mc_cpu_notifier = {
24046 +static struct notifier_block mc_cpu_notifier = {
24047 .notifier_call = mc_cpu_callback,
24048 };
24049
24050 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24051 index 5fb2ceb..3ae90bb 100644
24052 --- a/arch/x86/kernel/microcode_intel.c
24053 +++ b/arch/x86/kernel/microcode_intel.c
24054 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24055
24056 static int get_ucode_user(void *to, const void *from, size_t n)
24057 {
24058 - return copy_from_user(to, from, n);
24059 + return copy_from_user(to, (const void __force_user *)from, n);
24060 }
24061
24062 static enum ucode_state
24063 request_microcode_user(int cpu, const void __user *buf, size_t size)
24064 {
24065 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24066 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24067 }
24068
24069 static void microcode_fini_cpu(int cpu)
24070 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24071 index 216a4d7..228255a 100644
24072 --- a/arch/x86/kernel/module.c
24073 +++ b/arch/x86/kernel/module.c
24074 @@ -43,15 +43,60 @@ do { \
24075 } while (0)
24076 #endif
24077
24078 -void *module_alloc(unsigned long size)
24079 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24080 {
24081 - if (PAGE_ALIGN(size) > MODULES_LEN)
24082 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24083 return NULL;
24084 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24085 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24086 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24087 -1, __builtin_return_address(0));
24088 }
24089
24090 +void *module_alloc(unsigned long size)
24091 +{
24092 +
24093 +#ifdef CONFIG_PAX_KERNEXEC
24094 + return __module_alloc(size, PAGE_KERNEL);
24095 +#else
24096 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24097 +#endif
24098 +
24099 +}
24100 +
24101 +#ifdef CONFIG_PAX_KERNEXEC
24102 +#ifdef CONFIG_X86_32
24103 +void *module_alloc_exec(unsigned long size)
24104 +{
24105 + struct vm_struct *area;
24106 +
24107 + if (size == 0)
24108 + return NULL;
24109 +
24110 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24111 + return area ? area->addr : NULL;
24112 +}
24113 +EXPORT_SYMBOL(module_alloc_exec);
24114 +
24115 +void module_free_exec(struct module *mod, void *module_region)
24116 +{
24117 + vunmap(module_region);
24118 +}
24119 +EXPORT_SYMBOL(module_free_exec);
24120 +#else
24121 +void module_free_exec(struct module *mod, void *module_region)
24122 +{
24123 + module_free(mod, module_region);
24124 +}
24125 +EXPORT_SYMBOL(module_free_exec);
24126 +
24127 +void *module_alloc_exec(unsigned long size)
24128 +{
24129 + return __module_alloc(size, PAGE_KERNEL_RX);
24130 +}
24131 +EXPORT_SYMBOL(module_alloc_exec);
24132 +#endif
24133 +#endif
24134 +
24135 #ifdef CONFIG_X86_32
24136 int apply_relocate(Elf32_Shdr *sechdrs,
24137 const char *strtab,
24138 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24139 unsigned int i;
24140 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24141 Elf32_Sym *sym;
24142 - uint32_t *location;
24143 + uint32_t *plocation, location;
24144
24145 DEBUGP("Applying relocate section %u to %u\n",
24146 relsec, sechdrs[relsec].sh_info);
24147 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24148 /* This is where to make the change */
24149 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24150 - + rel[i].r_offset;
24151 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24152 + location = (uint32_t)plocation;
24153 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24154 + plocation = ktla_ktva((void *)plocation);
24155 /* This is the symbol it is referring to. Note that all
24156 undefined symbols have been resolved. */
24157 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24158 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24159 switch (ELF32_R_TYPE(rel[i].r_info)) {
24160 case R_386_32:
24161 /* We add the value into the location given */
24162 - *location += sym->st_value;
24163 + pax_open_kernel();
24164 + *plocation += sym->st_value;
24165 + pax_close_kernel();
24166 break;
24167 case R_386_PC32:
24168 /* Add the value, subtract its position */
24169 - *location += sym->st_value - (uint32_t)location;
24170 + pax_open_kernel();
24171 + *plocation += sym->st_value - location;
24172 + pax_close_kernel();
24173 break;
24174 default:
24175 pr_err("%s: Unknown relocation: %u\n",
24176 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24177 case R_X86_64_NONE:
24178 break;
24179 case R_X86_64_64:
24180 + pax_open_kernel();
24181 *(u64 *)loc = val;
24182 + pax_close_kernel();
24183 break;
24184 case R_X86_64_32:
24185 + pax_open_kernel();
24186 *(u32 *)loc = val;
24187 + pax_close_kernel();
24188 if (val != *(u32 *)loc)
24189 goto overflow;
24190 break;
24191 case R_X86_64_32S:
24192 + pax_open_kernel();
24193 *(s32 *)loc = val;
24194 + pax_close_kernel();
24195 if ((s64)val != *(s32 *)loc)
24196 goto overflow;
24197 break;
24198 case R_X86_64_PC32:
24199 val -= (u64)loc;
24200 + pax_open_kernel();
24201 *(u32 *)loc = val;
24202 + pax_close_kernel();
24203 +
24204 #if 0
24205 if ((s64)val != *(s32 *)loc)
24206 goto overflow;
24207 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24208 index 88458fa..349f7a4 100644
24209 --- a/arch/x86/kernel/msr.c
24210 +++ b/arch/x86/kernel/msr.c
24211 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24212 return notifier_from_errno(err);
24213 }
24214
24215 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24216 +static struct notifier_block msr_class_cpu_notifier = {
24217 .notifier_call = msr_class_cpu_callback,
24218 };
24219
24220 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24221 index 6fcb49c..5b3f4ff 100644
24222 --- a/arch/x86/kernel/nmi.c
24223 +++ b/arch/x86/kernel/nmi.c
24224 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24225 return handled;
24226 }
24227
24228 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24229 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24230 {
24231 struct nmi_desc *desc = nmi_to_desc(type);
24232 unsigned long flags;
24233 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24234 * event confuses some handlers (kdump uses this flag)
24235 */
24236 if (action->flags & NMI_FLAG_FIRST)
24237 - list_add_rcu(&action->list, &desc->head);
24238 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24239 else
24240 - list_add_tail_rcu(&action->list, &desc->head);
24241 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24242
24243 spin_unlock_irqrestore(&desc->lock, flags);
24244 return 0;
24245 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24246 if (!strcmp(n->name, name)) {
24247 WARN(in_nmi(),
24248 "Trying to free NMI (%s) from NMI context!\n", n->name);
24249 - list_del_rcu(&n->list);
24250 + pax_list_del_rcu((struct list_head *)&n->list);
24251 break;
24252 }
24253 }
24254 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24255 dotraplinkage notrace __kprobes void
24256 do_nmi(struct pt_regs *regs, long error_code)
24257 {
24258 +
24259 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24260 + if (!user_mode(regs)) {
24261 + unsigned long cs = regs->cs & 0xFFFF;
24262 + unsigned long ip = ktva_ktla(regs->ip);
24263 +
24264 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24265 + regs->ip = ip;
24266 + }
24267 +#endif
24268 +
24269 nmi_nesting_preprocess(regs);
24270
24271 nmi_enter();
24272 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24273 index 6d9582e..f746287 100644
24274 --- a/arch/x86/kernel/nmi_selftest.c
24275 +++ b/arch/x86/kernel/nmi_selftest.c
24276 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24277 {
24278 /* trap all the unknown NMIs we may generate */
24279 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24280 - __initdata);
24281 + __initconst);
24282 }
24283
24284 static void __init cleanup_nmi_testsuite(void)
24285 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24286 unsigned long timeout;
24287
24288 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24289 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24290 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24291 nmi_fail = FAILURE;
24292 return;
24293 }
24294 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24295 index bbb6c73..24a58ef 100644
24296 --- a/arch/x86/kernel/paravirt-spinlocks.c
24297 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24298 @@ -8,7 +8,7 @@
24299
24300 #include <asm/paravirt.h>
24301
24302 -struct pv_lock_ops pv_lock_ops = {
24303 +struct pv_lock_ops pv_lock_ops __read_only = {
24304 #ifdef CONFIG_SMP
24305 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
24306 .unlock_kick = paravirt_nop,
24307 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24308 index 1b10af8..0b58cbc 100644
24309 --- a/arch/x86/kernel/paravirt.c
24310 +++ b/arch/x86/kernel/paravirt.c
24311 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24312 {
24313 return x;
24314 }
24315 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24316 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24317 +#endif
24318
24319 void __init default_banner(void)
24320 {
24321 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24322 if (opfunc == NULL)
24323 /* If there's no function, patch it with a ud2a (BUG) */
24324 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24325 - else if (opfunc == _paravirt_nop)
24326 + else if (opfunc == (void *)_paravirt_nop)
24327 /* If the operation is a nop, then nop the callsite */
24328 ret = paravirt_patch_nop();
24329
24330 /* identity functions just return their single argument */
24331 - else if (opfunc == _paravirt_ident_32)
24332 + else if (opfunc == (void *)_paravirt_ident_32)
24333 ret = paravirt_patch_ident_32(insnbuf, len);
24334 - else if (opfunc == _paravirt_ident_64)
24335 + else if (opfunc == (void *)_paravirt_ident_64)
24336 ret = paravirt_patch_ident_64(insnbuf, len);
24337 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24338 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24339 + ret = paravirt_patch_ident_64(insnbuf, len);
24340 +#endif
24341
24342 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24343 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24344 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24345 if (insn_len > len || start == NULL)
24346 insn_len = len;
24347 else
24348 - memcpy(insnbuf, start, insn_len);
24349 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24350
24351 return insn_len;
24352 }
24353 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24354 return this_cpu_read(paravirt_lazy_mode);
24355 }
24356
24357 -struct pv_info pv_info = {
24358 +struct pv_info pv_info __read_only = {
24359 .name = "bare hardware",
24360 .paravirt_enabled = 0,
24361 .kernel_rpl = 0,
24362 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
24363 #endif
24364 };
24365
24366 -struct pv_init_ops pv_init_ops = {
24367 +struct pv_init_ops pv_init_ops __read_only = {
24368 .patch = native_patch,
24369 };
24370
24371 -struct pv_time_ops pv_time_ops = {
24372 +struct pv_time_ops pv_time_ops __read_only = {
24373 .sched_clock = native_sched_clock,
24374 .steal_clock = native_steal_clock,
24375 };
24376
24377 -__visible struct pv_irq_ops pv_irq_ops = {
24378 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
24379 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24380 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24381 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24382 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
24383 #endif
24384 };
24385
24386 -__visible struct pv_cpu_ops pv_cpu_ops = {
24387 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
24388 .cpuid = native_cpuid,
24389 .get_debugreg = native_get_debugreg,
24390 .set_debugreg = native_set_debugreg,
24391 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
24392 .end_context_switch = paravirt_nop,
24393 };
24394
24395 -struct pv_apic_ops pv_apic_ops = {
24396 +struct pv_apic_ops pv_apic_ops __read_only= {
24397 #ifdef CONFIG_X86_LOCAL_APIC
24398 .startup_ipi_hook = paravirt_nop,
24399 #endif
24400 };
24401
24402 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24403 +#ifdef CONFIG_X86_32
24404 +#ifdef CONFIG_X86_PAE
24405 +/* 64-bit pagetable entries */
24406 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24407 +#else
24408 /* 32-bit pagetable entries */
24409 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24410 +#endif
24411 #else
24412 /* 64-bit pagetable entries */
24413 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24414 #endif
24415
24416 -struct pv_mmu_ops pv_mmu_ops = {
24417 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24418
24419 .read_cr2 = native_read_cr2,
24420 .write_cr2 = native_write_cr2,
24421 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24422 .make_pud = PTE_IDENT,
24423
24424 .set_pgd = native_set_pgd,
24425 + .set_pgd_batched = native_set_pgd_batched,
24426 #endif
24427 #endif /* PAGETABLE_LEVELS >= 3 */
24428
24429 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24430 },
24431
24432 .set_fixmap = native_set_fixmap,
24433 +
24434 +#ifdef CONFIG_PAX_KERNEXEC
24435 + .pax_open_kernel = native_pax_open_kernel,
24436 + .pax_close_kernel = native_pax_close_kernel,
24437 +#endif
24438 +
24439 };
24440
24441 EXPORT_SYMBOL_GPL(pv_time_ops);
24442 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24443 index 299d493..2ccb0ee 100644
24444 --- a/arch/x86/kernel/pci-calgary_64.c
24445 +++ b/arch/x86/kernel/pci-calgary_64.c
24446 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24447 tce_space = be64_to_cpu(readq(target));
24448 tce_space = tce_space & TAR_SW_BITS;
24449
24450 - tce_space = tce_space & (~specified_table_size);
24451 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24452 info->tce_space = (u64 *)__va(tce_space);
24453 }
24454 }
24455 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24456 index 35ccf75..7a15747 100644
24457 --- a/arch/x86/kernel/pci-iommu_table.c
24458 +++ b/arch/x86/kernel/pci-iommu_table.c
24459 @@ -2,7 +2,7 @@
24460 #include <asm/iommu_table.h>
24461 #include <linux/string.h>
24462 #include <linux/kallsyms.h>
24463 -
24464 +#include <linux/sched.h>
24465
24466 #define DEBUG 1
24467
24468 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24469 index 6c483ba..d10ce2f 100644
24470 --- a/arch/x86/kernel/pci-swiotlb.c
24471 +++ b/arch/x86/kernel/pci-swiotlb.c
24472 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24473 void *vaddr, dma_addr_t dma_addr,
24474 struct dma_attrs *attrs)
24475 {
24476 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24477 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24478 }
24479
24480 static struct dma_map_ops swiotlb_dma_ops = {
24481 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24482 index 3fb8d95..254dc51 100644
24483 --- a/arch/x86/kernel/process.c
24484 +++ b/arch/x86/kernel/process.c
24485 @@ -36,7 +36,8 @@
24486 * section. Since TSS's are completely CPU-local, we want them
24487 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24488 */
24489 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24490 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24491 +EXPORT_SYMBOL(init_tss);
24492
24493 #ifdef CONFIG_X86_64
24494 static DEFINE_PER_CPU(unsigned char, is_idle);
24495 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24496 task_xstate_cachep =
24497 kmem_cache_create("task_xstate", xstate_size,
24498 __alignof__(union thread_xstate),
24499 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24500 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24501 }
24502
24503 /*
24504 @@ -105,7 +106,7 @@ void exit_thread(void)
24505 unsigned long *bp = t->io_bitmap_ptr;
24506
24507 if (bp) {
24508 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24509 + struct tss_struct *tss = init_tss + get_cpu();
24510
24511 t->io_bitmap_ptr = NULL;
24512 clear_thread_flag(TIF_IO_BITMAP);
24513 @@ -125,6 +126,9 @@ void flush_thread(void)
24514 {
24515 struct task_struct *tsk = current;
24516
24517 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24518 + loadsegment(gs, 0);
24519 +#endif
24520 flush_ptrace_hw_breakpoint(tsk);
24521 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24522 drop_init_fpu(tsk);
24523 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24524 void exit_idle(void)
24525 {
24526 /* idle loop has pid 0 */
24527 - if (current->pid)
24528 + if (task_pid_nr(current))
24529 return;
24530 __exit_idle();
24531 }
24532 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24533 return ret;
24534 }
24535 #endif
24536 -void stop_this_cpu(void *dummy)
24537 +__noreturn void stop_this_cpu(void *dummy)
24538 {
24539 local_irq_disable();
24540 /*
24541 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24542 }
24543 early_param("idle", idle_setup);
24544
24545 -unsigned long arch_align_stack(unsigned long sp)
24546 +#ifdef CONFIG_PAX_RANDKSTACK
24547 +void pax_randomize_kstack(struct pt_regs *regs)
24548 {
24549 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24550 - sp -= get_random_int() % 8192;
24551 - return sp & ~0xf;
24552 -}
24553 + struct thread_struct *thread = &current->thread;
24554 + unsigned long time;
24555
24556 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24557 -{
24558 - unsigned long range_end = mm->brk + 0x02000000;
24559 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24560 -}
24561 + if (!randomize_va_space)
24562 + return;
24563 +
24564 + if (v8086_mode(regs))
24565 + return;
24566
24567 + rdtscl(time);
24568 +
24569 + /* P4 seems to return a 0 LSB, ignore it */
24570 +#ifdef CONFIG_MPENTIUM4
24571 + time &= 0x3EUL;
24572 + time <<= 2;
24573 +#elif defined(CONFIG_X86_64)
24574 + time &= 0xFUL;
24575 + time <<= 4;
24576 +#else
24577 + time &= 0x1FUL;
24578 + time <<= 3;
24579 +#endif
24580 +
24581 + thread->sp0 ^= time;
24582 + load_sp0(init_tss + smp_processor_id(), thread);
24583 +
24584 +#ifdef CONFIG_X86_64
24585 + this_cpu_write(kernel_stack, thread->sp0);
24586 +#endif
24587 +}
24588 +#endif
24589 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24590 index 884f98f..ec23e04 100644
24591 --- a/arch/x86/kernel/process_32.c
24592 +++ b/arch/x86/kernel/process_32.c
24593 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24594 unsigned long thread_saved_pc(struct task_struct *tsk)
24595 {
24596 return ((unsigned long *)tsk->thread.sp)[3];
24597 +//XXX return tsk->thread.eip;
24598 }
24599
24600 void __show_regs(struct pt_regs *regs, int all)
24601 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24602 unsigned long sp;
24603 unsigned short ss, gs;
24604
24605 - if (user_mode_vm(regs)) {
24606 + if (user_mode(regs)) {
24607 sp = regs->sp;
24608 ss = regs->ss & 0xffff;
24609 - gs = get_user_gs(regs);
24610 } else {
24611 sp = kernel_stack_pointer(regs);
24612 savesegment(ss, ss);
24613 - savesegment(gs, gs);
24614 }
24615 + gs = get_user_gs(regs);
24616
24617 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24618 (u16)regs->cs, regs->ip, regs->flags,
24619 - smp_processor_id());
24620 + raw_smp_processor_id());
24621 print_symbol("EIP is at %s\n", regs->ip);
24622
24623 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24624 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24625 int copy_thread(unsigned long clone_flags, unsigned long sp,
24626 unsigned long arg, struct task_struct *p)
24627 {
24628 - struct pt_regs *childregs = task_pt_regs(p);
24629 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24630 struct task_struct *tsk;
24631 int err;
24632
24633 p->thread.sp = (unsigned long) childregs;
24634 p->thread.sp0 = (unsigned long) (childregs+1);
24635 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24636
24637 if (unlikely(p->flags & PF_KTHREAD)) {
24638 /* kernel thread */
24639 memset(childregs, 0, sizeof(struct pt_regs));
24640 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24641 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24642 - childregs->ds = __USER_DS;
24643 - childregs->es = __USER_DS;
24644 + savesegment(gs, childregs->gs);
24645 + childregs->ds = __KERNEL_DS;
24646 + childregs->es = __KERNEL_DS;
24647 childregs->fs = __KERNEL_PERCPU;
24648 childregs->bx = sp; /* function */
24649 childregs->bp = arg;
24650 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24651 struct thread_struct *prev = &prev_p->thread,
24652 *next = &next_p->thread;
24653 int cpu = smp_processor_id();
24654 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24655 + struct tss_struct *tss = init_tss + cpu;
24656 fpu_switch_t fpu;
24657
24658 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24659 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24660 */
24661 lazy_save_gs(prev->gs);
24662
24663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24664 + __set_fs(task_thread_info(next_p)->addr_limit);
24665 +#endif
24666 +
24667 /*
24668 * Load the per-thread Thread-Local Storage descriptor.
24669 */
24670 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24671 */
24672 arch_end_context_switch(next_p);
24673
24674 + this_cpu_write(current_task, next_p);
24675 + this_cpu_write(current_tinfo, &next_p->tinfo);
24676 +
24677 /*
24678 * Restore %gs if needed (which is common)
24679 */
24680 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24681
24682 switch_fpu_finish(next_p, fpu);
24683
24684 - this_cpu_write(current_task, next_p);
24685 -
24686 return prev_p;
24687 }
24688
24689 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24690 } while (count++ < 16);
24691 return 0;
24692 }
24693 -
24694 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24695 index bb1dc51..08dda7f 100644
24696 --- a/arch/x86/kernel/process_64.c
24697 +++ b/arch/x86/kernel/process_64.c
24698 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24699 struct pt_regs *childregs;
24700 struct task_struct *me = current;
24701
24702 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24703 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24704 childregs = task_pt_regs(p);
24705 p->thread.sp = (unsigned long) childregs;
24706 p->thread.usersp = me->thread.usersp;
24707 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24708 set_tsk_thread_flag(p, TIF_FORK);
24709 p->fpu_counter = 0;
24710 p->thread.io_bitmap_ptr = NULL;
24711 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24712 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24713 savesegment(es, p->thread.es);
24714 savesegment(ds, p->thread.ds);
24715 + savesegment(ss, p->thread.ss);
24716 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24717 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24718
24719 if (unlikely(p->flags & PF_KTHREAD)) {
24720 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24721 struct thread_struct *prev = &prev_p->thread;
24722 struct thread_struct *next = &next_p->thread;
24723 int cpu = smp_processor_id();
24724 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24725 + struct tss_struct *tss = init_tss + cpu;
24726 unsigned fsindex, gsindex;
24727 fpu_switch_t fpu;
24728
24729 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24730 if (unlikely(next->ds | prev->ds))
24731 loadsegment(ds, next->ds);
24732
24733 + savesegment(ss, prev->ss);
24734 + if (unlikely(next->ss != prev->ss))
24735 + loadsegment(ss, next->ss);
24736
24737 /* We must save %fs and %gs before load_TLS() because
24738 * %fs and %gs may be cleared by load_TLS().
24739 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24740 prev->usersp = this_cpu_read(old_rsp);
24741 this_cpu_write(old_rsp, next->usersp);
24742 this_cpu_write(current_task, next_p);
24743 + this_cpu_write(current_tinfo, &next_p->tinfo);
24744
24745 - this_cpu_write(kernel_stack,
24746 - (unsigned long)task_stack_page(next_p) +
24747 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24748 + this_cpu_write(kernel_stack, next->sp0);
24749
24750 /*
24751 * Now maybe reload the debug registers and handle I/O bitmaps
24752 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24753 if (!p || p == current || p->state == TASK_RUNNING)
24754 return 0;
24755 stack = (unsigned long)task_stack_page(p);
24756 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24757 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24758 return 0;
24759 fp = *(u64 *)(p->thread.sp);
24760 do {
24761 - if (fp < (unsigned long)stack ||
24762 - fp >= (unsigned long)stack+THREAD_SIZE)
24763 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24764 return 0;
24765 ip = *(u64 *)(fp+8);
24766 if (!in_sched_functions(ip))
24767 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24768 index 7461f50..1334029 100644
24769 --- a/arch/x86/kernel/ptrace.c
24770 +++ b/arch/x86/kernel/ptrace.c
24771 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24772 {
24773 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24774 unsigned long sp = (unsigned long)&regs->sp;
24775 - struct thread_info *tinfo;
24776
24777 - if (context == (sp & ~(THREAD_SIZE - 1)))
24778 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24779 return sp;
24780
24781 - tinfo = (struct thread_info *)context;
24782 - if (tinfo->previous_esp)
24783 - return tinfo->previous_esp;
24784 + sp = *(unsigned long *)context;
24785 + if (sp)
24786 + return sp;
24787
24788 return (unsigned long)regs;
24789 }
24790 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24791 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24792 {
24793 int i;
24794 - int dr7 = 0;
24795 + unsigned long dr7 = 0;
24796 struct arch_hw_breakpoint *info;
24797
24798 for (i = 0; i < HBP_NUM; i++) {
24799 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24800 unsigned long addr, unsigned long data)
24801 {
24802 int ret;
24803 - unsigned long __user *datap = (unsigned long __user *)data;
24804 + unsigned long __user *datap = (__force unsigned long __user *)data;
24805
24806 switch (request) {
24807 /* read the word at location addr in the USER area. */
24808 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24809 if ((int) addr < 0)
24810 return -EIO;
24811 ret = do_get_thread_area(child, addr,
24812 - (struct user_desc __user *)data);
24813 + (__force struct user_desc __user *) data);
24814 break;
24815
24816 case PTRACE_SET_THREAD_AREA:
24817 if ((int) addr < 0)
24818 return -EIO;
24819 ret = do_set_thread_area(child, addr,
24820 - (struct user_desc __user *)data, 0);
24821 + (__force struct user_desc __user *) data, 0);
24822 break;
24823 #endif
24824
24825 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24826
24827 #ifdef CONFIG_X86_64
24828
24829 -static struct user_regset x86_64_regsets[] __read_mostly = {
24830 +static user_regset_no_const x86_64_regsets[] __read_only = {
24831 [REGSET_GENERAL] = {
24832 .core_note_type = NT_PRSTATUS,
24833 .n = sizeof(struct user_regs_struct) / sizeof(long),
24834 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24835 #endif /* CONFIG_X86_64 */
24836
24837 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24838 -static struct user_regset x86_32_regsets[] __read_mostly = {
24839 +static user_regset_no_const x86_32_regsets[] __read_only = {
24840 [REGSET_GENERAL] = {
24841 .core_note_type = NT_PRSTATUS,
24842 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24843 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24844 */
24845 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24846
24847 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24848 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24849 {
24850 #ifdef CONFIG_X86_64
24851 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24852 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24853 memset(info, 0, sizeof(*info));
24854 info->si_signo = SIGTRAP;
24855 info->si_code = si_code;
24856 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24857 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24858 }
24859
24860 void user_single_step_siginfo(struct task_struct *tsk,
24861 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24862 # define IS_IA32 0
24863 #endif
24864
24865 +#ifdef CONFIG_GRKERNSEC_SETXID
24866 +extern void gr_delayed_cred_worker(void);
24867 +#endif
24868 +
24869 /*
24870 * We must return the syscall number to actually look up in the table.
24871 * This can be -1L to skip running any syscall at all.
24872 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24873
24874 user_exit();
24875
24876 +#ifdef CONFIG_GRKERNSEC_SETXID
24877 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24878 + gr_delayed_cred_worker();
24879 +#endif
24880 +
24881 /*
24882 * If we stepped into a sysenter/syscall insn, it trapped in
24883 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24884 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24885 */
24886 user_exit();
24887
24888 +#ifdef CONFIG_GRKERNSEC_SETXID
24889 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24890 + gr_delayed_cred_worker();
24891 +#endif
24892 +
24893 audit_syscall_exit(regs);
24894
24895 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24896 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24897 index a16bae3..1f65f25 100644
24898 --- a/arch/x86/kernel/pvclock.c
24899 +++ b/arch/x86/kernel/pvclock.c
24900 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24901 return pv_tsc_khz;
24902 }
24903
24904 -static atomic64_t last_value = ATOMIC64_INIT(0);
24905 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24906
24907 void pvclock_resume(void)
24908 {
24909 - atomic64_set(&last_value, 0);
24910 + atomic64_set_unchecked(&last_value, 0);
24911 }
24912
24913 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24914 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24915 * updating at the same time, and one of them could be slightly behind,
24916 * making the assumption that last_value always go forward fail to hold.
24917 */
24918 - last = atomic64_read(&last_value);
24919 + last = atomic64_read_unchecked(&last_value);
24920 do {
24921 if (ret < last)
24922 return last;
24923 - last = atomic64_cmpxchg(&last_value, last, ret);
24924 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24925 } while (unlikely(last != ret));
24926
24927 return ret;
24928 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24929 index 618ce26..ec7e21c 100644
24930 --- a/arch/x86/kernel/reboot.c
24931 +++ b/arch/x86/kernel/reboot.c
24932 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24933
24934 void __noreturn machine_real_restart(unsigned int type)
24935 {
24936 +
24937 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24938 + struct desc_struct *gdt;
24939 +#endif
24940 +
24941 local_irq_disable();
24942
24943 /*
24944 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24945
24946 /* Jump to the identity-mapped low memory code */
24947 #ifdef CONFIG_X86_32
24948 - asm volatile("jmpl *%0" : :
24949 +
24950 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24951 + gdt = get_cpu_gdt_table(smp_processor_id());
24952 + pax_open_kernel();
24953 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24954 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24955 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24956 + loadsegment(ds, __KERNEL_DS);
24957 + loadsegment(es, __KERNEL_DS);
24958 + loadsegment(ss, __KERNEL_DS);
24959 +#endif
24960 +#ifdef CONFIG_PAX_KERNEXEC
24961 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24962 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24963 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24964 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24965 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24966 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24967 +#endif
24968 + pax_close_kernel();
24969 +#endif
24970 +
24971 + asm volatile("ljmpl *%0" : :
24972 "rm" (real_mode_header->machine_real_restart_asm),
24973 "a" (type));
24974 #else
24975 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24976 * try to force a triple fault and then cycle between hitting the keyboard
24977 * controller and doing that
24978 */
24979 -static void native_machine_emergency_restart(void)
24980 +static void __noreturn native_machine_emergency_restart(void)
24981 {
24982 int i;
24983 int attempt = 0;
24984 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
24985 #endif
24986 }
24987
24988 -static void __machine_emergency_restart(int emergency)
24989 +static void __noreturn __machine_emergency_restart(int emergency)
24990 {
24991 reboot_emergency = emergency;
24992 machine_ops.emergency_restart();
24993 }
24994
24995 -static void native_machine_restart(char *__unused)
24996 +static void __noreturn native_machine_restart(char *__unused)
24997 {
24998 pr_notice("machine restart\n");
24999
25000 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25001 __machine_emergency_restart(0);
25002 }
25003
25004 -static void native_machine_halt(void)
25005 +static void __noreturn native_machine_halt(void)
25006 {
25007 /* Stop other cpus and apics */
25008 machine_shutdown();
25009 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25010 stop_this_cpu(NULL);
25011 }
25012
25013 -static void native_machine_power_off(void)
25014 +static void __noreturn native_machine_power_off(void)
25015 {
25016 if (pm_power_off) {
25017 if (!reboot_force)
25018 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25019 }
25020 /* A fallback in case there is no PM info available */
25021 tboot_shutdown(TB_SHUTDOWN_HALT);
25022 + unreachable();
25023 }
25024
25025 -struct machine_ops machine_ops = {
25026 +struct machine_ops machine_ops __read_only = {
25027 .power_off = native_machine_power_off,
25028 .shutdown = native_machine_shutdown,
25029 .emergency_restart = native_machine_emergency_restart,
25030 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25031 index c8e41e9..64049ef 100644
25032 --- a/arch/x86/kernel/reboot_fixups_32.c
25033 +++ b/arch/x86/kernel/reboot_fixups_32.c
25034 @@ -57,7 +57,7 @@ struct device_fixup {
25035 unsigned int vendor;
25036 unsigned int device;
25037 void (*reboot_fixup)(struct pci_dev *);
25038 -};
25039 +} __do_const;
25040
25041 /*
25042 * PCI ids solely used for fixups_table go here
25043 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25044 index 3fd2c69..16ef367 100644
25045 --- a/arch/x86/kernel/relocate_kernel_64.S
25046 +++ b/arch/x86/kernel/relocate_kernel_64.S
25047 @@ -11,6 +11,7 @@
25048 #include <asm/kexec.h>
25049 #include <asm/processor-flags.h>
25050 #include <asm/pgtable_types.h>
25051 +#include <asm/alternative-asm.h>
25052
25053 /*
25054 * Must be relocatable PIC code callable as a C function
25055 @@ -96,8 +97,7 @@ relocate_kernel:
25056
25057 /* jump to identity mapped page */
25058 addq $(identity_mapped - relocate_kernel), %r8
25059 - pushq %r8
25060 - ret
25061 + jmp *%r8
25062
25063 identity_mapped:
25064 /* set return address to 0 if not preserving context */
25065 @@ -167,6 +167,7 @@ identity_mapped:
25066 xorl %r14d, %r14d
25067 xorl %r15d, %r15d
25068
25069 + pax_force_retaddr 0, 1
25070 ret
25071
25072 1:
25073 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25074 index f0de629..a4978a8f 100644
25075 --- a/arch/x86/kernel/setup.c
25076 +++ b/arch/x86/kernel/setup.c
25077 @@ -110,6 +110,7 @@
25078 #include <asm/mce.h>
25079 #include <asm/alternative.h>
25080 #include <asm/prom.h>
25081 +#include <asm/boot.h>
25082
25083 /*
25084 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25085 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25086 #endif
25087
25088
25089 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25090 -__visible unsigned long mmu_cr4_features;
25091 +#ifdef CONFIG_X86_64
25092 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25093 +#elif defined(CONFIG_X86_PAE)
25094 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25095 #else
25096 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25097 +__visible unsigned long mmu_cr4_features __read_only;
25098 #endif
25099
25100 +void set_in_cr4(unsigned long mask)
25101 +{
25102 + unsigned long cr4 = read_cr4();
25103 +
25104 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25105 + return;
25106 +
25107 + pax_open_kernel();
25108 + mmu_cr4_features |= mask;
25109 + pax_close_kernel();
25110 +
25111 + if (trampoline_cr4_features)
25112 + *trampoline_cr4_features = mmu_cr4_features;
25113 + cr4 |= mask;
25114 + write_cr4(cr4);
25115 +}
25116 +EXPORT_SYMBOL(set_in_cr4);
25117 +
25118 +void clear_in_cr4(unsigned long mask)
25119 +{
25120 + unsigned long cr4 = read_cr4();
25121 +
25122 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25123 + return;
25124 +
25125 + pax_open_kernel();
25126 + mmu_cr4_features &= ~mask;
25127 + pax_close_kernel();
25128 +
25129 + if (trampoline_cr4_features)
25130 + *trampoline_cr4_features = mmu_cr4_features;
25131 + cr4 &= ~mask;
25132 + write_cr4(cr4);
25133 +}
25134 +EXPORT_SYMBOL(clear_in_cr4);
25135 +
25136 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25137 int bootloader_type, bootloader_version;
25138
25139 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25140 * area (640->1Mb) as ram even though it is not.
25141 * take them out.
25142 */
25143 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25144 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25145
25146 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25147 }
25148 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25149 /* called before trim_bios_range() to spare extra sanitize */
25150 static void __init e820_add_kernel_range(void)
25151 {
25152 - u64 start = __pa_symbol(_text);
25153 + u64 start = __pa_symbol(ktla_ktva(_text));
25154 u64 size = __pa_symbol(_end) - start;
25155
25156 /*
25157 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25158
25159 void __init setup_arch(char **cmdline_p)
25160 {
25161 +#ifdef CONFIG_X86_32
25162 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25163 +#else
25164 memblock_reserve(__pa_symbol(_text),
25165 (unsigned long)__bss_stop - (unsigned long)_text);
25166 +#endif
25167
25168 early_reserve_initrd();
25169
25170 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25171
25172 if (!boot_params.hdr.root_flags)
25173 root_mountflags &= ~MS_RDONLY;
25174 - init_mm.start_code = (unsigned long) _text;
25175 - init_mm.end_code = (unsigned long) _etext;
25176 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25177 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25178 init_mm.end_data = (unsigned long) _edata;
25179 init_mm.brk = _brk_end;
25180
25181 - code_resource.start = __pa_symbol(_text);
25182 - code_resource.end = __pa_symbol(_etext)-1;
25183 - data_resource.start = __pa_symbol(_etext);
25184 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25185 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25186 + data_resource.start = __pa_symbol(_sdata);
25187 data_resource.end = __pa_symbol(_edata)-1;
25188 bss_resource.start = __pa_symbol(__bss_start);
25189 bss_resource.end = __pa_symbol(__bss_stop)-1;
25190 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25191 index 5cdff03..80fa283 100644
25192 --- a/arch/x86/kernel/setup_percpu.c
25193 +++ b/arch/x86/kernel/setup_percpu.c
25194 @@ -21,19 +21,17 @@
25195 #include <asm/cpu.h>
25196 #include <asm/stackprotector.h>
25197
25198 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25199 +#ifdef CONFIG_SMP
25200 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25201 EXPORT_PER_CPU_SYMBOL(cpu_number);
25202 +#endif
25203
25204 -#ifdef CONFIG_X86_64
25205 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25206 -#else
25207 -#define BOOT_PERCPU_OFFSET 0
25208 -#endif
25209
25210 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25211 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25212
25213 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25214 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25215 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25216 };
25217 EXPORT_SYMBOL(__per_cpu_offset);
25218 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25219 {
25220 #ifdef CONFIG_NEED_MULTIPLE_NODES
25221 pg_data_t *last = NULL;
25222 - unsigned int cpu;
25223 + int cpu;
25224
25225 for_each_possible_cpu(cpu) {
25226 int node = early_cpu_to_node(cpu);
25227 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25228 {
25229 #ifdef CONFIG_X86_32
25230 struct desc_struct gdt;
25231 + unsigned long base = per_cpu_offset(cpu);
25232
25233 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25234 - 0x2 | DESCTYPE_S, 0x8);
25235 - gdt.s = 1;
25236 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25237 + 0x83 | DESCTYPE_S, 0xC);
25238 write_gdt_entry(get_cpu_gdt_table(cpu),
25239 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25240 #endif
25241 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25242 /* alrighty, percpu areas up and running */
25243 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25244 for_each_possible_cpu(cpu) {
25245 +#ifdef CONFIG_CC_STACKPROTECTOR
25246 +#ifdef CONFIG_X86_32
25247 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25248 +#endif
25249 +#endif
25250 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25251 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25252 per_cpu(cpu_number, cpu) = cpu;
25253 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25254 */
25255 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25256 #endif
25257 +#ifdef CONFIG_CC_STACKPROTECTOR
25258 +#ifdef CONFIG_X86_32
25259 + if (!cpu)
25260 + per_cpu(stack_canary.canary, cpu) = canary;
25261 +#endif
25262 +#endif
25263 /*
25264 * Up to this point, the boot CPU has been using .init.data
25265 * area. Reload any changed state for the boot CPU.
25266 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25267 index 9e5de68..16c53cb 100644
25268 --- a/arch/x86/kernel/signal.c
25269 +++ b/arch/x86/kernel/signal.c
25270 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25271 * Align the stack pointer according to the i386 ABI,
25272 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25273 */
25274 - sp = ((sp + 4) & -16ul) - 4;
25275 + sp = ((sp - 12) & -16ul) - 4;
25276 #else /* !CONFIG_X86_32 */
25277 sp = round_down(sp, 16) - 8;
25278 #endif
25279 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25280 }
25281
25282 if (current->mm->context.vdso)
25283 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25284 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25285 else
25286 - restorer = &frame->retcode;
25287 + restorer = (void __user *)&frame->retcode;
25288 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25289 restorer = ksig->ka.sa.sa_restorer;
25290
25291 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25292 * reasons and because gdb uses it as a signature to notice
25293 * signal handler stack frames.
25294 */
25295 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25296 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25297
25298 if (err)
25299 return -EFAULT;
25300 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25301 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25302
25303 /* Set up to return from userspace. */
25304 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25305 + if (current->mm->context.vdso)
25306 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25307 + else
25308 + restorer = (void __user *)&frame->retcode;
25309 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25310 restorer = ksig->ka.sa.sa_restorer;
25311 put_user_ex(restorer, &frame->pretcode);
25312 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25313 * reasons and because gdb uses it as a signature to notice
25314 * signal handler stack frames.
25315 */
25316 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25317 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25318 } put_user_catch(err);
25319
25320 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25321 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25322 {
25323 int usig = signr_convert(ksig->sig);
25324 sigset_t *set = sigmask_to_save();
25325 - compat_sigset_t *cset = (compat_sigset_t *) set;
25326 + sigset_t sigcopy;
25327 + compat_sigset_t *cset;
25328 +
25329 + sigcopy = *set;
25330 +
25331 + cset = (compat_sigset_t *) &sigcopy;
25332
25333 /* Set up the stack frame */
25334 if (is_ia32_frame()) {
25335 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25336 } else if (is_x32_frame()) {
25337 return x32_setup_rt_frame(ksig, cset, regs);
25338 } else {
25339 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25340 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25341 }
25342 }
25343
25344 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25345 index 7c3a5a6..f0a8961 100644
25346 --- a/arch/x86/kernel/smp.c
25347 +++ b/arch/x86/kernel/smp.c
25348 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25349
25350 __setup("nonmi_ipi", nonmi_ipi_setup);
25351
25352 -struct smp_ops smp_ops = {
25353 +struct smp_ops smp_ops __read_only = {
25354 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25355 .smp_prepare_cpus = native_smp_prepare_cpus,
25356 .smp_cpus_done = native_smp_cpus_done,
25357 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25358 index 6cacab6..750636a 100644
25359 --- a/arch/x86/kernel/smpboot.c
25360 +++ b/arch/x86/kernel/smpboot.c
25361 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25362
25363 enable_start_cpu0 = 0;
25364
25365 -#ifdef CONFIG_X86_32
25366 - /* switch away from the initial page table */
25367 - load_cr3(swapper_pg_dir);
25368 - __flush_tlb_all();
25369 -#endif
25370 -
25371 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25372 barrier();
25373 +
25374 + /* switch away from the initial page table */
25375 +#ifdef CONFIG_PAX_PER_CPU_PGD
25376 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25377 + __flush_tlb_all();
25378 +#elif defined(CONFIG_X86_32)
25379 + load_cr3(swapper_pg_dir);
25380 + __flush_tlb_all();
25381 +#endif
25382 +
25383 /*
25384 * Check TSC synchronization with the BP:
25385 */
25386 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25387 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25388 (THREAD_SIZE + task_stack_page(idle))) - 1);
25389 per_cpu(current_task, cpu) = idle;
25390 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25391
25392 #ifdef CONFIG_X86_32
25393 /* Stack for startup_32 can be just as for start_secondary onwards */
25394 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25395 #else
25396 clear_tsk_thread_flag(idle, TIF_FORK);
25397 initial_gs = per_cpu_offset(cpu);
25398 - per_cpu(kernel_stack, cpu) =
25399 - (unsigned long)task_stack_page(idle) -
25400 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25401 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25402 #endif
25403 +
25404 + pax_open_kernel();
25405 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25406 + pax_close_kernel();
25407 +
25408 initial_code = (unsigned long)start_secondary;
25409 stack_start = idle->thread.sp;
25410
25411 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25412 /* the FPU context is blank, nobody can own it */
25413 __cpu_disable_lazy_restore(cpu);
25414
25415 +#ifdef CONFIG_PAX_PER_CPU_PGD
25416 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25417 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25418 + KERNEL_PGD_PTRS);
25419 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25420 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25421 + KERNEL_PGD_PTRS);
25422 +#endif
25423 +
25424 err = do_boot_cpu(apicid, cpu, tidle);
25425 if (err) {
25426 pr_debug("do_boot_cpu failed %d\n", err);
25427 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25428 index 9b4d51d..5d28b58 100644
25429 --- a/arch/x86/kernel/step.c
25430 +++ b/arch/x86/kernel/step.c
25431 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25432 struct desc_struct *desc;
25433 unsigned long base;
25434
25435 - seg &= ~7UL;
25436 + seg >>= 3;
25437
25438 mutex_lock(&child->mm->context.lock);
25439 - if (unlikely((seg >> 3) >= child->mm->context.size))
25440 + if (unlikely(seg >= child->mm->context.size))
25441 addr = -1L; /* bogus selector, access would fault */
25442 else {
25443 desc = child->mm->context.ldt + seg;
25444 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25445 addr += base;
25446 }
25447 mutex_unlock(&child->mm->context.lock);
25448 - }
25449 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25450 + addr = ktla_ktva(addr);
25451
25452 return addr;
25453 }
25454 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25455 unsigned char opcode[15];
25456 unsigned long addr = convert_ip_to_linear(child, regs);
25457
25458 + if (addr == -EINVAL)
25459 + return 0;
25460 +
25461 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25462 for (i = 0; i < copied; i++) {
25463 switch (opcode[i]) {
25464 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25465 new file mode 100644
25466 index 0000000..5877189
25467 --- /dev/null
25468 +++ b/arch/x86/kernel/sys_i386_32.c
25469 @@ -0,0 +1,189 @@
25470 +/*
25471 + * This file contains various random system calls that
25472 + * have a non-standard calling sequence on the Linux/i386
25473 + * platform.
25474 + */
25475 +
25476 +#include <linux/errno.h>
25477 +#include <linux/sched.h>
25478 +#include <linux/mm.h>
25479 +#include <linux/fs.h>
25480 +#include <linux/smp.h>
25481 +#include <linux/sem.h>
25482 +#include <linux/msg.h>
25483 +#include <linux/shm.h>
25484 +#include <linux/stat.h>
25485 +#include <linux/syscalls.h>
25486 +#include <linux/mman.h>
25487 +#include <linux/file.h>
25488 +#include <linux/utsname.h>
25489 +#include <linux/ipc.h>
25490 +#include <linux/elf.h>
25491 +
25492 +#include <linux/uaccess.h>
25493 +#include <linux/unistd.h>
25494 +
25495 +#include <asm/syscalls.h>
25496 +
25497 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25498 +{
25499 + unsigned long pax_task_size = TASK_SIZE;
25500 +
25501 +#ifdef CONFIG_PAX_SEGMEXEC
25502 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25503 + pax_task_size = SEGMEXEC_TASK_SIZE;
25504 +#endif
25505 +
25506 + if (flags & MAP_FIXED)
25507 + if (len > pax_task_size || addr > pax_task_size - len)
25508 + return -EINVAL;
25509 +
25510 + return 0;
25511 +}
25512 +
25513 +/*
25514 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25515 + */
25516 +static unsigned long get_align_mask(void)
25517 +{
25518 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25519 + return 0;
25520 +
25521 + if (!(current->flags & PF_RANDOMIZE))
25522 + return 0;
25523 +
25524 + return va_align.mask;
25525 +}
25526 +
25527 +unsigned long
25528 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25529 + unsigned long len, unsigned long pgoff, unsigned long flags)
25530 +{
25531 + struct mm_struct *mm = current->mm;
25532 + struct vm_area_struct *vma;
25533 + unsigned long pax_task_size = TASK_SIZE;
25534 + struct vm_unmapped_area_info info;
25535 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25536 +
25537 +#ifdef CONFIG_PAX_SEGMEXEC
25538 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25539 + pax_task_size = SEGMEXEC_TASK_SIZE;
25540 +#endif
25541 +
25542 + pax_task_size -= PAGE_SIZE;
25543 +
25544 + if (len > pax_task_size)
25545 + return -ENOMEM;
25546 +
25547 + if (flags & MAP_FIXED)
25548 + return addr;
25549 +
25550 +#ifdef CONFIG_PAX_RANDMMAP
25551 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25552 +#endif
25553 +
25554 + if (addr) {
25555 + addr = PAGE_ALIGN(addr);
25556 + if (pax_task_size - len >= addr) {
25557 + vma = find_vma(mm, addr);
25558 + if (check_heap_stack_gap(vma, addr, len, offset))
25559 + return addr;
25560 + }
25561 + }
25562 +
25563 + info.flags = 0;
25564 + info.length = len;
25565 + info.align_mask = filp ? get_align_mask() : 0;
25566 + info.align_offset = pgoff << PAGE_SHIFT;
25567 + info.threadstack_offset = offset;
25568 +
25569 +#ifdef CONFIG_PAX_PAGEEXEC
25570 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25571 + info.low_limit = 0x00110000UL;
25572 + info.high_limit = mm->start_code;
25573 +
25574 +#ifdef CONFIG_PAX_RANDMMAP
25575 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25576 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25577 +#endif
25578 +
25579 + if (info.low_limit < info.high_limit) {
25580 + addr = vm_unmapped_area(&info);
25581 + if (!IS_ERR_VALUE(addr))
25582 + return addr;
25583 + }
25584 + } else
25585 +#endif
25586 +
25587 + info.low_limit = mm->mmap_base;
25588 + info.high_limit = pax_task_size;
25589 +
25590 + return vm_unmapped_area(&info);
25591 +}
25592 +
25593 +unsigned long
25594 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25595 + const unsigned long len, const unsigned long pgoff,
25596 + const unsigned long flags)
25597 +{
25598 + struct vm_area_struct *vma;
25599 + struct mm_struct *mm = current->mm;
25600 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25601 + struct vm_unmapped_area_info info;
25602 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25603 +
25604 +#ifdef CONFIG_PAX_SEGMEXEC
25605 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25606 + pax_task_size = SEGMEXEC_TASK_SIZE;
25607 +#endif
25608 +
25609 + pax_task_size -= PAGE_SIZE;
25610 +
25611 + /* requested length too big for entire address space */
25612 + if (len > pax_task_size)
25613 + return -ENOMEM;
25614 +
25615 + if (flags & MAP_FIXED)
25616 + return addr;
25617 +
25618 +#ifdef CONFIG_PAX_PAGEEXEC
25619 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25620 + goto bottomup;
25621 +#endif
25622 +
25623 +#ifdef CONFIG_PAX_RANDMMAP
25624 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25625 +#endif
25626 +
25627 + /* requesting a specific address */
25628 + if (addr) {
25629 + addr = PAGE_ALIGN(addr);
25630 + if (pax_task_size - len >= addr) {
25631 + vma = find_vma(mm, addr);
25632 + if (check_heap_stack_gap(vma, addr, len, offset))
25633 + return addr;
25634 + }
25635 + }
25636 +
25637 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25638 + info.length = len;
25639 + info.low_limit = PAGE_SIZE;
25640 + info.high_limit = mm->mmap_base;
25641 + info.align_mask = filp ? get_align_mask() : 0;
25642 + info.align_offset = pgoff << PAGE_SHIFT;
25643 + info.threadstack_offset = offset;
25644 +
25645 + addr = vm_unmapped_area(&info);
25646 + if (!(addr & ~PAGE_MASK))
25647 + return addr;
25648 + VM_BUG_ON(addr != -ENOMEM);
25649 +
25650 +bottomup:
25651 + /*
25652 + * A failed mmap() very likely causes application failure,
25653 + * so fall back to the bottom-up function here. This scenario
25654 + * can happen with large stack limits and large mmap()
25655 + * allocations.
25656 + */
25657 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25658 +}
25659 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25660 index 30277e2..5664a29 100644
25661 --- a/arch/x86/kernel/sys_x86_64.c
25662 +++ b/arch/x86/kernel/sys_x86_64.c
25663 @@ -81,8 +81,8 @@ out:
25664 return error;
25665 }
25666
25667 -static void find_start_end(unsigned long flags, unsigned long *begin,
25668 - unsigned long *end)
25669 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25670 + unsigned long *begin, unsigned long *end)
25671 {
25672 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25673 unsigned long new_begin;
25674 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25675 *begin = new_begin;
25676 }
25677 } else {
25678 - *begin = current->mm->mmap_legacy_base;
25679 + *begin = mm->mmap_legacy_base;
25680 *end = TASK_SIZE;
25681 }
25682 }
25683 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25684 struct vm_area_struct *vma;
25685 struct vm_unmapped_area_info info;
25686 unsigned long begin, end;
25687 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25688
25689 if (flags & MAP_FIXED)
25690 return addr;
25691
25692 - find_start_end(flags, &begin, &end);
25693 + find_start_end(mm, flags, &begin, &end);
25694
25695 if (len > end)
25696 return -ENOMEM;
25697
25698 +#ifdef CONFIG_PAX_RANDMMAP
25699 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25700 +#endif
25701 +
25702 if (addr) {
25703 addr = PAGE_ALIGN(addr);
25704 vma = find_vma(mm, addr);
25705 - if (end - len >= addr &&
25706 - (!vma || addr + len <= vma->vm_start))
25707 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25708 return addr;
25709 }
25710
25711 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25712 info.high_limit = end;
25713 info.align_mask = filp ? get_align_mask() : 0;
25714 info.align_offset = pgoff << PAGE_SHIFT;
25715 + info.threadstack_offset = offset;
25716 return vm_unmapped_area(&info);
25717 }
25718
25719 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25720 struct mm_struct *mm = current->mm;
25721 unsigned long addr = addr0;
25722 struct vm_unmapped_area_info info;
25723 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25724
25725 /* requested length too big for entire address space */
25726 if (len > TASK_SIZE)
25727 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25728 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25729 goto bottomup;
25730
25731 +#ifdef CONFIG_PAX_RANDMMAP
25732 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25733 +#endif
25734 +
25735 /* requesting a specific address */
25736 if (addr) {
25737 addr = PAGE_ALIGN(addr);
25738 vma = find_vma(mm, addr);
25739 - if (TASK_SIZE - len >= addr &&
25740 - (!vma || addr + len <= vma->vm_start))
25741 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25742 return addr;
25743 }
25744
25745 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25746 info.high_limit = mm->mmap_base;
25747 info.align_mask = filp ? get_align_mask() : 0;
25748 info.align_offset = pgoff << PAGE_SHIFT;
25749 + info.threadstack_offset = offset;
25750 addr = vm_unmapped_area(&info);
25751 if (!(addr & ~PAGE_MASK))
25752 return addr;
25753 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25754 index 91a4496..1730bff 100644
25755 --- a/arch/x86/kernel/tboot.c
25756 +++ b/arch/x86/kernel/tboot.c
25757 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25758
25759 void tboot_shutdown(u32 shutdown_type)
25760 {
25761 - void (*shutdown)(void);
25762 + void (* __noreturn shutdown)(void);
25763
25764 if (!tboot_enabled())
25765 return;
25766 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25767
25768 switch_to_tboot_pt();
25769
25770 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25771 + shutdown = (void *)tboot->shutdown_entry;
25772 shutdown();
25773
25774 /* should not reach here */
25775 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
25776 return -ENODEV;
25777 }
25778
25779 -static atomic_t ap_wfs_count;
25780 +static atomic_unchecked_t ap_wfs_count;
25781
25782 static int tboot_wait_for_aps(int num_aps)
25783 {
25784 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25785 {
25786 switch (action) {
25787 case CPU_DYING:
25788 - atomic_inc(&ap_wfs_count);
25789 + atomic_inc_unchecked(&ap_wfs_count);
25790 if (num_online_cpus() == 1)
25791 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25792 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25793 return NOTIFY_BAD;
25794 break;
25795 }
25796 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
25797
25798 tboot_create_trampoline();
25799
25800 - atomic_set(&ap_wfs_count, 0);
25801 + atomic_set_unchecked(&ap_wfs_count, 0);
25802 register_hotcpu_notifier(&tboot_cpu_notifier);
25803
25804 #ifdef CONFIG_DEBUG_FS
25805 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25806 index 24d3c91..d06b473 100644
25807 --- a/arch/x86/kernel/time.c
25808 +++ b/arch/x86/kernel/time.c
25809 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25810 {
25811 unsigned long pc = instruction_pointer(regs);
25812
25813 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25814 + if (!user_mode(regs) && in_lock_functions(pc)) {
25815 #ifdef CONFIG_FRAME_POINTER
25816 - return *(unsigned long *)(regs->bp + sizeof(long));
25817 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25818 #else
25819 unsigned long *sp =
25820 (unsigned long *)kernel_stack_pointer(regs);
25821 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25822 * or above a saved flags. Eflags has bits 22-31 zero,
25823 * kernel addresses don't.
25824 */
25825 +
25826 +#ifdef CONFIG_PAX_KERNEXEC
25827 + return ktla_ktva(sp[0]);
25828 +#else
25829 if (sp[0] >> 22)
25830 return sp[0];
25831 if (sp[1] >> 22)
25832 return sp[1];
25833 #endif
25834 +
25835 +#endif
25836 }
25837 return pc;
25838 }
25839 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25840 index f7fec09..9991981 100644
25841 --- a/arch/x86/kernel/tls.c
25842 +++ b/arch/x86/kernel/tls.c
25843 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25844 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25845 return -EINVAL;
25846
25847 +#ifdef CONFIG_PAX_SEGMEXEC
25848 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25849 + return -EINVAL;
25850 +#endif
25851 +
25852 set_tls_desc(p, idx, &info, 1);
25853
25854 return 0;
25855 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25856
25857 if (kbuf)
25858 info = kbuf;
25859 - else if (__copy_from_user(infobuf, ubuf, count))
25860 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25861 return -EFAULT;
25862 else
25863 info = infobuf;
25864 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25865 index 1c113db..287b42e 100644
25866 --- a/arch/x86/kernel/tracepoint.c
25867 +++ b/arch/x86/kernel/tracepoint.c
25868 @@ -9,11 +9,11 @@
25869 #include <linux/atomic.h>
25870
25871 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25872 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25873 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25874 (unsigned long) trace_idt_table };
25875
25876 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25877 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25878 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25879
25880 static int trace_irq_vector_refcount;
25881 static DEFINE_MUTEX(irq_vector_mutex);
25882 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25883 index 8c8093b..c93f581 100644
25884 --- a/arch/x86/kernel/traps.c
25885 +++ b/arch/x86/kernel/traps.c
25886 @@ -66,7 +66,7 @@
25887 #include <asm/proto.h>
25888
25889 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25890 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25891 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25892 #else
25893 #include <asm/processor-flags.h>
25894 #include <asm/setup.h>
25895 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
25896 #endif
25897
25898 /* Must be page-aligned because the real IDT is used in a fixmap. */
25899 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25900 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25901
25902 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25903 EXPORT_SYMBOL_GPL(used_vectors);
25904 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25905 }
25906
25907 static int __kprobes
25908 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25909 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25910 struct pt_regs *regs, long error_code)
25911 {
25912 #ifdef CONFIG_X86_32
25913 - if (regs->flags & X86_VM_MASK) {
25914 + if (v8086_mode(regs)) {
25915 /*
25916 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25917 * On nmi (interrupt 2), do_trap should not be called.
25918 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25919 return -1;
25920 }
25921 #endif
25922 - if (!user_mode(regs)) {
25923 + if (!user_mode_novm(regs)) {
25924 if (!fixup_exception(regs)) {
25925 tsk->thread.error_code = error_code;
25926 tsk->thread.trap_nr = trapnr;
25927 +
25928 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25929 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25930 + str = "PAX: suspicious stack segment fault";
25931 +#endif
25932 +
25933 die(str, regs, error_code);
25934 }
25935 +
25936 +#ifdef CONFIG_PAX_REFCOUNT
25937 + if (trapnr == 4)
25938 + pax_report_refcount_overflow(regs);
25939 +#endif
25940 +
25941 return 0;
25942 }
25943
25944 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25945 }
25946
25947 static void __kprobes
25948 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25949 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25950 long error_code, siginfo_t *info)
25951 {
25952 struct task_struct *tsk = current;
25953 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25954 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25955 printk_ratelimit()) {
25956 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25957 - tsk->comm, tsk->pid, str,
25958 + tsk->comm, task_pid_nr(tsk), str,
25959 regs->ip, regs->sp, error_code);
25960 print_vma_addr(" in ", regs->ip);
25961 pr_cont("\n");
25962 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25963 conditional_sti(regs);
25964
25965 #ifdef CONFIG_X86_32
25966 - if (regs->flags & X86_VM_MASK) {
25967 + if (v8086_mode(regs)) {
25968 local_irq_enable();
25969 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25970 goto exit;
25971 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25972 #endif
25973
25974 tsk = current;
25975 - if (!user_mode(regs)) {
25976 + if (!user_mode_novm(regs)) {
25977 if (fixup_exception(regs))
25978 goto exit;
25979
25980 tsk->thread.error_code = error_code;
25981 tsk->thread.trap_nr = X86_TRAP_GP;
25982 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25983 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25984 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25985 +
25986 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25987 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25988 + die("PAX: suspicious general protection fault", regs, error_code);
25989 + else
25990 +#endif
25991 +
25992 die("general protection fault", regs, error_code);
25993 + }
25994 goto exit;
25995 }
25996
25997 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25998 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25999 + struct mm_struct *mm = tsk->mm;
26000 + unsigned long limit;
26001 +
26002 + down_write(&mm->mmap_sem);
26003 + limit = mm->context.user_cs_limit;
26004 + if (limit < TASK_SIZE) {
26005 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26006 + up_write(&mm->mmap_sem);
26007 + return;
26008 + }
26009 + up_write(&mm->mmap_sem);
26010 + }
26011 +#endif
26012 +
26013 tsk->thread.error_code = error_code;
26014 tsk->thread.trap_nr = X86_TRAP_GP;
26015
26016 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26017 /* It's safe to allow irq's after DR6 has been saved */
26018 preempt_conditional_sti(regs);
26019
26020 - if (regs->flags & X86_VM_MASK) {
26021 + if (v8086_mode(regs)) {
26022 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26023 X86_TRAP_DB);
26024 preempt_conditional_cli(regs);
26025 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26026 * We already checked v86 mode above, so we can check for kernel mode
26027 * by just checking the CPL of CS.
26028 */
26029 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26030 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26031 tsk->thread.debugreg6 &= ~DR_STEP;
26032 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26033 regs->flags &= ~X86_EFLAGS_TF;
26034 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26035 return;
26036 conditional_sti(regs);
26037
26038 - if (!user_mode_vm(regs))
26039 + if (!user_mode(regs))
26040 {
26041 if (!fixup_exception(regs)) {
26042 task->thread.error_code = error_code;
26043 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26044 index 2ed8459..7cf329f 100644
26045 --- a/arch/x86/kernel/uprobes.c
26046 +++ b/arch/x86/kernel/uprobes.c
26047 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26048 int ret = NOTIFY_DONE;
26049
26050 /* We are only interested in userspace traps */
26051 - if (regs && !user_mode_vm(regs))
26052 + if (regs && !user_mode(regs))
26053 return NOTIFY_DONE;
26054
26055 switch (val) {
26056 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26057
26058 if (ncopied != rasize) {
26059 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26060 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26061 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26062
26063 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26064 }
26065 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26066 index b9242ba..50c5edd 100644
26067 --- a/arch/x86/kernel/verify_cpu.S
26068 +++ b/arch/x86/kernel/verify_cpu.S
26069 @@ -20,6 +20,7 @@
26070 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26071 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26072 * arch/x86/kernel/head_32.S: processor startup
26073 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26074 *
26075 * verify_cpu, returns the status of longmode and SSE in register %eax.
26076 * 0: Success 1: Failure
26077 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26078 index e8edcf5..27f9344 100644
26079 --- a/arch/x86/kernel/vm86_32.c
26080 +++ b/arch/x86/kernel/vm86_32.c
26081 @@ -44,6 +44,7 @@
26082 #include <linux/ptrace.h>
26083 #include <linux/audit.h>
26084 #include <linux/stddef.h>
26085 +#include <linux/grsecurity.h>
26086
26087 #include <asm/uaccess.h>
26088 #include <asm/io.h>
26089 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26090 do_exit(SIGSEGV);
26091 }
26092
26093 - tss = &per_cpu(init_tss, get_cpu());
26094 + tss = init_tss + get_cpu();
26095 current->thread.sp0 = current->thread.saved_sp0;
26096 current->thread.sysenter_cs = __KERNEL_CS;
26097 load_sp0(tss, &current->thread);
26098 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26099
26100 if (tsk->thread.saved_sp0)
26101 return -EPERM;
26102 +
26103 +#ifdef CONFIG_GRKERNSEC_VM86
26104 + if (!capable(CAP_SYS_RAWIO)) {
26105 + gr_handle_vm86();
26106 + return -EPERM;
26107 + }
26108 +#endif
26109 +
26110 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26111 offsetof(struct kernel_vm86_struct, vm86plus) -
26112 sizeof(info.regs));
26113 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26114 int tmp;
26115 struct vm86plus_struct __user *v86;
26116
26117 +#ifdef CONFIG_GRKERNSEC_VM86
26118 + if (!capable(CAP_SYS_RAWIO)) {
26119 + gr_handle_vm86();
26120 + return -EPERM;
26121 + }
26122 +#endif
26123 +
26124 tsk = current;
26125 switch (cmd) {
26126 case VM86_REQUEST_IRQ:
26127 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26128 tsk->thread.saved_fs = info->regs32->fs;
26129 tsk->thread.saved_gs = get_user_gs(info->regs32);
26130
26131 - tss = &per_cpu(init_tss, get_cpu());
26132 + tss = init_tss + get_cpu();
26133 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26134 if (cpu_has_sep)
26135 tsk->thread.sysenter_cs = 0;
26136 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26137 goto cannot_handle;
26138 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26139 goto cannot_handle;
26140 - intr_ptr = (unsigned long __user *) (i << 2);
26141 + intr_ptr = (__force unsigned long __user *) (i << 2);
26142 if (get_user(segoffs, intr_ptr))
26143 goto cannot_handle;
26144 if ((segoffs >> 16) == BIOSSEG)
26145 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26146 index 10c4f30..65408b9 100644
26147 --- a/arch/x86/kernel/vmlinux.lds.S
26148 +++ b/arch/x86/kernel/vmlinux.lds.S
26149 @@ -26,6 +26,13 @@
26150 #include <asm/page_types.h>
26151 #include <asm/cache.h>
26152 #include <asm/boot.h>
26153 +#include <asm/segment.h>
26154 +
26155 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26156 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26157 +#else
26158 +#define __KERNEL_TEXT_OFFSET 0
26159 +#endif
26160
26161 #undef i386 /* in case the preprocessor is a 32bit one */
26162
26163 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26164
26165 PHDRS {
26166 text PT_LOAD FLAGS(5); /* R_E */
26167 +#ifdef CONFIG_X86_32
26168 + module PT_LOAD FLAGS(5); /* R_E */
26169 +#endif
26170 +#ifdef CONFIG_XEN
26171 + rodata PT_LOAD FLAGS(5); /* R_E */
26172 +#else
26173 + rodata PT_LOAD FLAGS(4); /* R__ */
26174 +#endif
26175 data PT_LOAD FLAGS(6); /* RW_ */
26176 -#ifdef CONFIG_X86_64
26177 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26178 #ifdef CONFIG_SMP
26179 percpu PT_LOAD FLAGS(6); /* RW_ */
26180 #endif
26181 + text.init PT_LOAD FLAGS(5); /* R_E */
26182 + text.exit PT_LOAD FLAGS(5); /* R_E */
26183 init PT_LOAD FLAGS(7); /* RWE */
26184 -#endif
26185 note PT_NOTE FLAGS(0); /* ___ */
26186 }
26187
26188 SECTIONS
26189 {
26190 #ifdef CONFIG_X86_32
26191 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26192 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26193 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26194 #else
26195 - . = __START_KERNEL;
26196 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26197 + . = __START_KERNEL;
26198 #endif
26199
26200 /* Text and read-only data */
26201 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26202 - _text = .;
26203 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26204 /* bootstrapping code */
26205 +#ifdef CONFIG_X86_32
26206 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26207 +#else
26208 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26209 +#endif
26210 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26211 + _text = .;
26212 HEAD_TEXT
26213 . = ALIGN(8);
26214 _stext = .;
26215 @@ -104,13 +124,47 @@ SECTIONS
26216 IRQENTRY_TEXT
26217 *(.fixup)
26218 *(.gnu.warning)
26219 - /* End of text section */
26220 - _etext = .;
26221 } :text = 0x9090
26222
26223 - NOTES :text :note
26224 + . += __KERNEL_TEXT_OFFSET;
26225
26226 - EXCEPTION_TABLE(16) :text = 0x9090
26227 +#ifdef CONFIG_X86_32
26228 + . = ALIGN(PAGE_SIZE);
26229 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26230 +
26231 +#ifdef CONFIG_PAX_KERNEXEC
26232 + MODULES_EXEC_VADDR = .;
26233 + BYTE(0)
26234 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26235 + . = ALIGN(HPAGE_SIZE) - 1;
26236 + MODULES_EXEC_END = .;
26237 +#endif
26238 +
26239 + } :module
26240 +#endif
26241 +
26242 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26243 + /* End of text section */
26244 + BYTE(0)
26245 + _etext = . - __KERNEL_TEXT_OFFSET;
26246 + }
26247 +
26248 +#ifdef CONFIG_X86_32
26249 + . = ALIGN(PAGE_SIZE);
26250 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26251 + . = ALIGN(PAGE_SIZE);
26252 + *(.empty_zero_page)
26253 + *(.initial_pg_fixmap)
26254 + *(.initial_pg_pmd)
26255 + *(.initial_page_table)
26256 + *(.swapper_pg_dir)
26257 + } :rodata
26258 +#endif
26259 +
26260 + . = ALIGN(PAGE_SIZE);
26261 + NOTES :rodata :note
26262 +
26263 + EXCEPTION_TABLE(16) :rodata
26264
26265 #if defined(CONFIG_DEBUG_RODATA)
26266 /* .text should occupy whole number of pages */
26267 @@ -122,16 +176,20 @@ SECTIONS
26268
26269 /* Data */
26270 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26271 +
26272 +#ifdef CONFIG_PAX_KERNEXEC
26273 + . = ALIGN(HPAGE_SIZE);
26274 +#else
26275 + . = ALIGN(PAGE_SIZE);
26276 +#endif
26277 +
26278 /* Start of data section */
26279 _sdata = .;
26280
26281 /* init_task */
26282 INIT_TASK_DATA(THREAD_SIZE)
26283
26284 -#ifdef CONFIG_X86_32
26285 - /* 32 bit has nosave before _edata */
26286 NOSAVE_DATA
26287 -#endif
26288
26289 PAGE_ALIGNED_DATA(PAGE_SIZE)
26290
26291 @@ -172,12 +230,19 @@ SECTIONS
26292 #endif /* CONFIG_X86_64 */
26293
26294 /* Init code and data - will be freed after init */
26295 - . = ALIGN(PAGE_SIZE);
26296 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26297 + BYTE(0)
26298 +
26299 +#ifdef CONFIG_PAX_KERNEXEC
26300 + . = ALIGN(HPAGE_SIZE);
26301 +#else
26302 + . = ALIGN(PAGE_SIZE);
26303 +#endif
26304 +
26305 __init_begin = .; /* paired with __init_end */
26306 - }
26307 + } :init.begin
26308
26309 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26310 +#ifdef CONFIG_SMP
26311 /*
26312 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26313 * output PHDR, so the next output section - .init.text - should
26314 @@ -186,12 +251,27 @@ SECTIONS
26315 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26316 #endif
26317
26318 - INIT_TEXT_SECTION(PAGE_SIZE)
26319 -#ifdef CONFIG_X86_64
26320 - :init
26321 -#endif
26322 + . = ALIGN(PAGE_SIZE);
26323 + init_begin = .;
26324 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26325 + VMLINUX_SYMBOL(_sinittext) = .;
26326 + INIT_TEXT
26327 + VMLINUX_SYMBOL(_einittext) = .;
26328 + . = ALIGN(PAGE_SIZE);
26329 + } :text.init
26330
26331 - INIT_DATA_SECTION(16)
26332 + /*
26333 + * .exit.text is discard at runtime, not link time, to deal with
26334 + * references from .altinstructions and .eh_frame
26335 + */
26336 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26337 + EXIT_TEXT
26338 + . = ALIGN(16);
26339 + } :text.exit
26340 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26341 +
26342 + . = ALIGN(PAGE_SIZE);
26343 + INIT_DATA_SECTION(16) :init
26344
26345 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26346 __x86_cpu_dev_start = .;
26347 @@ -253,19 +333,12 @@ SECTIONS
26348 }
26349
26350 . = ALIGN(8);
26351 - /*
26352 - * .exit.text is discard at runtime, not link time, to deal with
26353 - * references from .altinstructions and .eh_frame
26354 - */
26355 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26356 - EXIT_TEXT
26357 - }
26358
26359 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26360 EXIT_DATA
26361 }
26362
26363 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26364 +#ifndef CONFIG_SMP
26365 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26366 #endif
26367
26368 @@ -284,16 +357,10 @@ SECTIONS
26369 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26370 __smp_locks = .;
26371 *(.smp_locks)
26372 - . = ALIGN(PAGE_SIZE);
26373 __smp_locks_end = .;
26374 + . = ALIGN(PAGE_SIZE);
26375 }
26376
26377 -#ifdef CONFIG_X86_64
26378 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26379 - NOSAVE_DATA
26380 - }
26381 -#endif
26382 -
26383 /* BSS */
26384 . = ALIGN(PAGE_SIZE);
26385 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26386 @@ -309,6 +376,7 @@ SECTIONS
26387 __brk_base = .;
26388 . += 64 * 1024; /* 64k alignment slop space */
26389 *(.brk_reservation) /* areas brk users have reserved */
26390 + . = ALIGN(HPAGE_SIZE);
26391 __brk_limit = .;
26392 }
26393
26394 @@ -335,13 +403,12 @@ SECTIONS
26395 * for the boot processor.
26396 */
26397 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26398 -INIT_PER_CPU(gdt_page);
26399 INIT_PER_CPU(irq_stack_union);
26400
26401 /*
26402 * Build-time check on the image size:
26403 */
26404 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26405 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26406 "kernel image bigger than KERNEL_IMAGE_SIZE");
26407
26408 #ifdef CONFIG_SMP
26409 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26410 index 1f96f93..d5c8f7a 100644
26411 --- a/arch/x86/kernel/vsyscall_64.c
26412 +++ b/arch/x86/kernel/vsyscall_64.c
26413 @@ -56,15 +56,13 @@
26414 DEFINE_VVAR(int, vgetcpu_mode);
26415 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26416
26417 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26418 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26419
26420 static int __init vsyscall_setup(char *str)
26421 {
26422 if (str) {
26423 if (!strcmp("emulate", str))
26424 vsyscall_mode = EMULATE;
26425 - else if (!strcmp("native", str))
26426 - vsyscall_mode = NATIVE;
26427 else if (!strcmp("none", str))
26428 vsyscall_mode = NONE;
26429 else
26430 @@ -323,8 +321,7 @@ do_ret:
26431 return true;
26432
26433 sigsegv:
26434 - force_sig(SIGSEGV, current);
26435 - return true;
26436 + do_group_exit(SIGKILL);
26437 }
26438
26439 /*
26440 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26441 extern char __vvar_page;
26442 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26443
26444 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26445 - vsyscall_mode == NATIVE
26446 - ? PAGE_KERNEL_VSYSCALL
26447 - : PAGE_KERNEL_VVAR);
26448 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26449 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26450 (unsigned long)VSYSCALL_START);
26451
26452 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26453 index b014d94..e775258 100644
26454 --- a/arch/x86/kernel/x8664_ksyms_64.c
26455 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26456 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26457 EXPORT_SYMBOL(copy_user_generic_unrolled);
26458 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26459 EXPORT_SYMBOL(__copy_user_nocache);
26460 -EXPORT_SYMBOL(_copy_from_user);
26461 -EXPORT_SYMBOL(_copy_to_user);
26462
26463 EXPORT_SYMBOL(copy_page);
26464 EXPORT_SYMBOL(clear_page);
26465 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26466 #ifndef CONFIG_PARAVIRT
26467 EXPORT_SYMBOL(native_load_gs_index);
26468 #endif
26469 +
26470 +#ifdef CONFIG_PAX_PER_CPU_PGD
26471 +EXPORT_SYMBOL(cpu_pgd);
26472 +#endif
26473 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26474 index 8ce0072..431a0e7 100644
26475 --- a/arch/x86/kernel/x86_init.c
26476 +++ b/arch/x86/kernel/x86_init.c
26477 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26478 static void default_nmi_init(void) { };
26479 static int default_i8042_detect(void) { return 1; };
26480
26481 -struct x86_platform_ops x86_platform = {
26482 +struct x86_platform_ops x86_platform __read_only = {
26483 .calibrate_tsc = native_calibrate_tsc,
26484 .get_wallclock = mach_get_cmos_time,
26485 .set_wallclock = mach_set_rtc_mmss,
26486 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
26487 EXPORT_SYMBOL_GPL(x86_platform);
26488
26489 #if defined(CONFIG_PCI_MSI)
26490 -struct x86_msi_ops x86_msi = {
26491 +struct x86_msi_ops x86_msi __read_only = {
26492 .setup_msi_irqs = native_setup_msi_irqs,
26493 .compose_msi_msg = native_compose_msi_msg,
26494 .teardown_msi_irq = native_teardown_msi_irq,
26495 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
26496 }
26497 #endif
26498
26499 -struct x86_io_apic_ops x86_io_apic_ops = {
26500 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26501 .init = native_io_apic_init_mappings,
26502 .read = native_io_apic_read,
26503 .write = native_io_apic_write,
26504 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26505 index 422fd82..c3687ca 100644
26506 --- a/arch/x86/kernel/xsave.c
26507 +++ b/arch/x86/kernel/xsave.c
26508 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26509 {
26510 int err;
26511
26512 + buf = (struct xsave_struct __user *)____m(buf);
26513 if (use_xsave())
26514 err = xsave_user(buf);
26515 else if (use_fxsr())
26516 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26517 */
26518 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26519 {
26520 + buf = (void __user *)____m(buf);
26521 if (use_xsave()) {
26522 if ((unsigned long)buf % 64 || fx_only) {
26523 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26524 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26525 index b110fe6..d9c19f2 100644
26526 --- a/arch/x86/kvm/cpuid.c
26527 +++ b/arch/x86/kvm/cpuid.c
26528 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26529 struct kvm_cpuid2 *cpuid,
26530 struct kvm_cpuid_entry2 __user *entries)
26531 {
26532 - int r;
26533 + int r, i;
26534
26535 r = -E2BIG;
26536 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26537 goto out;
26538 r = -EFAULT;
26539 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26540 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26541 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26542 goto out;
26543 + for (i = 0; i < cpuid->nent; ++i) {
26544 + struct kvm_cpuid_entry2 cpuid_entry;
26545 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26546 + goto out;
26547 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26548 + }
26549 vcpu->arch.cpuid_nent = cpuid->nent;
26550 kvm_apic_set_version(vcpu);
26551 kvm_x86_ops->cpuid_update(vcpu);
26552 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26553 struct kvm_cpuid2 *cpuid,
26554 struct kvm_cpuid_entry2 __user *entries)
26555 {
26556 - int r;
26557 + int r, i;
26558
26559 r = -E2BIG;
26560 if (cpuid->nent < vcpu->arch.cpuid_nent)
26561 goto out;
26562 r = -EFAULT;
26563 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26564 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26565 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26566 goto out;
26567 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26568 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26569 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26570 + goto out;
26571 + }
26572 return 0;
26573
26574 out:
26575 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26576 index 5439117..d08f3d4 100644
26577 --- a/arch/x86/kvm/lapic.c
26578 +++ b/arch/x86/kvm/lapic.c
26579 @@ -55,7 +55,7 @@
26580 #define APIC_BUS_CYCLE_NS 1
26581
26582 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26583 -#define apic_debug(fmt, arg...)
26584 +#define apic_debug(fmt, arg...) do {} while (0)
26585
26586 #define APIC_LVT_NUM 6
26587 /* 14 is the version for Xeon and Pentium 8.4.8*/
26588 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26589 index ad75d77..a679d32 100644
26590 --- a/arch/x86/kvm/paging_tmpl.h
26591 +++ b/arch/x86/kvm/paging_tmpl.h
26592 @@ -331,7 +331,7 @@ retry_walk:
26593 if (unlikely(kvm_is_error_hva(host_addr)))
26594 goto error;
26595
26596 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26597 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26598 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26599 goto error;
26600 walker->ptep_user[walker->level - 1] = ptep_user;
26601 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26602 index c0bc803..6837a50 100644
26603 --- a/arch/x86/kvm/svm.c
26604 +++ b/arch/x86/kvm/svm.c
26605 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26606 int cpu = raw_smp_processor_id();
26607
26608 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26609 +
26610 + pax_open_kernel();
26611 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26612 + pax_close_kernel();
26613 +
26614 load_TR_desc();
26615 }
26616
26617 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26618 #endif
26619 #endif
26620
26621 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26622 + __set_fs(current_thread_info()->addr_limit);
26623 +#endif
26624 +
26625 reload_tss(vcpu);
26626
26627 local_irq_disable();
26628 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26629 index 2b2fce1..da76be4 100644
26630 --- a/arch/x86/kvm/vmx.c
26631 +++ b/arch/x86/kvm/vmx.c
26632 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26633 #endif
26634 }
26635
26636 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26637 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26638 {
26639 vmcs_writel(field, vmcs_readl(field) & ~mask);
26640 }
26641
26642 -static void vmcs_set_bits(unsigned long field, u32 mask)
26643 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26644 {
26645 vmcs_writel(field, vmcs_readl(field) | mask);
26646 }
26647 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
26648 struct desc_struct *descs;
26649
26650 descs = (void *)gdt->address;
26651 +
26652 + pax_open_kernel();
26653 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26654 + pax_close_kernel();
26655 +
26656 load_TR_desc();
26657 }
26658
26659 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26660 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26661 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26662
26663 +#ifdef CONFIG_PAX_PER_CPU_PGD
26664 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26665 +#endif
26666 +
26667 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26668 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26669 vmx->loaded_vmcs->cpu = cpu;
26670 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
26671 * reads and returns guest's timestamp counter "register"
26672 * guest_tsc = host_tsc + tsc_offset -- 21.3
26673 */
26674 -static u64 guest_read_tsc(void)
26675 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
26676 {
26677 u64 host_tsc, tsc_offset;
26678
26679 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
26680 if (!cpu_has_vmx_flexpriority())
26681 flexpriority_enabled = 0;
26682
26683 - if (!cpu_has_vmx_tpr_shadow())
26684 - kvm_x86_ops->update_cr8_intercept = NULL;
26685 + if (!cpu_has_vmx_tpr_shadow()) {
26686 + pax_open_kernel();
26687 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26688 + pax_close_kernel();
26689 + }
26690
26691 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26692 kvm_disable_largepages();
26693 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
26694 if (!cpu_has_vmx_apicv())
26695 enable_apicv = 0;
26696
26697 + pax_open_kernel();
26698 if (enable_apicv)
26699 - kvm_x86_ops->update_cr8_intercept = NULL;
26700 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26701 else {
26702 - kvm_x86_ops->hwapic_irr_update = NULL;
26703 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26704 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26705 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26706 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26707 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26708 }
26709 + pax_close_kernel();
26710
26711 if (nested)
26712 nested_vmx_setup_ctls_msrs();
26713 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26714
26715 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26716 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26717 +
26718 +#ifndef CONFIG_PAX_PER_CPU_PGD
26719 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26720 +#endif
26721
26722 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26723 #ifdef CONFIG_X86_64
26724 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26725 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26726 vmx->host_idt_base = dt.address;
26727
26728 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26729 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26730
26731 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26732 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26733 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26734 "jmp 2f \n\t"
26735 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26736 "2: "
26737 +
26738 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26739 + "ljmp %[cs],$3f\n\t"
26740 + "3: "
26741 +#endif
26742 +
26743 /* Save guest registers, load host registers, keep flags */
26744 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26745 "pop %0 \n\t"
26746 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26747 #endif
26748 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26749 [wordsize]"i"(sizeof(ulong))
26750 +
26751 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26752 + ,[cs]"i"(__KERNEL_CS)
26753 +#endif
26754 +
26755 : "cc", "memory"
26756 #ifdef CONFIG_X86_64
26757 , "rax", "rbx", "rdi", "rsi"
26758 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26759 if (debugctlmsr)
26760 update_debugctlmsr(debugctlmsr);
26761
26762 -#ifndef CONFIG_X86_64
26763 +#ifdef CONFIG_X86_32
26764 /*
26765 * The sysexit path does not restore ds/es, so we must set them to
26766 * a reasonable value ourselves.
26767 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26768 * may be executed in interrupt context, which saves and restore segments
26769 * around it, nullifying its effect.
26770 */
26771 - loadsegment(ds, __USER_DS);
26772 - loadsegment(es, __USER_DS);
26773 + loadsegment(ds, __KERNEL_DS);
26774 + loadsegment(es, __KERNEL_DS);
26775 + loadsegment(ss, __KERNEL_DS);
26776 +
26777 +#ifdef CONFIG_PAX_KERNEXEC
26778 + loadsegment(fs, __KERNEL_PERCPU);
26779 +#endif
26780 +
26781 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26782 + __set_fs(current_thread_info()->addr_limit);
26783 +#endif
26784 +
26785 #endif
26786
26787 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26788 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26789 index e5ca72a..83d5177 100644
26790 --- a/arch/x86/kvm/x86.c
26791 +++ b/arch/x86/kvm/x86.c
26792 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26793 {
26794 struct kvm *kvm = vcpu->kvm;
26795 int lm = is_long_mode(vcpu);
26796 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26797 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26798 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26799 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26800 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26801 : kvm->arch.xen_hvm_config.blob_size_32;
26802 u32 page_num = data & ~PAGE_MASK;
26803 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26804 if (n < msr_list.nmsrs)
26805 goto out;
26806 r = -EFAULT;
26807 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26808 + goto out;
26809 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26810 num_msrs_to_save * sizeof(u32)))
26811 goto out;
26812 @@ -5462,7 +5464,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26813 };
26814 #endif
26815
26816 -int kvm_arch_init(void *opaque)
26817 +int kvm_arch_init(const void *opaque)
26818 {
26819 int r;
26820 struct kvm_x86_ops *ops = opaque;
26821 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26822 index bdf8532..f63c587 100644
26823 --- a/arch/x86/lguest/boot.c
26824 +++ b/arch/x86/lguest/boot.c
26825 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26826 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26827 * Launcher to reboot us.
26828 */
26829 -static void lguest_restart(char *reason)
26830 +static __noreturn void lguest_restart(char *reason)
26831 {
26832 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26833 + BUG();
26834 }
26835
26836 /*G:050
26837 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26838 index 00933d5..3a64af9 100644
26839 --- a/arch/x86/lib/atomic64_386_32.S
26840 +++ b/arch/x86/lib/atomic64_386_32.S
26841 @@ -48,6 +48,10 @@ BEGIN(read)
26842 movl (v), %eax
26843 movl 4(v), %edx
26844 RET_ENDP
26845 +BEGIN(read_unchecked)
26846 + movl (v), %eax
26847 + movl 4(v), %edx
26848 +RET_ENDP
26849 #undef v
26850
26851 #define v %esi
26852 @@ -55,6 +59,10 @@ BEGIN(set)
26853 movl %ebx, (v)
26854 movl %ecx, 4(v)
26855 RET_ENDP
26856 +BEGIN(set_unchecked)
26857 + movl %ebx, (v)
26858 + movl %ecx, 4(v)
26859 +RET_ENDP
26860 #undef v
26861
26862 #define v %esi
26863 @@ -70,6 +78,20 @@ RET_ENDP
26864 BEGIN(add)
26865 addl %eax, (v)
26866 adcl %edx, 4(v)
26867 +
26868 +#ifdef CONFIG_PAX_REFCOUNT
26869 + jno 0f
26870 + subl %eax, (v)
26871 + sbbl %edx, 4(v)
26872 + int $4
26873 +0:
26874 + _ASM_EXTABLE(0b, 0b)
26875 +#endif
26876 +
26877 +RET_ENDP
26878 +BEGIN(add_unchecked)
26879 + addl %eax, (v)
26880 + adcl %edx, 4(v)
26881 RET_ENDP
26882 #undef v
26883
26884 @@ -77,6 +99,24 @@ RET_ENDP
26885 BEGIN(add_return)
26886 addl (v), %eax
26887 adcl 4(v), %edx
26888 +
26889 +#ifdef CONFIG_PAX_REFCOUNT
26890 + into
26891 +1234:
26892 + _ASM_EXTABLE(1234b, 2f)
26893 +#endif
26894 +
26895 + movl %eax, (v)
26896 + movl %edx, 4(v)
26897 +
26898 +#ifdef CONFIG_PAX_REFCOUNT
26899 +2:
26900 +#endif
26901 +
26902 +RET_ENDP
26903 +BEGIN(add_return_unchecked)
26904 + addl (v), %eax
26905 + adcl 4(v), %edx
26906 movl %eax, (v)
26907 movl %edx, 4(v)
26908 RET_ENDP
26909 @@ -86,6 +126,20 @@ RET_ENDP
26910 BEGIN(sub)
26911 subl %eax, (v)
26912 sbbl %edx, 4(v)
26913 +
26914 +#ifdef CONFIG_PAX_REFCOUNT
26915 + jno 0f
26916 + addl %eax, (v)
26917 + adcl %edx, 4(v)
26918 + int $4
26919 +0:
26920 + _ASM_EXTABLE(0b, 0b)
26921 +#endif
26922 +
26923 +RET_ENDP
26924 +BEGIN(sub_unchecked)
26925 + subl %eax, (v)
26926 + sbbl %edx, 4(v)
26927 RET_ENDP
26928 #undef v
26929
26930 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26931 sbbl $0, %edx
26932 addl (v), %eax
26933 adcl 4(v), %edx
26934 +
26935 +#ifdef CONFIG_PAX_REFCOUNT
26936 + into
26937 +1234:
26938 + _ASM_EXTABLE(1234b, 2f)
26939 +#endif
26940 +
26941 + movl %eax, (v)
26942 + movl %edx, 4(v)
26943 +
26944 +#ifdef CONFIG_PAX_REFCOUNT
26945 +2:
26946 +#endif
26947 +
26948 +RET_ENDP
26949 +BEGIN(sub_return_unchecked)
26950 + negl %edx
26951 + negl %eax
26952 + sbbl $0, %edx
26953 + addl (v), %eax
26954 + adcl 4(v), %edx
26955 movl %eax, (v)
26956 movl %edx, 4(v)
26957 RET_ENDP
26958 @@ -105,6 +180,20 @@ RET_ENDP
26959 BEGIN(inc)
26960 addl $1, (v)
26961 adcl $0, 4(v)
26962 +
26963 +#ifdef CONFIG_PAX_REFCOUNT
26964 + jno 0f
26965 + subl $1, (v)
26966 + sbbl $0, 4(v)
26967 + int $4
26968 +0:
26969 + _ASM_EXTABLE(0b, 0b)
26970 +#endif
26971 +
26972 +RET_ENDP
26973 +BEGIN(inc_unchecked)
26974 + addl $1, (v)
26975 + adcl $0, 4(v)
26976 RET_ENDP
26977 #undef v
26978
26979 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26980 movl 4(v), %edx
26981 addl $1, %eax
26982 adcl $0, %edx
26983 +
26984 +#ifdef CONFIG_PAX_REFCOUNT
26985 + into
26986 +1234:
26987 + _ASM_EXTABLE(1234b, 2f)
26988 +#endif
26989 +
26990 + movl %eax, (v)
26991 + movl %edx, 4(v)
26992 +
26993 +#ifdef CONFIG_PAX_REFCOUNT
26994 +2:
26995 +#endif
26996 +
26997 +RET_ENDP
26998 +BEGIN(inc_return_unchecked)
26999 + movl (v), %eax
27000 + movl 4(v), %edx
27001 + addl $1, %eax
27002 + adcl $0, %edx
27003 movl %eax, (v)
27004 movl %edx, 4(v)
27005 RET_ENDP
27006 @@ -123,6 +232,20 @@ RET_ENDP
27007 BEGIN(dec)
27008 subl $1, (v)
27009 sbbl $0, 4(v)
27010 +
27011 +#ifdef CONFIG_PAX_REFCOUNT
27012 + jno 0f
27013 + addl $1, (v)
27014 + adcl $0, 4(v)
27015 + int $4
27016 +0:
27017 + _ASM_EXTABLE(0b, 0b)
27018 +#endif
27019 +
27020 +RET_ENDP
27021 +BEGIN(dec_unchecked)
27022 + subl $1, (v)
27023 + sbbl $0, 4(v)
27024 RET_ENDP
27025 #undef v
27026
27027 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27028 movl 4(v), %edx
27029 subl $1, %eax
27030 sbbl $0, %edx
27031 +
27032 +#ifdef CONFIG_PAX_REFCOUNT
27033 + into
27034 +1234:
27035 + _ASM_EXTABLE(1234b, 2f)
27036 +#endif
27037 +
27038 + movl %eax, (v)
27039 + movl %edx, 4(v)
27040 +
27041 +#ifdef CONFIG_PAX_REFCOUNT
27042 +2:
27043 +#endif
27044 +
27045 +RET_ENDP
27046 +BEGIN(dec_return_unchecked)
27047 + movl (v), %eax
27048 + movl 4(v), %edx
27049 + subl $1, %eax
27050 + sbbl $0, %edx
27051 movl %eax, (v)
27052 movl %edx, 4(v)
27053 RET_ENDP
27054 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27055 adcl %edx, %edi
27056 addl (v), %eax
27057 adcl 4(v), %edx
27058 +
27059 +#ifdef CONFIG_PAX_REFCOUNT
27060 + into
27061 +1234:
27062 + _ASM_EXTABLE(1234b, 2f)
27063 +#endif
27064 +
27065 cmpl %eax, %ecx
27066 je 3f
27067 1:
27068 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27069 1:
27070 addl $1, %eax
27071 adcl $0, %edx
27072 +
27073 +#ifdef CONFIG_PAX_REFCOUNT
27074 + into
27075 +1234:
27076 + _ASM_EXTABLE(1234b, 2f)
27077 +#endif
27078 +
27079 movl %eax, (v)
27080 movl %edx, 4(v)
27081 movl $1, %eax
27082 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27083 movl 4(v), %edx
27084 subl $1, %eax
27085 sbbl $0, %edx
27086 +
27087 +#ifdef CONFIG_PAX_REFCOUNT
27088 + into
27089 +1234:
27090 + _ASM_EXTABLE(1234b, 1f)
27091 +#endif
27092 +
27093 js 1f
27094 movl %eax, (v)
27095 movl %edx, 4(v)
27096 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27097 index f5cc9eb..51fa319 100644
27098 --- a/arch/x86/lib/atomic64_cx8_32.S
27099 +++ b/arch/x86/lib/atomic64_cx8_32.S
27100 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27101 CFI_STARTPROC
27102
27103 read64 %ecx
27104 + pax_force_retaddr
27105 ret
27106 CFI_ENDPROC
27107 ENDPROC(atomic64_read_cx8)
27108
27109 +ENTRY(atomic64_read_unchecked_cx8)
27110 + CFI_STARTPROC
27111 +
27112 + read64 %ecx
27113 + pax_force_retaddr
27114 + ret
27115 + CFI_ENDPROC
27116 +ENDPROC(atomic64_read_unchecked_cx8)
27117 +
27118 ENTRY(atomic64_set_cx8)
27119 CFI_STARTPROC
27120
27121 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27122 cmpxchg8b (%esi)
27123 jne 1b
27124
27125 + pax_force_retaddr
27126 ret
27127 CFI_ENDPROC
27128 ENDPROC(atomic64_set_cx8)
27129
27130 +ENTRY(atomic64_set_unchecked_cx8)
27131 + CFI_STARTPROC
27132 +
27133 +1:
27134 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27135 + * are atomic on 586 and newer */
27136 + cmpxchg8b (%esi)
27137 + jne 1b
27138 +
27139 + pax_force_retaddr
27140 + ret
27141 + CFI_ENDPROC
27142 +ENDPROC(atomic64_set_unchecked_cx8)
27143 +
27144 ENTRY(atomic64_xchg_cx8)
27145 CFI_STARTPROC
27146
27147 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27148 cmpxchg8b (%esi)
27149 jne 1b
27150
27151 + pax_force_retaddr
27152 ret
27153 CFI_ENDPROC
27154 ENDPROC(atomic64_xchg_cx8)
27155
27156 -.macro addsub_return func ins insc
27157 -ENTRY(atomic64_\func\()_return_cx8)
27158 +.macro addsub_return func ins insc unchecked=""
27159 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27160 CFI_STARTPROC
27161 SAVE ebp
27162 SAVE ebx
27163 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27164 movl %edx, %ecx
27165 \ins\()l %esi, %ebx
27166 \insc\()l %edi, %ecx
27167 +
27168 +.ifb \unchecked
27169 +#ifdef CONFIG_PAX_REFCOUNT
27170 + into
27171 +2:
27172 + _ASM_EXTABLE(2b, 3f)
27173 +#endif
27174 +.endif
27175 +
27176 LOCK_PREFIX
27177 cmpxchg8b (%ebp)
27178 jne 1b
27179 -
27180 -10:
27181 movl %ebx, %eax
27182 movl %ecx, %edx
27183 +
27184 +.ifb \unchecked
27185 +#ifdef CONFIG_PAX_REFCOUNT
27186 +3:
27187 +#endif
27188 +.endif
27189 +
27190 RESTORE edi
27191 RESTORE esi
27192 RESTORE ebx
27193 RESTORE ebp
27194 + pax_force_retaddr
27195 ret
27196 CFI_ENDPROC
27197 -ENDPROC(atomic64_\func\()_return_cx8)
27198 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27199 .endm
27200
27201 addsub_return add add adc
27202 addsub_return sub sub sbb
27203 +addsub_return add add adc _unchecked
27204 +addsub_return sub sub sbb _unchecked
27205
27206 -.macro incdec_return func ins insc
27207 -ENTRY(atomic64_\func\()_return_cx8)
27208 +.macro incdec_return func ins insc unchecked=""
27209 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27210 CFI_STARTPROC
27211 SAVE ebx
27212
27213 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27214 movl %edx, %ecx
27215 \ins\()l $1, %ebx
27216 \insc\()l $0, %ecx
27217 +
27218 +.ifb \unchecked
27219 +#ifdef CONFIG_PAX_REFCOUNT
27220 + into
27221 +2:
27222 + _ASM_EXTABLE(2b, 3f)
27223 +#endif
27224 +.endif
27225 +
27226 LOCK_PREFIX
27227 cmpxchg8b (%esi)
27228 jne 1b
27229
27230 -10:
27231 movl %ebx, %eax
27232 movl %ecx, %edx
27233 +
27234 +.ifb \unchecked
27235 +#ifdef CONFIG_PAX_REFCOUNT
27236 +3:
27237 +#endif
27238 +.endif
27239 +
27240 RESTORE ebx
27241 + pax_force_retaddr
27242 ret
27243 CFI_ENDPROC
27244 -ENDPROC(atomic64_\func\()_return_cx8)
27245 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27246 .endm
27247
27248 incdec_return inc add adc
27249 incdec_return dec sub sbb
27250 +incdec_return inc add adc _unchecked
27251 +incdec_return dec sub sbb _unchecked
27252
27253 ENTRY(atomic64_dec_if_positive_cx8)
27254 CFI_STARTPROC
27255 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27256 movl %edx, %ecx
27257 subl $1, %ebx
27258 sbb $0, %ecx
27259 +
27260 +#ifdef CONFIG_PAX_REFCOUNT
27261 + into
27262 +1234:
27263 + _ASM_EXTABLE(1234b, 2f)
27264 +#endif
27265 +
27266 js 2f
27267 LOCK_PREFIX
27268 cmpxchg8b (%esi)
27269 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27270 movl %ebx, %eax
27271 movl %ecx, %edx
27272 RESTORE ebx
27273 + pax_force_retaddr
27274 ret
27275 CFI_ENDPROC
27276 ENDPROC(atomic64_dec_if_positive_cx8)
27277 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27278 movl %edx, %ecx
27279 addl %ebp, %ebx
27280 adcl %edi, %ecx
27281 +
27282 +#ifdef CONFIG_PAX_REFCOUNT
27283 + into
27284 +1234:
27285 + _ASM_EXTABLE(1234b, 3f)
27286 +#endif
27287 +
27288 LOCK_PREFIX
27289 cmpxchg8b (%esi)
27290 jne 1b
27291 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27292 CFI_ADJUST_CFA_OFFSET -8
27293 RESTORE ebx
27294 RESTORE ebp
27295 + pax_force_retaddr
27296 ret
27297 4:
27298 cmpl %edx, 4(%esp)
27299 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27300 xorl %ecx, %ecx
27301 addl $1, %ebx
27302 adcl %edx, %ecx
27303 +
27304 +#ifdef CONFIG_PAX_REFCOUNT
27305 + into
27306 +1234:
27307 + _ASM_EXTABLE(1234b, 3f)
27308 +#endif
27309 +
27310 LOCK_PREFIX
27311 cmpxchg8b (%esi)
27312 jne 1b
27313 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27314 movl $1, %eax
27315 3:
27316 RESTORE ebx
27317 + pax_force_retaddr
27318 ret
27319 CFI_ENDPROC
27320 ENDPROC(atomic64_inc_not_zero_cx8)
27321 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27322 index e78b8ee..7e173a8 100644
27323 --- a/arch/x86/lib/checksum_32.S
27324 +++ b/arch/x86/lib/checksum_32.S
27325 @@ -29,7 +29,8 @@
27326 #include <asm/dwarf2.h>
27327 #include <asm/errno.h>
27328 #include <asm/asm.h>
27329 -
27330 +#include <asm/segment.h>
27331 +
27332 /*
27333 * computes a partial checksum, e.g. for TCP/UDP fragments
27334 */
27335 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27336
27337 #define ARGBASE 16
27338 #define FP 12
27339 -
27340 -ENTRY(csum_partial_copy_generic)
27341 +
27342 +ENTRY(csum_partial_copy_generic_to_user)
27343 CFI_STARTPROC
27344 +
27345 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27346 + pushl_cfi %gs
27347 + popl_cfi %es
27348 + jmp csum_partial_copy_generic
27349 +#endif
27350 +
27351 +ENTRY(csum_partial_copy_generic_from_user)
27352 +
27353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27354 + pushl_cfi %gs
27355 + popl_cfi %ds
27356 +#endif
27357 +
27358 +ENTRY(csum_partial_copy_generic)
27359 subl $4,%esp
27360 CFI_ADJUST_CFA_OFFSET 4
27361 pushl_cfi %edi
27362 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27363 jmp 4f
27364 SRC(1: movw (%esi), %bx )
27365 addl $2, %esi
27366 -DST( movw %bx, (%edi) )
27367 +DST( movw %bx, %es:(%edi) )
27368 addl $2, %edi
27369 addw %bx, %ax
27370 adcl $0, %eax
27371 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27372 SRC(1: movl (%esi), %ebx )
27373 SRC( movl 4(%esi), %edx )
27374 adcl %ebx, %eax
27375 -DST( movl %ebx, (%edi) )
27376 +DST( movl %ebx, %es:(%edi) )
27377 adcl %edx, %eax
27378 -DST( movl %edx, 4(%edi) )
27379 +DST( movl %edx, %es:4(%edi) )
27380
27381 SRC( movl 8(%esi), %ebx )
27382 SRC( movl 12(%esi), %edx )
27383 adcl %ebx, %eax
27384 -DST( movl %ebx, 8(%edi) )
27385 +DST( movl %ebx, %es:8(%edi) )
27386 adcl %edx, %eax
27387 -DST( movl %edx, 12(%edi) )
27388 +DST( movl %edx, %es:12(%edi) )
27389
27390 SRC( movl 16(%esi), %ebx )
27391 SRC( movl 20(%esi), %edx )
27392 adcl %ebx, %eax
27393 -DST( movl %ebx, 16(%edi) )
27394 +DST( movl %ebx, %es:16(%edi) )
27395 adcl %edx, %eax
27396 -DST( movl %edx, 20(%edi) )
27397 +DST( movl %edx, %es:20(%edi) )
27398
27399 SRC( movl 24(%esi), %ebx )
27400 SRC( movl 28(%esi), %edx )
27401 adcl %ebx, %eax
27402 -DST( movl %ebx, 24(%edi) )
27403 +DST( movl %ebx, %es:24(%edi) )
27404 adcl %edx, %eax
27405 -DST( movl %edx, 28(%edi) )
27406 +DST( movl %edx, %es:28(%edi) )
27407
27408 lea 32(%esi), %esi
27409 lea 32(%edi), %edi
27410 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27411 shrl $2, %edx # This clears CF
27412 SRC(3: movl (%esi), %ebx )
27413 adcl %ebx, %eax
27414 -DST( movl %ebx, (%edi) )
27415 +DST( movl %ebx, %es:(%edi) )
27416 lea 4(%esi), %esi
27417 lea 4(%edi), %edi
27418 dec %edx
27419 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27420 jb 5f
27421 SRC( movw (%esi), %cx )
27422 leal 2(%esi), %esi
27423 -DST( movw %cx, (%edi) )
27424 +DST( movw %cx, %es:(%edi) )
27425 leal 2(%edi), %edi
27426 je 6f
27427 shll $16,%ecx
27428 SRC(5: movb (%esi), %cl )
27429 -DST( movb %cl, (%edi) )
27430 +DST( movb %cl, %es:(%edi) )
27431 6: addl %ecx, %eax
27432 adcl $0, %eax
27433 7:
27434 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27435
27436 6001:
27437 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27438 - movl $-EFAULT, (%ebx)
27439 + movl $-EFAULT, %ss:(%ebx)
27440
27441 # zero the complete destination - computing the rest
27442 # is too much work
27443 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27444
27445 6002:
27446 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27447 - movl $-EFAULT,(%ebx)
27448 + movl $-EFAULT,%ss:(%ebx)
27449 jmp 5000b
27450
27451 .previous
27452
27453 + pushl_cfi %ss
27454 + popl_cfi %ds
27455 + pushl_cfi %ss
27456 + popl_cfi %es
27457 popl_cfi %ebx
27458 CFI_RESTORE ebx
27459 popl_cfi %esi
27460 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27461 popl_cfi %ecx # equivalent to addl $4,%esp
27462 ret
27463 CFI_ENDPROC
27464 -ENDPROC(csum_partial_copy_generic)
27465 +ENDPROC(csum_partial_copy_generic_to_user)
27466
27467 #else
27468
27469 /* Version for PentiumII/PPro */
27470
27471 #define ROUND1(x) \
27472 + nop; nop; nop; \
27473 SRC(movl x(%esi), %ebx ) ; \
27474 addl %ebx, %eax ; \
27475 - DST(movl %ebx, x(%edi) ) ;
27476 + DST(movl %ebx, %es:x(%edi)) ;
27477
27478 #define ROUND(x) \
27479 + nop; nop; nop; \
27480 SRC(movl x(%esi), %ebx ) ; \
27481 adcl %ebx, %eax ; \
27482 - DST(movl %ebx, x(%edi) ) ;
27483 + DST(movl %ebx, %es:x(%edi)) ;
27484
27485 #define ARGBASE 12
27486 -
27487 -ENTRY(csum_partial_copy_generic)
27488 +
27489 +ENTRY(csum_partial_copy_generic_to_user)
27490 CFI_STARTPROC
27491 +
27492 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27493 + pushl_cfi %gs
27494 + popl_cfi %es
27495 + jmp csum_partial_copy_generic
27496 +#endif
27497 +
27498 +ENTRY(csum_partial_copy_generic_from_user)
27499 +
27500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27501 + pushl_cfi %gs
27502 + popl_cfi %ds
27503 +#endif
27504 +
27505 +ENTRY(csum_partial_copy_generic)
27506 pushl_cfi %ebx
27507 CFI_REL_OFFSET ebx, 0
27508 pushl_cfi %edi
27509 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27510 subl %ebx, %edi
27511 lea -1(%esi),%edx
27512 andl $-32,%edx
27513 - lea 3f(%ebx,%ebx), %ebx
27514 + lea 3f(%ebx,%ebx,2), %ebx
27515 testl %esi, %esi
27516 jmp *%ebx
27517 1: addl $64,%esi
27518 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27519 jb 5f
27520 SRC( movw (%esi), %dx )
27521 leal 2(%esi), %esi
27522 -DST( movw %dx, (%edi) )
27523 +DST( movw %dx, %es:(%edi) )
27524 leal 2(%edi), %edi
27525 je 6f
27526 shll $16,%edx
27527 5:
27528 SRC( movb (%esi), %dl )
27529 -DST( movb %dl, (%edi) )
27530 +DST( movb %dl, %es:(%edi) )
27531 6: addl %edx, %eax
27532 adcl $0, %eax
27533 7:
27534 .section .fixup, "ax"
27535 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27536 - movl $-EFAULT, (%ebx)
27537 + movl $-EFAULT, %ss:(%ebx)
27538 # zero the complete destination (computing the rest is too much work)
27539 movl ARGBASE+8(%esp),%edi # dst
27540 movl ARGBASE+12(%esp),%ecx # len
27541 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27542 rep; stosb
27543 jmp 7b
27544 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27545 - movl $-EFAULT, (%ebx)
27546 + movl $-EFAULT, %ss:(%ebx)
27547 jmp 7b
27548 .previous
27549
27550 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27551 + pushl_cfi %ss
27552 + popl_cfi %ds
27553 + pushl_cfi %ss
27554 + popl_cfi %es
27555 +#endif
27556 +
27557 popl_cfi %esi
27558 CFI_RESTORE esi
27559 popl_cfi %edi
27560 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27561 CFI_RESTORE ebx
27562 ret
27563 CFI_ENDPROC
27564 -ENDPROC(csum_partial_copy_generic)
27565 +ENDPROC(csum_partial_copy_generic_to_user)
27566
27567 #undef ROUND
27568 #undef ROUND1
27569 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27570 index f2145cf..cea889d 100644
27571 --- a/arch/x86/lib/clear_page_64.S
27572 +++ b/arch/x86/lib/clear_page_64.S
27573 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27574 movl $4096/8,%ecx
27575 xorl %eax,%eax
27576 rep stosq
27577 + pax_force_retaddr
27578 ret
27579 CFI_ENDPROC
27580 ENDPROC(clear_page_c)
27581 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27582 movl $4096,%ecx
27583 xorl %eax,%eax
27584 rep stosb
27585 + pax_force_retaddr
27586 ret
27587 CFI_ENDPROC
27588 ENDPROC(clear_page_c_e)
27589 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27590 leaq 64(%rdi),%rdi
27591 jnz .Lloop
27592 nop
27593 + pax_force_retaddr
27594 ret
27595 CFI_ENDPROC
27596 .Lclear_page_end:
27597 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27598
27599 #include <asm/cpufeature.h>
27600
27601 - .section .altinstr_replacement,"ax"
27602 + .section .altinstr_replacement,"a"
27603 1: .byte 0xeb /* jmp <disp8> */
27604 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27605 2: .byte 0xeb /* jmp <disp8> */
27606 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27607 index 1e572c5..2a162cd 100644
27608 --- a/arch/x86/lib/cmpxchg16b_emu.S
27609 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27610 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27611
27612 popf
27613 mov $1, %al
27614 + pax_force_retaddr
27615 ret
27616
27617 not_same:
27618 popf
27619 xor %al,%al
27620 + pax_force_retaddr
27621 ret
27622
27623 CFI_ENDPROC
27624 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27625 index 176cca6..1166c50 100644
27626 --- a/arch/x86/lib/copy_page_64.S
27627 +++ b/arch/x86/lib/copy_page_64.S
27628 @@ -9,6 +9,7 @@ copy_page_rep:
27629 CFI_STARTPROC
27630 movl $4096/8, %ecx
27631 rep movsq
27632 + pax_force_retaddr
27633 ret
27634 CFI_ENDPROC
27635 ENDPROC(copy_page_rep)
27636 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27637
27638 ENTRY(copy_page)
27639 CFI_STARTPROC
27640 - subq $2*8, %rsp
27641 - CFI_ADJUST_CFA_OFFSET 2*8
27642 + subq $3*8, %rsp
27643 + CFI_ADJUST_CFA_OFFSET 3*8
27644 movq %rbx, (%rsp)
27645 CFI_REL_OFFSET rbx, 0
27646 movq %r12, 1*8(%rsp)
27647 CFI_REL_OFFSET r12, 1*8
27648 + movq %r13, 2*8(%rsp)
27649 + CFI_REL_OFFSET r13, 2*8
27650
27651 movl $(4096/64)-5, %ecx
27652 .p2align 4
27653 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27654 movq 0x8*2(%rsi), %rdx
27655 movq 0x8*3(%rsi), %r8
27656 movq 0x8*4(%rsi), %r9
27657 - movq 0x8*5(%rsi), %r10
27658 + movq 0x8*5(%rsi), %r13
27659 movq 0x8*6(%rsi), %r11
27660 movq 0x8*7(%rsi), %r12
27661
27662 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27663 movq %rdx, 0x8*2(%rdi)
27664 movq %r8, 0x8*3(%rdi)
27665 movq %r9, 0x8*4(%rdi)
27666 - movq %r10, 0x8*5(%rdi)
27667 + movq %r13, 0x8*5(%rdi)
27668 movq %r11, 0x8*6(%rdi)
27669 movq %r12, 0x8*7(%rdi)
27670
27671 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27672 movq 0x8*2(%rsi), %rdx
27673 movq 0x8*3(%rsi), %r8
27674 movq 0x8*4(%rsi), %r9
27675 - movq 0x8*5(%rsi), %r10
27676 + movq 0x8*5(%rsi), %r13
27677 movq 0x8*6(%rsi), %r11
27678 movq 0x8*7(%rsi), %r12
27679
27680 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27681 movq %rdx, 0x8*2(%rdi)
27682 movq %r8, 0x8*3(%rdi)
27683 movq %r9, 0x8*4(%rdi)
27684 - movq %r10, 0x8*5(%rdi)
27685 + movq %r13, 0x8*5(%rdi)
27686 movq %r11, 0x8*6(%rdi)
27687 movq %r12, 0x8*7(%rdi)
27688
27689 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27690 CFI_RESTORE rbx
27691 movq 1*8(%rsp), %r12
27692 CFI_RESTORE r12
27693 - addq $2*8, %rsp
27694 - CFI_ADJUST_CFA_OFFSET -2*8
27695 + movq 2*8(%rsp), %r13
27696 + CFI_RESTORE r13
27697 + addq $3*8, %rsp
27698 + CFI_ADJUST_CFA_OFFSET -3*8
27699 + pax_force_retaddr
27700 ret
27701 .Lcopy_page_end:
27702 CFI_ENDPROC
27703 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27704
27705 #include <asm/cpufeature.h>
27706
27707 - .section .altinstr_replacement,"ax"
27708 + .section .altinstr_replacement,"a"
27709 1: .byte 0xeb /* jmp <disp8> */
27710 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27711 2:
27712 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27713 index a30ca15..6b3f4e1 100644
27714 --- a/arch/x86/lib/copy_user_64.S
27715 +++ b/arch/x86/lib/copy_user_64.S
27716 @@ -18,31 +18,7 @@
27717 #include <asm/alternative-asm.h>
27718 #include <asm/asm.h>
27719 #include <asm/smap.h>
27720 -
27721 -/*
27722 - * By placing feature2 after feature1 in altinstructions section, we logically
27723 - * implement:
27724 - * If CPU has feature2, jmp to alt2 is used
27725 - * else if CPU has feature1, jmp to alt1 is used
27726 - * else jmp to orig is used.
27727 - */
27728 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27729 -0:
27730 - .byte 0xe9 /* 32bit jump */
27731 - .long \orig-1f /* by default jump to orig */
27732 -1:
27733 - .section .altinstr_replacement,"ax"
27734 -2: .byte 0xe9 /* near jump with 32bit immediate */
27735 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27736 -3: .byte 0xe9 /* near jump with 32bit immediate */
27737 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27738 - .previous
27739 -
27740 - .section .altinstructions,"a"
27741 - altinstruction_entry 0b,2b,\feature1,5,5
27742 - altinstruction_entry 0b,3b,\feature2,5,5
27743 - .previous
27744 - .endm
27745 +#include <asm/pgtable.h>
27746
27747 .macro ALIGN_DESTINATION
27748 #ifdef FIX_ALIGNMENT
27749 @@ -70,52 +46,6 @@
27750 #endif
27751 .endm
27752
27753 -/* Standard copy_to_user with segment limit checking */
27754 -ENTRY(_copy_to_user)
27755 - CFI_STARTPROC
27756 - GET_THREAD_INFO(%rax)
27757 - movq %rdi,%rcx
27758 - addq %rdx,%rcx
27759 - jc bad_to_user
27760 - cmpq TI_addr_limit(%rax),%rcx
27761 - ja bad_to_user
27762 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27763 - copy_user_generic_unrolled,copy_user_generic_string, \
27764 - copy_user_enhanced_fast_string
27765 - CFI_ENDPROC
27766 -ENDPROC(_copy_to_user)
27767 -
27768 -/* Standard copy_from_user with segment limit checking */
27769 -ENTRY(_copy_from_user)
27770 - CFI_STARTPROC
27771 - GET_THREAD_INFO(%rax)
27772 - movq %rsi,%rcx
27773 - addq %rdx,%rcx
27774 - jc bad_from_user
27775 - cmpq TI_addr_limit(%rax),%rcx
27776 - ja bad_from_user
27777 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27778 - copy_user_generic_unrolled,copy_user_generic_string, \
27779 - copy_user_enhanced_fast_string
27780 - CFI_ENDPROC
27781 -ENDPROC(_copy_from_user)
27782 -
27783 - .section .fixup,"ax"
27784 - /* must zero dest */
27785 -ENTRY(bad_from_user)
27786 -bad_from_user:
27787 - CFI_STARTPROC
27788 - movl %edx,%ecx
27789 - xorl %eax,%eax
27790 - rep
27791 - stosb
27792 -bad_to_user:
27793 - movl %edx,%eax
27794 - ret
27795 - CFI_ENDPROC
27796 -ENDPROC(bad_from_user)
27797 - .previous
27798 -
27799 /*
27800 * copy_user_generic_unrolled - memory copy with exception handling.
27801 * This version is for CPUs like P4 that don't have efficient micro
27802 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27803 */
27804 ENTRY(copy_user_generic_unrolled)
27805 CFI_STARTPROC
27806 + ASM_PAX_OPEN_USERLAND
27807 ASM_STAC
27808 cmpl $8,%edx
27809 jb 20f /* less then 8 bytes, go to byte copy loop */
27810 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27811 jz 17f
27812 1: movq (%rsi),%r8
27813 2: movq 1*8(%rsi),%r9
27814 -3: movq 2*8(%rsi),%r10
27815 +3: movq 2*8(%rsi),%rax
27816 4: movq 3*8(%rsi),%r11
27817 5: movq %r8,(%rdi)
27818 6: movq %r9,1*8(%rdi)
27819 -7: movq %r10,2*8(%rdi)
27820 +7: movq %rax,2*8(%rdi)
27821 8: movq %r11,3*8(%rdi)
27822 9: movq 4*8(%rsi),%r8
27823 10: movq 5*8(%rsi),%r9
27824 -11: movq 6*8(%rsi),%r10
27825 +11: movq 6*8(%rsi),%rax
27826 12: movq 7*8(%rsi),%r11
27827 13: movq %r8,4*8(%rdi)
27828 14: movq %r9,5*8(%rdi)
27829 -15: movq %r10,6*8(%rdi)
27830 +15: movq %rax,6*8(%rdi)
27831 16: movq %r11,7*8(%rdi)
27832 leaq 64(%rsi),%rsi
27833 leaq 64(%rdi),%rdi
27834 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27835 jnz 21b
27836 23: xor %eax,%eax
27837 ASM_CLAC
27838 + ASM_PAX_CLOSE_USERLAND
27839 + pax_force_retaddr
27840 ret
27841
27842 .section .fixup,"ax"
27843 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27844 */
27845 ENTRY(copy_user_generic_string)
27846 CFI_STARTPROC
27847 + ASM_PAX_OPEN_USERLAND
27848 ASM_STAC
27849 andl %edx,%edx
27850 jz 4f
27851 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27852 movsb
27853 4: xorl %eax,%eax
27854 ASM_CLAC
27855 + ASM_PAX_CLOSE_USERLAND
27856 + pax_force_retaddr
27857 ret
27858
27859 .section .fixup,"ax"
27860 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27861 */
27862 ENTRY(copy_user_enhanced_fast_string)
27863 CFI_STARTPROC
27864 + ASM_PAX_OPEN_USERLAND
27865 ASM_STAC
27866 andl %edx,%edx
27867 jz 2f
27868 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27869 movsb
27870 2: xorl %eax,%eax
27871 ASM_CLAC
27872 + ASM_PAX_CLOSE_USERLAND
27873 + pax_force_retaddr
27874 ret
27875
27876 .section .fixup,"ax"
27877 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27878 index 6a4f43c..55d26f2 100644
27879 --- a/arch/x86/lib/copy_user_nocache_64.S
27880 +++ b/arch/x86/lib/copy_user_nocache_64.S
27881 @@ -8,6 +8,7 @@
27882
27883 #include <linux/linkage.h>
27884 #include <asm/dwarf2.h>
27885 +#include <asm/alternative-asm.h>
27886
27887 #define FIX_ALIGNMENT 1
27888
27889 @@ -16,6 +17,7 @@
27890 #include <asm/thread_info.h>
27891 #include <asm/asm.h>
27892 #include <asm/smap.h>
27893 +#include <asm/pgtable.h>
27894
27895 .macro ALIGN_DESTINATION
27896 #ifdef FIX_ALIGNMENT
27897 @@ -49,6 +51,16 @@
27898 */
27899 ENTRY(__copy_user_nocache)
27900 CFI_STARTPROC
27901 +
27902 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27903 + mov pax_user_shadow_base,%rcx
27904 + cmp %rcx,%rsi
27905 + jae 1f
27906 + add %rcx,%rsi
27907 +1:
27908 +#endif
27909 +
27910 + ASM_PAX_OPEN_USERLAND
27911 ASM_STAC
27912 cmpl $8,%edx
27913 jb 20f /* less then 8 bytes, go to byte copy loop */
27914 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27915 jz 17f
27916 1: movq (%rsi),%r8
27917 2: movq 1*8(%rsi),%r9
27918 -3: movq 2*8(%rsi),%r10
27919 +3: movq 2*8(%rsi),%rax
27920 4: movq 3*8(%rsi),%r11
27921 5: movnti %r8,(%rdi)
27922 6: movnti %r9,1*8(%rdi)
27923 -7: movnti %r10,2*8(%rdi)
27924 +7: movnti %rax,2*8(%rdi)
27925 8: movnti %r11,3*8(%rdi)
27926 9: movq 4*8(%rsi),%r8
27927 10: movq 5*8(%rsi),%r9
27928 -11: movq 6*8(%rsi),%r10
27929 +11: movq 6*8(%rsi),%rax
27930 12: movq 7*8(%rsi),%r11
27931 13: movnti %r8,4*8(%rdi)
27932 14: movnti %r9,5*8(%rdi)
27933 -15: movnti %r10,6*8(%rdi)
27934 +15: movnti %rax,6*8(%rdi)
27935 16: movnti %r11,7*8(%rdi)
27936 leaq 64(%rsi),%rsi
27937 leaq 64(%rdi),%rdi
27938 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27939 jnz 21b
27940 23: xorl %eax,%eax
27941 ASM_CLAC
27942 + ASM_PAX_CLOSE_USERLAND
27943 sfence
27944 + pax_force_retaddr
27945 ret
27946
27947 .section .fixup,"ax"
27948 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27949 index 2419d5f..953ee51 100644
27950 --- a/arch/x86/lib/csum-copy_64.S
27951 +++ b/arch/x86/lib/csum-copy_64.S
27952 @@ -9,6 +9,7 @@
27953 #include <asm/dwarf2.h>
27954 #include <asm/errno.h>
27955 #include <asm/asm.h>
27956 +#include <asm/alternative-asm.h>
27957
27958 /*
27959 * Checksum copy with exception handling.
27960 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27961 CFI_RESTORE rbp
27962 addq $7*8, %rsp
27963 CFI_ADJUST_CFA_OFFSET -7*8
27964 + pax_force_retaddr 0, 1
27965 ret
27966 CFI_RESTORE_STATE
27967
27968 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27969 index 7609e0e..b449b98 100644
27970 --- a/arch/x86/lib/csum-wrappers_64.c
27971 +++ b/arch/x86/lib/csum-wrappers_64.c
27972 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27973 len -= 2;
27974 }
27975 }
27976 + pax_open_userland();
27977 stac();
27978 - isum = csum_partial_copy_generic((__force const void *)src,
27979 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27980 dst, len, isum, errp, NULL);
27981 clac();
27982 + pax_close_userland();
27983 if (unlikely(*errp))
27984 goto out_err;
27985
27986 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27987 }
27988
27989 *errp = 0;
27990 + pax_open_userland();
27991 stac();
27992 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27993 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27994 len, isum, NULL, errp);
27995 clac();
27996 + pax_close_userland();
27997 return ret;
27998 }
27999 EXPORT_SYMBOL(csum_partial_copy_to_user);
28000 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28001 index a451235..1daa956 100644
28002 --- a/arch/x86/lib/getuser.S
28003 +++ b/arch/x86/lib/getuser.S
28004 @@ -33,17 +33,40 @@
28005 #include <asm/thread_info.h>
28006 #include <asm/asm.h>
28007 #include <asm/smap.h>
28008 +#include <asm/segment.h>
28009 +#include <asm/pgtable.h>
28010 +#include <asm/alternative-asm.h>
28011 +
28012 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28013 +#define __copyuser_seg gs;
28014 +#else
28015 +#define __copyuser_seg
28016 +#endif
28017
28018 .text
28019 ENTRY(__get_user_1)
28020 CFI_STARTPROC
28021 +
28022 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28023 GET_THREAD_INFO(%_ASM_DX)
28024 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28025 jae bad_get_user
28026 ASM_STAC
28027 -1: movzbl (%_ASM_AX),%edx
28028 +
28029 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28030 + mov pax_user_shadow_base,%_ASM_DX
28031 + cmp %_ASM_DX,%_ASM_AX
28032 + jae 1234f
28033 + add %_ASM_DX,%_ASM_AX
28034 +1234:
28035 +#endif
28036 +
28037 +#endif
28038 +
28039 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28040 xor %eax,%eax
28041 ASM_CLAC
28042 + pax_force_retaddr
28043 ret
28044 CFI_ENDPROC
28045 ENDPROC(__get_user_1)
28046 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28047 ENTRY(__get_user_2)
28048 CFI_STARTPROC
28049 add $1,%_ASM_AX
28050 +
28051 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28052 jc bad_get_user
28053 GET_THREAD_INFO(%_ASM_DX)
28054 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28055 jae bad_get_user
28056 ASM_STAC
28057 -2: movzwl -1(%_ASM_AX),%edx
28058 +
28059 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28060 + mov pax_user_shadow_base,%_ASM_DX
28061 + cmp %_ASM_DX,%_ASM_AX
28062 + jae 1234f
28063 + add %_ASM_DX,%_ASM_AX
28064 +1234:
28065 +#endif
28066 +
28067 +#endif
28068 +
28069 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28070 xor %eax,%eax
28071 ASM_CLAC
28072 + pax_force_retaddr
28073 ret
28074 CFI_ENDPROC
28075 ENDPROC(__get_user_2)
28076 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28077 ENTRY(__get_user_4)
28078 CFI_STARTPROC
28079 add $3,%_ASM_AX
28080 +
28081 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28082 jc bad_get_user
28083 GET_THREAD_INFO(%_ASM_DX)
28084 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28085 jae bad_get_user
28086 ASM_STAC
28087 -3: movl -3(%_ASM_AX),%edx
28088 +
28089 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28090 + mov pax_user_shadow_base,%_ASM_DX
28091 + cmp %_ASM_DX,%_ASM_AX
28092 + jae 1234f
28093 + add %_ASM_DX,%_ASM_AX
28094 +1234:
28095 +#endif
28096 +
28097 +#endif
28098 +
28099 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28100 xor %eax,%eax
28101 ASM_CLAC
28102 + pax_force_retaddr
28103 ret
28104 CFI_ENDPROC
28105 ENDPROC(__get_user_4)
28106 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28107 GET_THREAD_INFO(%_ASM_DX)
28108 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28109 jae bad_get_user
28110 +
28111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28112 + mov pax_user_shadow_base,%_ASM_DX
28113 + cmp %_ASM_DX,%_ASM_AX
28114 + jae 1234f
28115 + add %_ASM_DX,%_ASM_AX
28116 +1234:
28117 +#endif
28118 +
28119 ASM_STAC
28120 4: movq -7(%_ASM_AX),%rdx
28121 xor %eax,%eax
28122 ASM_CLAC
28123 + pax_force_retaddr
28124 ret
28125 #else
28126 add $7,%_ASM_AX
28127 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28128 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28129 jae bad_get_user_8
28130 ASM_STAC
28131 -4: movl -7(%_ASM_AX),%edx
28132 -5: movl -3(%_ASM_AX),%ecx
28133 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28134 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28135 xor %eax,%eax
28136 ASM_CLAC
28137 + pax_force_retaddr
28138 ret
28139 #endif
28140 CFI_ENDPROC
28141 @@ -113,6 +175,7 @@ bad_get_user:
28142 xor %edx,%edx
28143 mov $(-EFAULT),%_ASM_AX
28144 ASM_CLAC
28145 + pax_force_retaddr
28146 ret
28147 CFI_ENDPROC
28148 END(bad_get_user)
28149 @@ -124,6 +187,7 @@ bad_get_user_8:
28150 xor %ecx,%ecx
28151 mov $(-EFAULT),%_ASM_AX
28152 ASM_CLAC
28153 + pax_force_retaddr
28154 ret
28155 CFI_ENDPROC
28156 END(bad_get_user_8)
28157 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28158 index 54fcffe..7be149e 100644
28159 --- a/arch/x86/lib/insn.c
28160 +++ b/arch/x86/lib/insn.c
28161 @@ -20,8 +20,10 @@
28162
28163 #ifdef __KERNEL__
28164 #include <linux/string.h>
28165 +#include <asm/pgtable_types.h>
28166 #else
28167 #include <string.h>
28168 +#define ktla_ktva(addr) addr
28169 #endif
28170 #include <asm/inat.h>
28171 #include <asm/insn.h>
28172 @@ -53,8 +55,8 @@
28173 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28174 {
28175 memset(insn, 0, sizeof(*insn));
28176 - insn->kaddr = kaddr;
28177 - insn->next_byte = kaddr;
28178 + insn->kaddr = ktla_ktva(kaddr);
28179 + insn->next_byte = ktla_ktva(kaddr);
28180 insn->x86_64 = x86_64 ? 1 : 0;
28181 insn->opnd_bytes = 4;
28182 if (x86_64)
28183 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28184 index 05a95e7..326f2fa 100644
28185 --- a/arch/x86/lib/iomap_copy_64.S
28186 +++ b/arch/x86/lib/iomap_copy_64.S
28187 @@ -17,6 +17,7 @@
28188
28189 #include <linux/linkage.h>
28190 #include <asm/dwarf2.h>
28191 +#include <asm/alternative-asm.h>
28192
28193 /*
28194 * override generic version in lib/iomap_copy.c
28195 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28196 CFI_STARTPROC
28197 movl %edx,%ecx
28198 rep movsd
28199 + pax_force_retaddr
28200 ret
28201 CFI_ENDPROC
28202 ENDPROC(__iowrite32_copy)
28203 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28204 index 56313a3..9b59269 100644
28205 --- a/arch/x86/lib/memcpy_64.S
28206 +++ b/arch/x86/lib/memcpy_64.S
28207 @@ -24,7 +24,7 @@
28208 * This gets patched over the unrolled variant (below) via the
28209 * alternative instructions framework:
28210 */
28211 - .section .altinstr_replacement, "ax", @progbits
28212 + .section .altinstr_replacement, "a", @progbits
28213 .Lmemcpy_c:
28214 movq %rdi, %rax
28215 movq %rdx, %rcx
28216 @@ -33,6 +33,7 @@
28217 rep movsq
28218 movl %edx, %ecx
28219 rep movsb
28220 + pax_force_retaddr
28221 ret
28222 .Lmemcpy_e:
28223 .previous
28224 @@ -44,11 +45,12 @@
28225 * This gets patched over the unrolled variant (below) via the
28226 * alternative instructions framework:
28227 */
28228 - .section .altinstr_replacement, "ax", @progbits
28229 + .section .altinstr_replacement, "a", @progbits
28230 .Lmemcpy_c_e:
28231 movq %rdi, %rax
28232 movq %rdx, %rcx
28233 rep movsb
28234 + pax_force_retaddr
28235 ret
28236 .Lmemcpy_e_e:
28237 .previous
28238 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28239 */
28240 movq 0*8(%rsi), %r8
28241 movq 1*8(%rsi), %r9
28242 - movq 2*8(%rsi), %r10
28243 + movq 2*8(%rsi), %rcx
28244 movq 3*8(%rsi), %r11
28245 leaq 4*8(%rsi), %rsi
28246
28247 movq %r8, 0*8(%rdi)
28248 movq %r9, 1*8(%rdi)
28249 - movq %r10, 2*8(%rdi)
28250 + movq %rcx, 2*8(%rdi)
28251 movq %r11, 3*8(%rdi)
28252 leaq 4*8(%rdi), %rdi
28253 jae .Lcopy_forward_loop
28254 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28255 subq $0x20, %rdx
28256 movq -1*8(%rsi), %r8
28257 movq -2*8(%rsi), %r9
28258 - movq -3*8(%rsi), %r10
28259 + movq -3*8(%rsi), %rcx
28260 movq -4*8(%rsi), %r11
28261 leaq -4*8(%rsi), %rsi
28262 movq %r8, -1*8(%rdi)
28263 movq %r9, -2*8(%rdi)
28264 - movq %r10, -3*8(%rdi)
28265 + movq %rcx, -3*8(%rdi)
28266 movq %r11, -4*8(%rdi)
28267 leaq -4*8(%rdi), %rdi
28268 jae .Lcopy_backward_loop
28269 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28270 */
28271 movq 0*8(%rsi), %r8
28272 movq 1*8(%rsi), %r9
28273 - movq -2*8(%rsi, %rdx), %r10
28274 + movq -2*8(%rsi, %rdx), %rcx
28275 movq -1*8(%rsi, %rdx), %r11
28276 movq %r8, 0*8(%rdi)
28277 movq %r9, 1*8(%rdi)
28278 - movq %r10, -2*8(%rdi, %rdx)
28279 + movq %rcx, -2*8(%rdi, %rdx)
28280 movq %r11, -1*8(%rdi, %rdx)
28281 + pax_force_retaddr
28282 retq
28283 .p2align 4
28284 .Lless_16bytes:
28285 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28286 movq -1*8(%rsi, %rdx), %r9
28287 movq %r8, 0*8(%rdi)
28288 movq %r9, -1*8(%rdi, %rdx)
28289 + pax_force_retaddr
28290 retq
28291 .p2align 4
28292 .Lless_8bytes:
28293 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28294 movl -4(%rsi, %rdx), %r8d
28295 movl %ecx, (%rdi)
28296 movl %r8d, -4(%rdi, %rdx)
28297 + pax_force_retaddr
28298 retq
28299 .p2align 4
28300 .Lless_3bytes:
28301 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28302 movb %cl, (%rdi)
28303
28304 .Lend:
28305 + pax_force_retaddr
28306 retq
28307 CFI_ENDPROC
28308 ENDPROC(memcpy)
28309 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28310 index 65268a6..5aa7815 100644
28311 --- a/arch/x86/lib/memmove_64.S
28312 +++ b/arch/x86/lib/memmove_64.S
28313 @@ -61,13 +61,13 @@ ENTRY(memmove)
28314 5:
28315 sub $0x20, %rdx
28316 movq 0*8(%rsi), %r11
28317 - movq 1*8(%rsi), %r10
28318 + movq 1*8(%rsi), %rcx
28319 movq 2*8(%rsi), %r9
28320 movq 3*8(%rsi), %r8
28321 leaq 4*8(%rsi), %rsi
28322
28323 movq %r11, 0*8(%rdi)
28324 - movq %r10, 1*8(%rdi)
28325 + movq %rcx, 1*8(%rdi)
28326 movq %r9, 2*8(%rdi)
28327 movq %r8, 3*8(%rdi)
28328 leaq 4*8(%rdi), %rdi
28329 @@ -81,10 +81,10 @@ ENTRY(memmove)
28330 4:
28331 movq %rdx, %rcx
28332 movq -8(%rsi, %rdx), %r11
28333 - lea -8(%rdi, %rdx), %r10
28334 + lea -8(%rdi, %rdx), %r9
28335 shrq $3, %rcx
28336 rep movsq
28337 - movq %r11, (%r10)
28338 + movq %r11, (%r9)
28339 jmp 13f
28340 .Lmemmove_end_forward:
28341
28342 @@ -95,14 +95,14 @@ ENTRY(memmove)
28343 7:
28344 movq %rdx, %rcx
28345 movq (%rsi), %r11
28346 - movq %rdi, %r10
28347 + movq %rdi, %r9
28348 leaq -8(%rsi, %rdx), %rsi
28349 leaq -8(%rdi, %rdx), %rdi
28350 shrq $3, %rcx
28351 std
28352 rep movsq
28353 cld
28354 - movq %r11, (%r10)
28355 + movq %r11, (%r9)
28356 jmp 13f
28357
28358 /*
28359 @@ -127,13 +127,13 @@ ENTRY(memmove)
28360 8:
28361 subq $0x20, %rdx
28362 movq -1*8(%rsi), %r11
28363 - movq -2*8(%rsi), %r10
28364 + movq -2*8(%rsi), %rcx
28365 movq -3*8(%rsi), %r9
28366 movq -4*8(%rsi), %r8
28367 leaq -4*8(%rsi), %rsi
28368
28369 movq %r11, -1*8(%rdi)
28370 - movq %r10, -2*8(%rdi)
28371 + movq %rcx, -2*8(%rdi)
28372 movq %r9, -3*8(%rdi)
28373 movq %r8, -4*8(%rdi)
28374 leaq -4*8(%rdi), %rdi
28375 @@ -151,11 +151,11 @@ ENTRY(memmove)
28376 * Move data from 16 bytes to 31 bytes.
28377 */
28378 movq 0*8(%rsi), %r11
28379 - movq 1*8(%rsi), %r10
28380 + movq 1*8(%rsi), %rcx
28381 movq -2*8(%rsi, %rdx), %r9
28382 movq -1*8(%rsi, %rdx), %r8
28383 movq %r11, 0*8(%rdi)
28384 - movq %r10, 1*8(%rdi)
28385 + movq %rcx, 1*8(%rdi)
28386 movq %r9, -2*8(%rdi, %rdx)
28387 movq %r8, -1*8(%rdi, %rdx)
28388 jmp 13f
28389 @@ -167,9 +167,9 @@ ENTRY(memmove)
28390 * Move data from 8 bytes to 15 bytes.
28391 */
28392 movq 0*8(%rsi), %r11
28393 - movq -1*8(%rsi, %rdx), %r10
28394 + movq -1*8(%rsi, %rdx), %r9
28395 movq %r11, 0*8(%rdi)
28396 - movq %r10, -1*8(%rdi, %rdx)
28397 + movq %r9, -1*8(%rdi, %rdx)
28398 jmp 13f
28399 10:
28400 cmpq $4, %rdx
28401 @@ -178,9 +178,9 @@ ENTRY(memmove)
28402 * Move data from 4 bytes to 7 bytes.
28403 */
28404 movl (%rsi), %r11d
28405 - movl -4(%rsi, %rdx), %r10d
28406 + movl -4(%rsi, %rdx), %r9d
28407 movl %r11d, (%rdi)
28408 - movl %r10d, -4(%rdi, %rdx)
28409 + movl %r9d, -4(%rdi, %rdx)
28410 jmp 13f
28411 11:
28412 cmp $2, %rdx
28413 @@ -189,9 +189,9 @@ ENTRY(memmove)
28414 * Move data from 2 bytes to 3 bytes.
28415 */
28416 movw (%rsi), %r11w
28417 - movw -2(%rsi, %rdx), %r10w
28418 + movw -2(%rsi, %rdx), %r9w
28419 movw %r11w, (%rdi)
28420 - movw %r10w, -2(%rdi, %rdx)
28421 + movw %r9w, -2(%rdi, %rdx)
28422 jmp 13f
28423 12:
28424 cmp $1, %rdx
28425 @@ -202,14 +202,16 @@ ENTRY(memmove)
28426 movb (%rsi), %r11b
28427 movb %r11b, (%rdi)
28428 13:
28429 + pax_force_retaddr
28430 retq
28431 CFI_ENDPROC
28432
28433 - .section .altinstr_replacement,"ax"
28434 + .section .altinstr_replacement,"a"
28435 .Lmemmove_begin_forward_efs:
28436 /* Forward moving data. */
28437 movq %rdx, %rcx
28438 rep movsb
28439 + pax_force_retaddr
28440 retq
28441 .Lmemmove_end_forward_efs:
28442 .previous
28443 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28444 index 2dcb380..50a78bc 100644
28445 --- a/arch/x86/lib/memset_64.S
28446 +++ b/arch/x86/lib/memset_64.S
28447 @@ -16,7 +16,7 @@
28448 *
28449 * rax original destination
28450 */
28451 - .section .altinstr_replacement, "ax", @progbits
28452 + .section .altinstr_replacement, "a", @progbits
28453 .Lmemset_c:
28454 movq %rdi,%r9
28455 movq %rdx,%rcx
28456 @@ -30,6 +30,7 @@
28457 movl %edx,%ecx
28458 rep stosb
28459 movq %r9,%rax
28460 + pax_force_retaddr
28461 ret
28462 .Lmemset_e:
28463 .previous
28464 @@ -45,13 +46,14 @@
28465 *
28466 * rax original destination
28467 */
28468 - .section .altinstr_replacement, "ax", @progbits
28469 + .section .altinstr_replacement, "a", @progbits
28470 .Lmemset_c_e:
28471 movq %rdi,%r9
28472 movb %sil,%al
28473 movq %rdx,%rcx
28474 rep stosb
28475 movq %r9,%rax
28476 + pax_force_retaddr
28477 ret
28478 .Lmemset_e_e:
28479 .previous
28480 @@ -59,7 +61,7 @@
28481 ENTRY(memset)
28482 ENTRY(__memset)
28483 CFI_STARTPROC
28484 - movq %rdi,%r10
28485 + movq %rdi,%r11
28486
28487 /* expand byte value */
28488 movzbl %sil,%ecx
28489 @@ -117,7 +119,8 @@ ENTRY(__memset)
28490 jnz .Lloop_1
28491
28492 .Lende:
28493 - movq %r10,%rax
28494 + movq %r11,%rax
28495 + pax_force_retaddr
28496 ret
28497
28498 CFI_RESTORE_STATE
28499 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28500 index c9f2d9b..e7fd2c0 100644
28501 --- a/arch/x86/lib/mmx_32.c
28502 +++ b/arch/x86/lib/mmx_32.c
28503 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28504 {
28505 void *p;
28506 int i;
28507 + unsigned long cr0;
28508
28509 if (unlikely(in_interrupt()))
28510 return __memcpy(to, from, len);
28511 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28512 kernel_fpu_begin();
28513
28514 __asm__ __volatile__ (
28515 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28516 - " prefetch 64(%0)\n"
28517 - " prefetch 128(%0)\n"
28518 - " prefetch 192(%0)\n"
28519 - " prefetch 256(%0)\n"
28520 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28521 + " prefetch 64(%1)\n"
28522 + " prefetch 128(%1)\n"
28523 + " prefetch 192(%1)\n"
28524 + " prefetch 256(%1)\n"
28525 "2: \n"
28526 ".section .fixup, \"ax\"\n"
28527 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28528 + "3: \n"
28529 +
28530 +#ifdef CONFIG_PAX_KERNEXEC
28531 + " movl %%cr0, %0\n"
28532 + " movl %0, %%eax\n"
28533 + " andl $0xFFFEFFFF, %%eax\n"
28534 + " movl %%eax, %%cr0\n"
28535 +#endif
28536 +
28537 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28538 +
28539 +#ifdef CONFIG_PAX_KERNEXEC
28540 + " movl %0, %%cr0\n"
28541 +#endif
28542 +
28543 " jmp 2b\n"
28544 ".previous\n"
28545 _ASM_EXTABLE(1b, 3b)
28546 - : : "r" (from));
28547 + : "=&r" (cr0) : "r" (from) : "ax");
28548
28549 for ( ; i > 5; i--) {
28550 __asm__ __volatile__ (
28551 - "1: prefetch 320(%0)\n"
28552 - "2: movq (%0), %%mm0\n"
28553 - " movq 8(%0), %%mm1\n"
28554 - " movq 16(%0), %%mm2\n"
28555 - " movq 24(%0), %%mm3\n"
28556 - " movq %%mm0, (%1)\n"
28557 - " movq %%mm1, 8(%1)\n"
28558 - " movq %%mm2, 16(%1)\n"
28559 - " movq %%mm3, 24(%1)\n"
28560 - " movq 32(%0), %%mm0\n"
28561 - " movq 40(%0), %%mm1\n"
28562 - " movq 48(%0), %%mm2\n"
28563 - " movq 56(%0), %%mm3\n"
28564 - " movq %%mm0, 32(%1)\n"
28565 - " movq %%mm1, 40(%1)\n"
28566 - " movq %%mm2, 48(%1)\n"
28567 - " movq %%mm3, 56(%1)\n"
28568 + "1: prefetch 320(%1)\n"
28569 + "2: movq (%1), %%mm0\n"
28570 + " movq 8(%1), %%mm1\n"
28571 + " movq 16(%1), %%mm2\n"
28572 + " movq 24(%1), %%mm3\n"
28573 + " movq %%mm0, (%2)\n"
28574 + " movq %%mm1, 8(%2)\n"
28575 + " movq %%mm2, 16(%2)\n"
28576 + " movq %%mm3, 24(%2)\n"
28577 + " movq 32(%1), %%mm0\n"
28578 + " movq 40(%1), %%mm1\n"
28579 + " movq 48(%1), %%mm2\n"
28580 + " movq 56(%1), %%mm3\n"
28581 + " movq %%mm0, 32(%2)\n"
28582 + " movq %%mm1, 40(%2)\n"
28583 + " movq %%mm2, 48(%2)\n"
28584 + " movq %%mm3, 56(%2)\n"
28585 ".section .fixup, \"ax\"\n"
28586 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28587 + "3:\n"
28588 +
28589 +#ifdef CONFIG_PAX_KERNEXEC
28590 + " movl %%cr0, %0\n"
28591 + " movl %0, %%eax\n"
28592 + " andl $0xFFFEFFFF, %%eax\n"
28593 + " movl %%eax, %%cr0\n"
28594 +#endif
28595 +
28596 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28597 +
28598 +#ifdef CONFIG_PAX_KERNEXEC
28599 + " movl %0, %%cr0\n"
28600 +#endif
28601 +
28602 " jmp 2b\n"
28603 ".previous\n"
28604 _ASM_EXTABLE(1b, 3b)
28605 - : : "r" (from), "r" (to) : "memory");
28606 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28607
28608 from += 64;
28609 to += 64;
28610 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28611 static void fast_copy_page(void *to, void *from)
28612 {
28613 int i;
28614 + unsigned long cr0;
28615
28616 kernel_fpu_begin();
28617
28618 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28619 * but that is for later. -AV
28620 */
28621 __asm__ __volatile__(
28622 - "1: prefetch (%0)\n"
28623 - " prefetch 64(%0)\n"
28624 - " prefetch 128(%0)\n"
28625 - " prefetch 192(%0)\n"
28626 - " prefetch 256(%0)\n"
28627 + "1: prefetch (%1)\n"
28628 + " prefetch 64(%1)\n"
28629 + " prefetch 128(%1)\n"
28630 + " prefetch 192(%1)\n"
28631 + " prefetch 256(%1)\n"
28632 "2: \n"
28633 ".section .fixup, \"ax\"\n"
28634 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28635 + "3: \n"
28636 +
28637 +#ifdef CONFIG_PAX_KERNEXEC
28638 + " movl %%cr0, %0\n"
28639 + " movl %0, %%eax\n"
28640 + " andl $0xFFFEFFFF, %%eax\n"
28641 + " movl %%eax, %%cr0\n"
28642 +#endif
28643 +
28644 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28645 +
28646 +#ifdef CONFIG_PAX_KERNEXEC
28647 + " movl %0, %%cr0\n"
28648 +#endif
28649 +
28650 " jmp 2b\n"
28651 ".previous\n"
28652 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28653 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28654
28655 for (i = 0; i < (4096-320)/64; i++) {
28656 __asm__ __volatile__ (
28657 - "1: prefetch 320(%0)\n"
28658 - "2: movq (%0), %%mm0\n"
28659 - " movntq %%mm0, (%1)\n"
28660 - " movq 8(%0), %%mm1\n"
28661 - " movntq %%mm1, 8(%1)\n"
28662 - " movq 16(%0), %%mm2\n"
28663 - " movntq %%mm2, 16(%1)\n"
28664 - " movq 24(%0), %%mm3\n"
28665 - " movntq %%mm3, 24(%1)\n"
28666 - " movq 32(%0), %%mm4\n"
28667 - " movntq %%mm4, 32(%1)\n"
28668 - " movq 40(%0), %%mm5\n"
28669 - " movntq %%mm5, 40(%1)\n"
28670 - " movq 48(%0), %%mm6\n"
28671 - " movntq %%mm6, 48(%1)\n"
28672 - " movq 56(%0), %%mm7\n"
28673 - " movntq %%mm7, 56(%1)\n"
28674 + "1: prefetch 320(%1)\n"
28675 + "2: movq (%1), %%mm0\n"
28676 + " movntq %%mm0, (%2)\n"
28677 + " movq 8(%1), %%mm1\n"
28678 + " movntq %%mm1, 8(%2)\n"
28679 + " movq 16(%1), %%mm2\n"
28680 + " movntq %%mm2, 16(%2)\n"
28681 + " movq 24(%1), %%mm3\n"
28682 + " movntq %%mm3, 24(%2)\n"
28683 + " movq 32(%1), %%mm4\n"
28684 + " movntq %%mm4, 32(%2)\n"
28685 + " movq 40(%1), %%mm5\n"
28686 + " movntq %%mm5, 40(%2)\n"
28687 + " movq 48(%1), %%mm6\n"
28688 + " movntq %%mm6, 48(%2)\n"
28689 + " movq 56(%1), %%mm7\n"
28690 + " movntq %%mm7, 56(%2)\n"
28691 ".section .fixup, \"ax\"\n"
28692 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28693 + "3:\n"
28694 +
28695 +#ifdef CONFIG_PAX_KERNEXEC
28696 + " movl %%cr0, %0\n"
28697 + " movl %0, %%eax\n"
28698 + " andl $0xFFFEFFFF, %%eax\n"
28699 + " movl %%eax, %%cr0\n"
28700 +#endif
28701 +
28702 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28703 +
28704 +#ifdef CONFIG_PAX_KERNEXEC
28705 + " movl %0, %%cr0\n"
28706 +#endif
28707 +
28708 " jmp 2b\n"
28709 ".previous\n"
28710 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28711 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28712
28713 from += 64;
28714 to += 64;
28715 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28716 static void fast_copy_page(void *to, void *from)
28717 {
28718 int i;
28719 + unsigned long cr0;
28720
28721 kernel_fpu_begin();
28722
28723 __asm__ __volatile__ (
28724 - "1: prefetch (%0)\n"
28725 - " prefetch 64(%0)\n"
28726 - " prefetch 128(%0)\n"
28727 - " prefetch 192(%0)\n"
28728 - " prefetch 256(%0)\n"
28729 + "1: prefetch (%1)\n"
28730 + " prefetch 64(%1)\n"
28731 + " prefetch 128(%1)\n"
28732 + " prefetch 192(%1)\n"
28733 + " prefetch 256(%1)\n"
28734 "2: \n"
28735 ".section .fixup, \"ax\"\n"
28736 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28737 + "3: \n"
28738 +
28739 +#ifdef CONFIG_PAX_KERNEXEC
28740 + " movl %%cr0, %0\n"
28741 + " movl %0, %%eax\n"
28742 + " andl $0xFFFEFFFF, %%eax\n"
28743 + " movl %%eax, %%cr0\n"
28744 +#endif
28745 +
28746 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28747 +
28748 +#ifdef CONFIG_PAX_KERNEXEC
28749 + " movl %0, %%cr0\n"
28750 +#endif
28751 +
28752 " jmp 2b\n"
28753 ".previous\n"
28754 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28755 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28756
28757 for (i = 0; i < 4096/64; i++) {
28758 __asm__ __volatile__ (
28759 - "1: prefetch 320(%0)\n"
28760 - "2: movq (%0), %%mm0\n"
28761 - " movq 8(%0), %%mm1\n"
28762 - " movq 16(%0), %%mm2\n"
28763 - " movq 24(%0), %%mm3\n"
28764 - " movq %%mm0, (%1)\n"
28765 - " movq %%mm1, 8(%1)\n"
28766 - " movq %%mm2, 16(%1)\n"
28767 - " movq %%mm3, 24(%1)\n"
28768 - " movq 32(%0), %%mm0\n"
28769 - " movq 40(%0), %%mm1\n"
28770 - " movq 48(%0), %%mm2\n"
28771 - " movq 56(%0), %%mm3\n"
28772 - " movq %%mm0, 32(%1)\n"
28773 - " movq %%mm1, 40(%1)\n"
28774 - " movq %%mm2, 48(%1)\n"
28775 - " movq %%mm3, 56(%1)\n"
28776 + "1: prefetch 320(%1)\n"
28777 + "2: movq (%1), %%mm0\n"
28778 + " movq 8(%1), %%mm1\n"
28779 + " movq 16(%1), %%mm2\n"
28780 + " movq 24(%1), %%mm3\n"
28781 + " movq %%mm0, (%2)\n"
28782 + " movq %%mm1, 8(%2)\n"
28783 + " movq %%mm2, 16(%2)\n"
28784 + " movq %%mm3, 24(%2)\n"
28785 + " movq 32(%1), %%mm0\n"
28786 + " movq 40(%1), %%mm1\n"
28787 + " movq 48(%1), %%mm2\n"
28788 + " movq 56(%1), %%mm3\n"
28789 + " movq %%mm0, 32(%2)\n"
28790 + " movq %%mm1, 40(%2)\n"
28791 + " movq %%mm2, 48(%2)\n"
28792 + " movq %%mm3, 56(%2)\n"
28793 ".section .fixup, \"ax\"\n"
28794 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28795 + "3:\n"
28796 +
28797 +#ifdef CONFIG_PAX_KERNEXEC
28798 + " movl %%cr0, %0\n"
28799 + " movl %0, %%eax\n"
28800 + " andl $0xFFFEFFFF, %%eax\n"
28801 + " movl %%eax, %%cr0\n"
28802 +#endif
28803 +
28804 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28805 +
28806 +#ifdef CONFIG_PAX_KERNEXEC
28807 + " movl %0, %%cr0\n"
28808 +#endif
28809 +
28810 " jmp 2b\n"
28811 ".previous\n"
28812 _ASM_EXTABLE(1b, 3b)
28813 - : : "r" (from), "r" (to) : "memory");
28814 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28815
28816 from += 64;
28817 to += 64;
28818 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28819 index f6d13ee..aca5f0b 100644
28820 --- a/arch/x86/lib/msr-reg.S
28821 +++ b/arch/x86/lib/msr-reg.S
28822 @@ -3,6 +3,7 @@
28823 #include <asm/dwarf2.h>
28824 #include <asm/asm.h>
28825 #include <asm/msr.h>
28826 +#include <asm/alternative-asm.h>
28827
28828 #ifdef CONFIG_X86_64
28829 /*
28830 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28831 CFI_STARTPROC
28832 pushq_cfi %rbx
28833 pushq_cfi %rbp
28834 - movq %rdi, %r10 /* Save pointer */
28835 + movq %rdi, %r9 /* Save pointer */
28836 xorl %r11d, %r11d /* Return value */
28837 movl (%rdi), %eax
28838 movl 4(%rdi), %ecx
28839 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28840 movl 28(%rdi), %edi
28841 CFI_REMEMBER_STATE
28842 1: \op
28843 -2: movl %eax, (%r10)
28844 +2: movl %eax, (%r9)
28845 movl %r11d, %eax /* Return value */
28846 - movl %ecx, 4(%r10)
28847 - movl %edx, 8(%r10)
28848 - movl %ebx, 12(%r10)
28849 - movl %ebp, 20(%r10)
28850 - movl %esi, 24(%r10)
28851 - movl %edi, 28(%r10)
28852 + movl %ecx, 4(%r9)
28853 + movl %edx, 8(%r9)
28854 + movl %ebx, 12(%r9)
28855 + movl %ebp, 20(%r9)
28856 + movl %esi, 24(%r9)
28857 + movl %edi, 28(%r9)
28858 popq_cfi %rbp
28859 popq_cfi %rbx
28860 + pax_force_retaddr
28861 ret
28862 3:
28863 CFI_RESTORE_STATE
28864 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28865 index fc6ba17..d4d989d 100644
28866 --- a/arch/x86/lib/putuser.S
28867 +++ b/arch/x86/lib/putuser.S
28868 @@ -16,7 +16,9 @@
28869 #include <asm/errno.h>
28870 #include <asm/asm.h>
28871 #include <asm/smap.h>
28872 -
28873 +#include <asm/segment.h>
28874 +#include <asm/pgtable.h>
28875 +#include <asm/alternative-asm.h>
28876
28877 /*
28878 * __put_user_X
28879 @@ -30,57 +32,125 @@
28880 * as they get called from within inline assembly.
28881 */
28882
28883 -#define ENTER CFI_STARTPROC ; \
28884 - GET_THREAD_INFO(%_ASM_BX)
28885 -#define EXIT ASM_CLAC ; \
28886 - ret ; \
28887 +#define ENTER CFI_STARTPROC
28888 +#define EXIT ASM_CLAC ; \
28889 + pax_force_retaddr ; \
28890 + ret ; \
28891 CFI_ENDPROC
28892
28893 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28894 +#define _DEST %_ASM_CX,%_ASM_BX
28895 +#else
28896 +#define _DEST %_ASM_CX
28897 +#endif
28898 +
28899 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28900 +#define __copyuser_seg gs;
28901 +#else
28902 +#define __copyuser_seg
28903 +#endif
28904 +
28905 .text
28906 ENTRY(__put_user_1)
28907 ENTER
28908 +
28909 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28910 + GET_THREAD_INFO(%_ASM_BX)
28911 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28912 jae bad_put_user
28913 ASM_STAC
28914 -1: movb %al,(%_ASM_CX)
28915 +
28916 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28917 + mov pax_user_shadow_base,%_ASM_BX
28918 + cmp %_ASM_BX,%_ASM_CX
28919 + jb 1234f
28920 + xor %ebx,%ebx
28921 +1234:
28922 +#endif
28923 +
28924 +#endif
28925 +
28926 +1: __copyuser_seg movb %al,(_DEST)
28927 xor %eax,%eax
28928 EXIT
28929 ENDPROC(__put_user_1)
28930
28931 ENTRY(__put_user_2)
28932 ENTER
28933 +
28934 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28935 + GET_THREAD_INFO(%_ASM_BX)
28936 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28937 sub $1,%_ASM_BX
28938 cmp %_ASM_BX,%_ASM_CX
28939 jae bad_put_user
28940 ASM_STAC
28941 -2: movw %ax,(%_ASM_CX)
28942 +
28943 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28944 + mov pax_user_shadow_base,%_ASM_BX
28945 + cmp %_ASM_BX,%_ASM_CX
28946 + jb 1234f
28947 + xor %ebx,%ebx
28948 +1234:
28949 +#endif
28950 +
28951 +#endif
28952 +
28953 +2: __copyuser_seg movw %ax,(_DEST)
28954 xor %eax,%eax
28955 EXIT
28956 ENDPROC(__put_user_2)
28957
28958 ENTRY(__put_user_4)
28959 ENTER
28960 +
28961 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28962 + GET_THREAD_INFO(%_ASM_BX)
28963 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28964 sub $3,%_ASM_BX
28965 cmp %_ASM_BX,%_ASM_CX
28966 jae bad_put_user
28967 ASM_STAC
28968 -3: movl %eax,(%_ASM_CX)
28969 +
28970 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28971 + mov pax_user_shadow_base,%_ASM_BX
28972 + cmp %_ASM_BX,%_ASM_CX
28973 + jb 1234f
28974 + xor %ebx,%ebx
28975 +1234:
28976 +#endif
28977 +
28978 +#endif
28979 +
28980 +3: __copyuser_seg movl %eax,(_DEST)
28981 xor %eax,%eax
28982 EXIT
28983 ENDPROC(__put_user_4)
28984
28985 ENTRY(__put_user_8)
28986 ENTER
28987 +
28988 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28989 + GET_THREAD_INFO(%_ASM_BX)
28990 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28991 sub $7,%_ASM_BX
28992 cmp %_ASM_BX,%_ASM_CX
28993 jae bad_put_user
28994 ASM_STAC
28995 -4: mov %_ASM_AX,(%_ASM_CX)
28996 +
28997 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28998 + mov pax_user_shadow_base,%_ASM_BX
28999 + cmp %_ASM_BX,%_ASM_CX
29000 + jb 1234f
29001 + xor %ebx,%ebx
29002 +1234:
29003 +#endif
29004 +
29005 +#endif
29006 +
29007 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29008 #ifdef CONFIG_X86_32
29009 -5: movl %edx,4(%_ASM_CX)
29010 +5: __copyuser_seg movl %edx,4(_DEST)
29011 #endif
29012 xor %eax,%eax
29013 EXIT
29014 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29015 index 1cad221..de671ee 100644
29016 --- a/arch/x86/lib/rwlock.S
29017 +++ b/arch/x86/lib/rwlock.S
29018 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29019 FRAME
29020 0: LOCK_PREFIX
29021 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29022 +
29023 +#ifdef CONFIG_PAX_REFCOUNT
29024 + jno 1234f
29025 + LOCK_PREFIX
29026 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29027 + int $4
29028 +1234:
29029 + _ASM_EXTABLE(1234b, 1234b)
29030 +#endif
29031 +
29032 1: rep; nop
29033 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29034 jne 1b
29035 LOCK_PREFIX
29036 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29037 +
29038 +#ifdef CONFIG_PAX_REFCOUNT
29039 + jno 1234f
29040 + LOCK_PREFIX
29041 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29042 + int $4
29043 +1234:
29044 + _ASM_EXTABLE(1234b, 1234b)
29045 +#endif
29046 +
29047 jnz 0b
29048 ENDFRAME
29049 + pax_force_retaddr
29050 ret
29051 CFI_ENDPROC
29052 END(__write_lock_failed)
29053 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29054 FRAME
29055 0: LOCK_PREFIX
29056 READ_LOCK_SIZE(inc) (%__lock_ptr)
29057 +
29058 +#ifdef CONFIG_PAX_REFCOUNT
29059 + jno 1234f
29060 + LOCK_PREFIX
29061 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29062 + int $4
29063 +1234:
29064 + _ASM_EXTABLE(1234b, 1234b)
29065 +#endif
29066 +
29067 1: rep; nop
29068 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29069 js 1b
29070 LOCK_PREFIX
29071 READ_LOCK_SIZE(dec) (%__lock_ptr)
29072 +
29073 +#ifdef CONFIG_PAX_REFCOUNT
29074 + jno 1234f
29075 + LOCK_PREFIX
29076 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29077 + int $4
29078 +1234:
29079 + _ASM_EXTABLE(1234b, 1234b)
29080 +#endif
29081 +
29082 js 0b
29083 ENDFRAME
29084 + pax_force_retaddr
29085 ret
29086 CFI_ENDPROC
29087 END(__read_lock_failed)
29088 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29089 index 5dff5f0..cadebf4 100644
29090 --- a/arch/x86/lib/rwsem.S
29091 +++ b/arch/x86/lib/rwsem.S
29092 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29093 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29094 CFI_RESTORE __ASM_REG(dx)
29095 restore_common_regs
29096 + pax_force_retaddr
29097 ret
29098 CFI_ENDPROC
29099 ENDPROC(call_rwsem_down_read_failed)
29100 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29101 movq %rax,%rdi
29102 call rwsem_down_write_failed
29103 restore_common_regs
29104 + pax_force_retaddr
29105 ret
29106 CFI_ENDPROC
29107 ENDPROC(call_rwsem_down_write_failed)
29108 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29109 movq %rax,%rdi
29110 call rwsem_wake
29111 restore_common_regs
29112 -1: ret
29113 +1: pax_force_retaddr
29114 + ret
29115 CFI_ENDPROC
29116 ENDPROC(call_rwsem_wake)
29117
29118 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29119 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29120 CFI_RESTORE __ASM_REG(dx)
29121 restore_common_regs
29122 + pax_force_retaddr
29123 ret
29124 CFI_ENDPROC
29125 ENDPROC(call_rwsem_downgrade_wake)
29126 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29127 index a63efd6..ccecad8 100644
29128 --- a/arch/x86/lib/thunk_64.S
29129 +++ b/arch/x86/lib/thunk_64.S
29130 @@ -8,6 +8,7 @@
29131 #include <linux/linkage.h>
29132 #include <asm/dwarf2.h>
29133 #include <asm/calling.h>
29134 +#include <asm/alternative-asm.h>
29135
29136 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29137 .macro THUNK name, func, put_ret_addr_in_rdi=0
29138 @@ -41,5 +42,6 @@
29139 SAVE_ARGS
29140 restore:
29141 RESTORE_ARGS
29142 + pax_force_retaddr
29143 ret
29144 CFI_ENDPROC
29145 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29146 index 3eb18ac..4b22130 100644
29147 --- a/arch/x86/lib/usercopy_32.c
29148 +++ b/arch/x86/lib/usercopy_32.c
29149 @@ -42,11 +42,13 @@ do { \
29150 int __d0; \
29151 might_fault(); \
29152 __asm__ __volatile__( \
29153 + __COPYUSER_SET_ES \
29154 ASM_STAC "\n" \
29155 "0: rep; stosl\n" \
29156 " movl %2,%0\n" \
29157 "1: rep; stosb\n" \
29158 "2: " ASM_CLAC "\n" \
29159 + __COPYUSER_RESTORE_ES \
29160 ".section .fixup,\"ax\"\n" \
29161 "3: lea 0(%2,%0,4),%0\n" \
29162 " jmp 2b\n" \
29163 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29164
29165 #ifdef CONFIG_X86_INTEL_USERCOPY
29166 static unsigned long
29167 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29168 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29169 {
29170 int d0, d1;
29171 __asm__ __volatile__(
29172 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29173 " .align 2,0x90\n"
29174 "3: movl 0(%4), %%eax\n"
29175 "4: movl 4(%4), %%edx\n"
29176 - "5: movl %%eax, 0(%3)\n"
29177 - "6: movl %%edx, 4(%3)\n"
29178 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29179 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29180 "7: movl 8(%4), %%eax\n"
29181 "8: movl 12(%4),%%edx\n"
29182 - "9: movl %%eax, 8(%3)\n"
29183 - "10: movl %%edx, 12(%3)\n"
29184 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29185 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29186 "11: movl 16(%4), %%eax\n"
29187 "12: movl 20(%4), %%edx\n"
29188 - "13: movl %%eax, 16(%3)\n"
29189 - "14: movl %%edx, 20(%3)\n"
29190 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29191 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29192 "15: movl 24(%4), %%eax\n"
29193 "16: movl 28(%4), %%edx\n"
29194 - "17: movl %%eax, 24(%3)\n"
29195 - "18: movl %%edx, 28(%3)\n"
29196 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29197 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29198 "19: movl 32(%4), %%eax\n"
29199 "20: movl 36(%4), %%edx\n"
29200 - "21: movl %%eax, 32(%3)\n"
29201 - "22: movl %%edx, 36(%3)\n"
29202 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29203 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29204 "23: movl 40(%4), %%eax\n"
29205 "24: movl 44(%4), %%edx\n"
29206 - "25: movl %%eax, 40(%3)\n"
29207 - "26: movl %%edx, 44(%3)\n"
29208 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29209 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29210 "27: movl 48(%4), %%eax\n"
29211 "28: movl 52(%4), %%edx\n"
29212 - "29: movl %%eax, 48(%3)\n"
29213 - "30: movl %%edx, 52(%3)\n"
29214 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29215 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29216 "31: movl 56(%4), %%eax\n"
29217 "32: movl 60(%4), %%edx\n"
29218 - "33: movl %%eax, 56(%3)\n"
29219 - "34: movl %%edx, 60(%3)\n"
29220 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29221 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29222 " addl $-64, %0\n"
29223 " addl $64, %4\n"
29224 " addl $64, %3\n"
29225 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29226 " shrl $2, %0\n"
29227 " andl $3, %%eax\n"
29228 " cld\n"
29229 + __COPYUSER_SET_ES
29230 "99: rep; movsl\n"
29231 "36: movl %%eax, %0\n"
29232 "37: rep; movsb\n"
29233 "100:\n"
29234 + __COPYUSER_RESTORE_ES
29235 + ".section .fixup,\"ax\"\n"
29236 + "101: lea 0(%%eax,%0,4),%0\n"
29237 + " jmp 100b\n"
29238 + ".previous\n"
29239 + _ASM_EXTABLE(1b,100b)
29240 + _ASM_EXTABLE(2b,100b)
29241 + _ASM_EXTABLE(3b,100b)
29242 + _ASM_EXTABLE(4b,100b)
29243 + _ASM_EXTABLE(5b,100b)
29244 + _ASM_EXTABLE(6b,100b)
29245 + _ASM_EXTABLE(7b,100b)
29246 + _ASM_EXTABLE(8b,100b)
29247 + _ASM_EXTABLE(9b,100b)
29248 + _ASM_EXTABLE(10b,100b)
29249 + _ASM_EXTABLE(11b,100b)
29250 + _ASM_EXTABLE(12b,100b)
29251 + _ASM_EXTABLE(13b,100b)
29252 + _ASM_EXTABLE(14b,100b)
29253 + _ASM_EXTABLE(15b,100b)
29254 + _ASM_EXTABLE(16b,100b)
29255 + _ASM_EXTABLE(17b,100b)
29256 + _ASM_EXTABLE(18b,100b)
29257 + _ASM_EXTABLE(19b,100b)
29258 + _ASM_EXTABLE(20b,100b)
29259 + _ASM_EXTABLE(21b,100b)
29260 + _ASM_EXTABLE(22b,100b)
29261 + _ASM_EXTABLE(23b,100b)
29262 + _ASM_EXTABLE(24b,100b)
29263 + _ASM_EXTABLE(25b,100b)
29264 + _ASM_EXTABLE(26b,100b)
29265 + _ASM_EXTABLE(27b,100b)
29266 + _ASM_EXTABLE(28b,100b)
29267 + _ASM_EXTABLE(29b,100b)
29268 + _ASM_EXTABLE(30b,100b)
29269 + _ASM_EXTABLE(31b,100b)
29270 + _ASM_EXTABLE(32b,100b)
29271 + _ASM_EXTABLE(33b,100b)
29272 + _ASM_EXTABLE(34b,100b)
29273 + _ASM_EXTABLE(35b,100b)
29274 + _ASM_EXTABLE(36b,100b)
29275 + _ASM_EXTABLE(37b,100b)
29276 + _ASM_EXTABLE(99b,101b)
29277 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29278 + : "1"(to), "2"(from), "0"(size)
29279 + : "eax", "edx", "memory");
29280 + return size;
29281 +}
29282 +
29283 +static unsigned long
29284 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29285 +{
29286 + int d0, d1;
29287 + __asm__ __volatile__(
29288 + " .align 2,0x90\n"
29289 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29290 + " cmpl $67, %0\n"
29291 + " jbe 3f\n"
29292 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29293 + " .align 2,0x90\n"
29294 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29295 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29296 + "5: movl %%eax, 0(%3)\n"
29297 + "6: movl %%edx, 4(%3)\n"
29298 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29299 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29300 + "9: movl %%eax, 8(%3)\n"
29301 + "10: movl %%edx, 12(%3)\n"
29302 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29303 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29304 + "13: movl %%eax, 16(%3)\n"
29305 + "14: movl %%edx, 20(%3)\n"
29306 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29307 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29308 + "17: movl %%eax, 24(%3)\n"
29309 + "18: movl %%edx, 28(%3)\n"
29310 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29311 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29312 + "21: movl %%eax, 32(%3)\n"
29313 + "22: movl %%edx, 36(%3)\n"
29314 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29315 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29316 + "25: movl %%eax, 40(%3)\n"
29317 + "26: movl %%edx, 44(%3)\n"
29318 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29319 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29320 + "29: movl %%eax, 48(%3)\n"
29321 + "30: movl %%edx, 52(%3)\n"
29322 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29323 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29324 + "33: movl %%eax, 56(%3)\n"
29325 + "34: movl %%edx, 60(%3)\n"
29326 + " addl $-64, %0\n"
29327 + " addl $64, %4\n"
29328 + " addl $64, %3\n"
29329 + " cmpl $63, %0\n"
29330 + " ja 1b\n"
29331 + "35: movl %0, %%eax\n"
29332 + " shrl $2, %0\n"
29333 + " andl $3, %%eax\n"
29334 + " cld\n"
29335 + "99: rep; "__copyuser_seg" movsl\n"
29336 + "36: movl %%eax, %0\n"
29337 + "37: rep; "__copyuser_seg" movsb\n"
29338 + "100:\n"
29339 ".section .fixup,\"ax\"\n"
29340 "101: lea 0(%%eax,%0,4),%0\n"
29341 " jmp 100b\n"
29342 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29343 int d0, d1;
29344 __asm__ __volatile__(
29345 " .align 2,0x90\n"
29346 - "0: movl 32(%4), %%eax\n"
29347 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29348 " cmpl $67, %0\n"
29349 " jbe 2f\n"
29350 - "1: movl 64(%4), %%eax\n"
29351 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29352 " .align 2,0x90\n"
29353 - "2: movl 0(%4), %%eax\n"
29354 - "21: movl 4(%4), %%edx\n"
29355 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29356 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29357 " movl %%eax, 0(%3)\n"
29358 " movl %%edx, 4(%3)\n"
29359 - "3: movl 8(%4), %%eax\n"
29360 - "31: movl 12(%4),%%edx\n"
29361 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29362 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29363 " movl %%eax, 8(%3)\n"
29364 " movl %%edx, 12(%3)\n"
29365 - "4: movl 16(%4), %%eax\n"
29366 - "41: movl 20(%4), %%edx\n"
29367 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29368 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29369 " movl %%eax, 16(%3)\n"
29370 " movl %%edx, 20(%3)\n"
29371 - "10: movl 24(%4), %%eax\n"
29372 - "51: movl 28(%4), %%edx\n"
29373 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29374 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29375 " movl %%eax, 24(%3)\n"
29376 " movl %%edx, 28(%3)\n"
29377 - "11: movl 32(%4), %%eax\n"
29378 - "61: movl 36(%4), %%edx\n"
29379 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29380 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29381 " movl %%eax, 32(%3)\n"
29382 " movl %%edx, 36(%3)\n"
29383 - "12: movl 40(%4), %%eax\n"
29384 - "71: movl 44(%4), %%edx\n"
29385 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29386 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29387 " movl %%eax, 40(%3)\n"
29388 " movl %%edx, 44(%3)\n"
29389 - "13: movl 48(%4), %%eax\n"
29390 - "81: movl 52(%4), %%edx\n"
29391 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29392 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29393 " movl %%eax, 48(%3)\n"
29394 " movl %%edx, 52(%3)\n"
29395 - "14: movl 56(%4), %%eax\n"
29396 - "91: movl 60(%4), %%edx\n"
29397 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29398 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29399 " movl %%eax, 56(%3)\n"
29400 " movl %%edx, 60(%3)\n"
29401 " addl $-64, %0\n"
29402 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29403 " shrl $2, %0\n"
29404 " andl $3, %%eax\n"
29405 " cld\n"
29406 - "6: rep; movsl\n"
29407 + "6: rep; "__copyuser_seg" movsl\n"
29408 " movl %%eax,%0\n"
29409 - "7: rep; movsb\n"
29410 + "7: rep; "__copyuser_seg" movsb\n"
29411 "8:\n"
29412 ".section .fixup,\"ax\"\n"
29413 "9: lea 0(%%eax,%0,4),%0\n"
29414 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29415
29416 __asm__ __volatile__(
29417 " .align 2,0x90\n"
29418 - "0: movl 32(%4), %%eax\n"
29419 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29420 " cmpl $67, %0\n"
29421 " jbe 2f\n"
29422 - "1: movl 64(%4), %%eax\n"
29423 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29424 " .align 2,0x90\n"
29425 - "2: movl 0(%4), %%eax\n"
29426 - "21: movl 4(%4), %%edx\n"
29427 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29428 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29429 " movnti %%eax, 0(%3)\n"
29430 " movnti %%edx, 4(%3)\n"
29431 - "3: movl 8(%4), %%eax\n"
29432 - "31: movl 12(%4),%%edx\n"
29433 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29434 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29435 " movnti %%eax, 8(%3)\n"
29436 " movnti %%edx, 12(%3)\n"
29437 - "4: movl 16(%4), %%eax\n"
29438 - "41: movl 20(%4), %%edx\n"
29439 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29440 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29441 " movnti %%eax, 16(%3)\n"
29442 " movnti %%edx, 20(%3)\n"
29443 - "10: movl 24(%4), %%eax\n"
29444 - "51: movl 28(%4), %%edx\n"
29445 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29446 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29447 " movnti %%eax, 24(%3)\n"
29448 " movnti %%edx, 28(%3)\n"
29449 - "11: movl 32(%4), %%eax\n"
29450 - "61: movl 36(%4), %%edx\n"
29451 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29452 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29453 " movnti %%eax, 32(%3)\n"
29454 " movnti %%edx, 36(%3)\n"
29455 - "12: movl 40(%4), %%eax\n"
29456 - "71: movl 44(%4), %%edx\n"
29457 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29458 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29459 " movnti %%eax, 40(%3)\n"
29460 " movnti %%edx, 44(%3)\n"
29461 - "13: movl 48(%4), %%eax\n"
29462 - "81: movl 52(%4), %%edx\n"
29463 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29464 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29465 " movnti %%eax, 48(%3)\n"
29466 " movnti %%edx, 52(%3)\n"
29467 - "14: movl 56(%4), %%eax\n"
29468 - "91: movl 60(%4), %%edx\n"
29469 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29470 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29471 " movnti %%eax, 56(%3)\n"
29472 " movnti %%edx, 60(%3)\n"
29473 " addl $-64, %0\n"
29474 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29475 " shrl $2, %0\n"
29476 " andl $3, %%eax\n"
29477 " cld\n"
29478 - "6: rep; movsl\n"
29479 + "6: rep; "__copyuser_seg" movsl\n"
29480 " movl %%eax,%0\n"
29481 - "7: rep; movsb\n"
29482 + "7: rep; "__copyuser_seg" movsb\n"
29483 "8:\n"
29484 ".section .fixup,\"ax\"\n"
29485 "9: lea 0(%%eax,%0,4),%0\n"
29486 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
29487
29488 __asm__ __volatile__(
29489 " .align 2,0x90\n"
29490 - "0: movl 32(%4), %%eax\n"
29491 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29492 " cmpl $67, %0\n"
29493 " jbe 2f\n"
29494 - "1: movl 64(%4), %%eax\n"
29495 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29496 " .align 2,0x90\n"
29497 - "2: movl 0(%4), %%eax\n"
29498 - "21: movl 4(%4), %%edx\n"
29499 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29500 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29501 " movnti %%eax, 0(%3)\n"
29502 " movnti %%edx, 4(%3)\n"
29503 - "3: movl 8(%4), %%eax\n"
29504 - "31: movl 12(%4),%%edx\n"
29505 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29506 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29507 " movnti %%eax, 8(%3)\n"
29508 " movnti %%edx, 12(%3)\n"
29509 - "4: movl 16(%4), %%eax\n"
29510 - "41: movl 20(%4), %%edx\n"
29511 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29512 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29513 " movnti %%eax, 16(%3)\n"
29514 " movnti %%edx, 20(%3)\n"
29515 - "10: movl 24(%4), %%eax\n"
29516 - "51: movl 28(%4), %%edx\n"
29517 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29518 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29519 " movnti %%eax, 24(%3)\n"
29520 " movnti %%edx, 28(%3)\n"
29521 - "11: movl 32(%4), %%eax\n"
29522 - "61: movl 36(%4), %%edx\n"
29523 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29524 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29525 " movnti %%eax, 32(%3)\n"
29526 " movnti %%edx, 36(%3)\n"
29527 - "12: movl 40(%4), %%eax\n"
29528 - "71: movl 44(%4), %%edx\n"
29529 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29530 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29531 " movnti %%eax, 40(%3)\n"
29532 " movnti %%edx, 44(%3)\n"
29533 - "13: movl 48(%4), %%eax\n"
29534 - "81: movl 52(%4), %%edx\n"
29535 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29536 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29537 " movnti %%eax, 48(%3)\n"
29538 " movnti %%edx, 52(%3)\n"
29539 - "14: movl 56(%4), %%eax\n"
29540 - "91: movl 60(%4), %%edx\n"
29541 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29542 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29543 " movnti %%eax, 56(%3)\n"
29544 " movnti %%edx, 60(%3)\n"
29545 " addl $-64, %0\n"
29546 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29547 " shrl $2, %0\n"
29548 " andl $3, %%eax\n"
29549 " cld\n"
29550 - "6: rep; movsl\n"
29551 + "6: rep; "__copyuser_seg" movsl\n"
29552 " movl %%eax,%0\n"
29553 - "7: rep; movsb\n"
29554 + "7: rep; "__copyuser_seg" movsb\n"
29555 "8:\n"
29556 ".section .fixup,\"ax\"\n"
29557 "9: lea 0(%%eax,%0,4),%0\n"
29558 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29559 */
29560 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29561 unsigned long size);
29562 -unsigned long __copy_user_intel(void __user *to, const void *from,
29563 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29564 + unsigned long size);
29565 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29566 unsigned long size);
29567 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29568 const void __user *from, unsigned long size);
29569 #endif /* CONFIG_X86_INTEL_USERCOPY */
29570
29571 /* Generic arbitrary sized copy. */
29572 -#define __copy_user(to, from, size) \
29573 +#define __copy_user(to, from, size, prefix, set, restore) \
29574 do { \
29575 int __d0, __d1, __d2; \
29576 __asm__ __volatile__( \
29577 + set \
29578 " cmp $7,%0\n" \
29579 " jbe 1f\n" \
29580 " movl %1,%0\n" \
29581 " negl %0\n" \
29582 " andl $7,%0\n" \
29583 " subl %0,%3\n" \
29584 - "4: rep; movsb\n" \
29585 + "4: rep; "prefix"movsb\n" \
29586 " movl %3,%0\n" \
29587 " shrl $2,%0\n" \
29588 " andl $3,%3\n" \
29589 " .align 2,0x90\n" \
29590 - "0: rep; movsl\n" \
29591 + "0: rep; "prefix"movsl\n" \
29592 " movl %3,%0\n" \
29593 - "1: rep; movsb\n" \
29594 + "1: rep; "prefix"movsb\n" \
29595 "2:\n" \
29596 + restore \
29597 ".section .fixup,\"ax\"\n" \
29598 "5: addl %3,%0\n" \
29599 " jmp 2b\n" \
29600 @@ -538,14 +650,14 @@ do { \
29601 " negl %0\n" \
29602 " andl $7,%0\n" \
29603 " subl %0,%3\n" \
29604 - "4: rep; movsb\n" \
29605 + "4: rep; "__copyuser_seg"movsb\n" \
29606 " movl %3,%0\n" \
29607 " shrl $2,%0\n" \
29608 " andl $3,%3\n" \
29609 " .align 2,0x90\n" \
29610 - "0: rep; movsl\n" \
29611 + "0: rep; "__copyuser_seg"movsl\n" \
29612 " movl %3,%0\n" \
29613 - "1: rep; movsb\n" \
29614 + "1: rep; "__copyuser_seg"movsb\n" \
29615 "2:\n" \
29616 ".section .fixup,\"ax\"\n" \
29617 "5: addl %3,%0\n" \
29618 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29619 {
29620 stac();
29621 if (movsl_is_ok(to, from, n))
29622 - __copy_user(to, from, n);
29623 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29624 else
29625 - n = __copy_user_intel(to, from, n);
29626 + n = __generic_copy_to_user_intel(to, from, n);
29627 clac();
29628 return n;
29629 }
29630 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29631 {
29632 stac();
29633 if (movsl_is_ok(to, from, n))
29634 - __copy_user(to, from, n);
29635 + __copy_user(to, from, n, __copyuser_seg, "", "");
29636 else
29637 - n = __copy_user_intel((void __user *)to,
29638 - (const void *)from, n);
29639 + n = __generic_copy_from_user_intel(to, from, n);
29640 clac();
29641 return n;
29642 }
29643 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29644 if (n > 64 && cpu_has_xmm2)
29645 n = __copy_user_intel_nocache(to, from, n);
29646 else
29647 - __copy_user(to, from, n);
29648 + __copy_user(to, from, n, __copyuser_seg, "", "");
29649 #else
29650 - __copy_user(to, from, n);
29651 + __copy_user(to, from, n, __copyuser_seg, "", "");
29652 #endif
29653 clac();
29654 return n;
29655 }
29656 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29657
29658 -/**
29659 - * copy_to_user: - Copy a block of data into user space.
29660 - * @to: Destination address, in user space.
29661 - * @from: Source address, in kernel space.
29662 - * @n: Number of bytes to copy.
29663 - *
29664 - * Context: User context only. This function may sleep.
29665 - *
29666 - * Copy data from kernel space to user space.
29667 - *
29668 - * Returns number of bytes that could not be copied.
29669 - * On success, this will be zero.
29670 - */
29671 -unsigned long
29672 -copy_to_user(void __user *to, const void *from, unsigned long n)
29673 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29674 +void __set_fs(mm_segment_t x)
29675 {
29676 - if (access_ok(VERIFY_WRITE, to, n))
29677 - n = __copy_to_user(to, from, n);
29678 - return n;
29679 + switch (x.seg) {
29680 + case 0:
29681 + loadsegment(gs, 0);
29682 + break;
29683 + case TASK_SIZE_MAX:
29684 + loadsegment(gs, __USER_DS);
29685 + break;
29686 + case -1UL:
29687 + loadsegment(gs, __KERNEL_DS);
29688 + break;
29689 + default:
29690 + BUG();
29691 + }
29692 }
29693 -EXPORT_SYMBOL(copy_to_user);
29694 +EXPORT_SYMBOL(__set_fs);
29695
29696 -/**
29697 - * copy_from_user: - Copy a block of data from user space.
29698 - * @to: Destination address, in kernel space.
29699 - * @from: Source address, in user space.
29700 - * @n: Number of bytes to copy.
29701 - *
29702 - * Context: User context only. This function may sleep.
29703 - *
29704 - * Copy data from user space to kernel space.
29705 - *
29706 - * Returns number of bytes that could not be copied.
29707 - * On success, this will be zero.
29708 - *
29709 - * If some data could not be copied, this function will pad the copied
29710 - * data to the requested size using zero bytes.
29711 - */
29712 -unsigned long
29713 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29714 +void set_fs(mm_segment_t x)
29715 {
29716 - if (access_ok(VERIFY_READ, from, n))
29717 - n = __copy_from_user(to, from, n);
29718 - else
29719 - memset(to, 0, n);
29720 - return n;
29721 + current_thread_info()->addr_limit = x;
29722 + __set_fs(x);
29723 }
29724 -EXPORT_SYMBOL(_copy_from_user);
29725 +EXPORT_SYMBOL(set_fs);
29726 +#endif
29727 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29728 index c905e89..01ab928 100644
29729 --- a/arch/x86/lib/usercopy_64.c
29730 +++ b/arch/x86/lib/usercopy_64.c
29731 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29732 might_fault();
29733 /* no memory constraint because it doesn't change any memory gcc knows
29734 about */
29735 + pax_open_userland();
29736 stac();
29737 asm volatile(
29738 " testq %[size8],%[size8]\n"
29739 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29740 _ASM_EXTABLE(0b,3b)
29741 _ASM_EXTABLE(1b,2b)
29742 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29743 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29744 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29745 [zero] "r" (0UL), [eight] "r" (8UL));
29746 clac();
29747 + pax_close_userland();
29748 return size;
29749 }
29750 EXPORT_SYMBOL(__clear_user);
29751 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29752 }
29753 EXPORT_SYMBOL(clear_user);
29754
29755 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29756 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29757 {
29758 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29759 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29760 - }
29761 - return len;
29762 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29763 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29764 + return len;
29765 }
29766 EXPORT_SYMBOL(copy_in_user);
29767
29768 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29769 * it is not necessary to optimize tail handling.
29770 */
29771 __visible unsigned long
29772 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29773 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29774 {
29775 char c;
29776 unsigned zero_len;
29777
29778 + clac();
29779 + pax_close_userland();
29780 for (; len; --len, to++) {
29781 if (__get_user_nocheck(c, from++, sizeof(char)))
29782 break;
29783 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29784 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29785 if (__put_user_nocheck(c, to++, sizeof(char)))
29786 break;
29787 - clac();
29788 return len;
29789 }
29790 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29791 index 23d8e5f..9ccc13a 100644
29792 --- a/arch/x86/mm/Makefile
29793 +++ b/arch/x86/mm/Makefile
29794 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29795 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29796
29797 obj-$(CONFIG_MEMTEST) += memtest.o
29798 +
29799 +quote:="
29800 +obj-$(CONFIG_X86_64) += uderef_64.o
29801 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29802 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29803 index 903ec1e..c4166b2 100644
29804 --- a/arch/x86/mm/extable.c
29805 +++ b/arch/x86/mm/extable.c
29806 @@ -6,12 +6,24 @@
29807 static inline unsigned long
29808 ex_insn_addr(const struct exception_table_entry *x)
29809 {
29810 - return (unsigned long)&x->insn + x->insn;
29811 + unsigned long reloc = 0;
29812 +
29813 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29814 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29815 +#endif
29816 +
29817 + return (unsigned long)&x->insn + x->insn + reloc;
29818 }
29819 static inline unsigned long
29820 ex_fixup_addr(const struct exception_table_entry *x)
29821 {
29822 - return (unsigned long)&x->fixup + x->fixup;
29823 + unsigned long reloc = 0;
29824 +
29825 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29826 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29827 +#endif
29828 +
29829 + return (unsigned long)&x->fixup + x->fixup + reloc;
29830 }
29831
29832 int fixup_exception(struct pt_regs *regs)
29833 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29834 unsigned long new_ip;
29835
29836 #ifdef CONFIG_PNPBIOS
29837 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29838 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29839 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29840 extern u32 pnp_bios_is_utter_crap;
29841 pnp_bios_is_utter_crap = 1;
29842 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29843 i += 4;
29844 p->fixup -= i;
29845 i += 4;
29846 +
29847 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29848 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29849 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29850 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29851 +#endif
29852 +
29853 }
29854 }
29855
29856 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29857 index 3aaeffc..42ea9fb 100644
29858 --- a/arch/x86/mm/fault.c
29859 +++ b/arch/x86/mm/fault.c
29860 @@ -14,11 +14,18 @@
29861 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29862 #include <linux/prefetch.h> /* prefetchw */
29863 #include <linux/context_tracking.h> /* exception_enter(), ... */
29864 +#include <linux/unistd.h>
29865 +#include <linux/compiler.h>
29866
29867 #include <asm/traps.h> /* dotraplinkage, ... */
29868 #include <asm/pgalloc.h> /* pgd_*(), ... */
29869 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29870 #include <asm/fixmap.h> /* VSYSCALL_START */
29871 +#include <asm/tlbflush.h>
29872 +
29873 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29874 +#include <asm/stacktrace.h>
29875 +#endif
29876
29877 /*
29878 * Page fault error code bits:
29879 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29880 int ret = 0;
29881
29882 /* kprobe_running() needs smp_processor_id() */
29883 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29884 + if (kprobes_built_in() && !user_mode(regs)) {
29885 preempt_disable();
29886 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29887 ret = 1;
29888 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29889 return !instr_lo || (instr_lo>>1) == 1;
29890 case 0x00:
29891 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29892 - if (probe_kernel_address(instr, opcode))
29893 + if (user_mode(regs)) {
29894 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29895 + return 0;
29896 + } else if (probe_kernel_address(instr, opcode))
29897 return 0;
29898
29899 *prefetch = (instr_lo == 0xF) &&
29900 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29901 while (instr < max_instr) {
29902 unsigned char opcode;
29903
29904 - if (probe_kernel_address(instr, opcode))
29905 + if (user_mode(regs)) {
29906 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29907 + break;
29908 + } else if (probe_kernel_address(instr, opcode))
29909 break;
29910
29911 instr++;
29912 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29913 force_sig_info(si_signo, &info, tsk);
29914 }
29915
29916 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29917 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29918 +#endif
29919 +
29920 +#ifdef CONFIG_PAX_EMUTRAMP
29921 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29922 +#endif
29923 +
29924 +#ifdef CONFIG_PAX_PAGEEXEC
29925 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29926 +{
29927 + pgd_t *pgd;
29928 + pud_t *pud;
29929 + pmd_t *pmd;
29930 +
29931 + pgd = pgd_offset(mm, address);
29932 + if (!pgd_present(*pgd))
29933 + return NULL;
29934 + pud = pud_offset(pgd, address);
29935 + if (!pud_present(*pud))
29936 + return NULL;
29937 + pmd = pmd_offset(pud, address);
29938 + if (!pmd_present(*pmd))
29939 + return NULL;
29940 + return pmd;
29941 +}
29942 +#endif
29943 +
29944 DEFINE_SPINLOCK(pgd_lock);
29945 LIST_HEAD(pgd_list);
29946
29947 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29948 for (address = VMALLOC_START & PMD_MASK;
29949 address >= TASK_SIZE && address < FIXADDR_TOP;
29950 address += PMD_SIZE) {
29951 +
29952 +#ifdef CONFIG_PAX_PER_CPU_PGD
29953 + unsigned long cpu;
29954 +#else
29955 struct page *page;
29956 +#endif
29957
29958 spin_lock(&pgd_lock);
29959 +
29960 +#ifdef CONFIG_PAX_PER_CPU_PGD
29961 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29962 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29963 + pmd_t *ret;
29964 +
29965 + ret = vmalloc_sync_one(pgd, address);
29966 + if (!ret)
29967 + break;
29968 + pgd = get_cpu_pgd(cpu, kernel);
29969 +#else
29970 list_for_each_entry(page, &pgd_list, lru) {
29971 + pgd_t *pgd;
29972 spinlock_t *pgt_lock;
29973 pmd_t *ret;
29974
29975 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29976 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29977
29978 spin_lock(pgt_lock);
29979 - ret = vmalloc_sync_one(page_address(page), address);
29980 + pgd = page_address(page);
29981 +#endif
29982 +
29983 + ret = vmalloc_sync_one(pgd, address);
29984 +
29985 +#ifndef CONFIG_PAX_PER_CPU_PGD
29986 spin_unlock(pgt_lock);
29987 +#endif
29988
29989 if (!ret)
29990 break;
29991 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29992 * an interrupt in the middle of a task switch..
29993 */
29994 pgd_paddr = read_cr3();
29995 +
29996 +#ifdef CONFIG_PAX_PER_CPU_PGD
29997 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29998 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29999 +#endif
30000 +
30001 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30002 if (!pmd_k)
30003 return -1;
30004 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30005 * happen within a race in page table update. In the later
30006 * case just flush:
30007 */
30008 - pgd = pgd_offset(current->active_mm, address);
30009 +
30010 pgd_ref = pgd_offset_k(address);
30011 if (pgd_none(*pgd_ref))
30012 return -1;
30013
30014 +#ifdef CONFIG_PAX_PER_CPU_PGD
30015 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30016 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30017 + if (pgd_none(*pgd)) {
30018 + set_pgd(pgd, *pgd_ref);
30019 + arch_flush_lazy_mmu_mode();
30020 + } else {
30021 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30022 + }
30023 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30024 +#else
30025 + pgd = pgd_offset(current->active_mm, address);
30026 +#endif
30027 +
30028 if (pgd_none(*pgd)) {
30029 set_pgd(pgd, *pgd_ref);
30030 arch_flush_lazy_mmu_mode();
30031 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30032 static int is_errata100(struct pt_regs *regs, unsigned long address)
30033 {
30034 #ifdef CONFIG_X86_64
30035 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30036 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30037 return 1;
30038 #endif
30039 return 0;
30040 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30041 }
30042
30043 static const char nx_warning[] = KERN_CRIT
30044 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30045 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30046
30047 static void
30048 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30049 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30050 if (!oops_may_print())
30051 return;
30052
30053 - if (error_code & PF_INSTR) {
30054 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30055 unsigned int level;
30056
30057 pte_t *pte = lookup_address(address, &level);
30058
30059 if (pte && pte_present(*pte) && !pte_exec(*pte))
30060 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30061 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30062 }
30063
30064 +#ifdef CONFIG_PAX_KERNEXEC
30065 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30066 + if (current->signal->curr_ip)
30067 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30068 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30069 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30070 + else
30071 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30072 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30073 + }
30074 +#endif
30075 +
30076 printk(KERN_ALERT "BUG: unable to handle kernel ");
30077 if (address < PAGE_SIZE)
30078 printk(KERN_CONT "NULL pointer dereference");
30079 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30080 return;
30081 }
30082 #endif
30083 +
30084 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30085 + if (pax_is_fetch_fault(regs, error_code, address)) {
30086 +
30087 +#ifdef CONFIG_PAX_EMUTRAMP
30088 + switch (pax_handle_fetch_fault(regs)) {
30089 + case 2:
30090 + return;
30091 + }
30092 +#endif
30093 +
30094 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30095 + do_group_exit(SIGKILL);
30096 + }
30097 +#endif
30098 +
30099 /* Kernel addresses are always protection faults: */
30100 if (address >= TASK_SIZE)
30101 error_code |= PF_PROT;
30102 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30103 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30104 printk(KERN_ERR
30105 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30106 - tsk->comm, tsk->pid, address);
30107 + tsk->comm, task_pid_nr(tsk), address);
30108 code = BUS_MCEERR_AR;
30109 }
30110 #endif
30111 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30112 return 1;
30113 }
30114
30115 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30116 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30117 +{
30118 + pte_t *pte;
30119 + pmd_t *pmd;
30120 + spinlock_t *ptl;
30121 + unsigned char pte_mask;
30122 +
30123 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30124 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30125 + return 0;
30126 +
30127 + /* PaX: it's our fault, let's handle it if we can */
30128 +
30129 + /* PaX: take a look at read faults before acquiring any locks */
30130 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30131 + /* instruction fetch attempt from a protected page in user mode */
30132 + up_read(&mm->mmap_sem);
30133 +
30134 +#ifdef CONFIG_PAX_EMUTRAMP
30135 + switch (pax_handle_fetch_fault(regs)) {
30136 + case 2:
30137 + return 1;
30138 + }
30139 +#endif
30140 +
30141 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30142 + do_group_exit(SIGKILL);
30143 + }
30144 +
30145 + pmd = pax_get_pmd(mm, address);
30146 + if (unlikely(!pmd))
30147 + return 0;
30148 +
30149 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30150 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30151 + pte_unmap_unlock(pte, ptl);
30152 + return 0;
30153 + }
30154 +
30155 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30156 + /* write attempt to a protected page in user mode */
30157 + pte_unmap_unlock(pte, ptl);
30158 + return 0;
30159 + }
30160 +
30161 +#ifdef CONFIG_SMP
30162 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30163 +#else
30164 + if (likely(address > get_limit(regs->cs)))
30165 +#endif
30166 + {
30167 + set_pte(pte, pte_mkread(*pte));
30168 + __flush_tlb_one(address);
30169 + pte_unmap_unlock(pte, ptl);
30170 + up_read(&mm->mmap_sem);
30171 + return 1;
30172 + }
30173 +
30174 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30175 +
30176 + /*
30177 + * PaX: fill DTLB with user rights and retry
30178 + */
30179 + __asm__ __volatile__ (
30180 + "orb %2,(%1)\n"
30181 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30182 +/*
30183 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30184 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30185 + * page fault when examined during a TLB load attempt. this is true not only
30186 + * for PTEs holding a non-present entry but also present entries that will
30187 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30188 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30189 + * for our target pages since their PTEs are simply not in the TLBs at all.
30190 +
30191 + * the best thing in omitting it is that we gain around 15-20% speed in the
30192 + * fast path of the page fault handler and can get rid of tracing since we
30193 + * can no longer flush unintended entries.
30194 + */
30195 + "invlpg (%0)\n"
30196 +#endif
30197 + __copyuser_seg"testb $0,(%0)\n"
30198 + "xorb %3,(%1)\n"
30199 + :
30200 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30201 + : "memory", "cc");
30202 + pte_unmap_unlock(pte, ptl);
30203 + up_read(&mm->mmap_sem);
30204 + return 1;
30205 +}
30206 +#endif
30207 +
30208 /*
30209 * Handle a spurious fault caused by a stale TLB entry.
30210 *
30211 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30212 static inline int
30213 access_error(unsigned long error_code, struct vm_area_struct *vma)
30214 {
30215 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30216 + return 1;
30217 +
30218 if (error_code & PF_WRITE) {
30219 /* write, present and write, not present: */
30220 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30221 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30222 if (error_code & PF_USER)
30223 return false;
30224
30225 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30226 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30227 return false;
30228
30229 return true;
30230 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30231 /* Get the faulting address: */
30232 address = read_cr2();
30233
30234 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30235 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30236 + if (!search_exception_tables(regs->ip)) {
30237 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30238 + bad_area_nosemaphore(regs, error_code, address);
30239 + return;
30240 + }
30241 + if (address < pax_user_shadow_base) {
30242 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30243 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30244 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30245 + } else
30246 + address -= pax_user_shadow_base;
30247 + }
30248 +#endif
30249 +
30250 /*
30251 * Detect and handle instructions that would cause a page fault for
30252 * both a tracked kernel page and a userspace page.
30253 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30254 * User-mode registers count as a user access even for any
30255 * potential system fault or CPU buglet:
30256 */
30257 - if (user_mode_vm(regs)) {
30258 + if (user_mode(regs)) {
30259 local_irq_enable();
30260 error_code |= PF_USER;
30261 flags |= FAULT_FLAG_USER;
30262 @@ -1135,6 +1359,11 @@ retry:
30263 might_sleep();
30264 }
30265
30266 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30267 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30268 + return;
30269 +#endif
30270 +
30271 vma = find_vma(mm, address);
30272 if (unlikely(!vma)) {
30273 bad_area(regs, error_code, address);
30274 @@ -1146,18 +1375,24 @@ retry:
30275 bad_area(regs, error_code, address);
30276 return;
30277 }
30278 - if (error_code & PF_USER) {
30279 - /*
30280 - * Accessing the stack below %sp is always a bug.
30281 - * The large cushion allows instructions like enter
30282 - * and pusha to work. ("enter $65535, $31" pushes
30283 - * 32 pointers and then decrements %sp by 65535.)
30284 - */
30285 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30286 - bad_area(regs, error_code, address);
30287 - return;
30288 - }
30289 + /*
30290 + * Accessing the stack below %sp is always a bug.
30291 + * The large cushion allows instructions like enter
30292 + * and pusha to work. ("enter $65535, $31" pushes
30293 + * 32 pointers and then decrements %sp by 65535.)
30294 + */
30295 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30296 + bad_area(regs, error_code, address);
30297 + return;
30298 }
30299 +
30300 +#ifdef CONFIG_PAX_SEGMEXEC
30301 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30302 + bad_area(regs, error_code, address);
30303 + return;
30304 + }
30305 +#endif
30306 +
30307 if (unlikely(expand_stack(vma, address))) {
30308 bad_area(regs, error_code, address);
30309 return;
30310 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30311 __do_page_fault(regs, error_code);
30312 exception_exit(prev_state);
30313 }
30314 +
30315 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30316 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30317 +{
30318 + struct mm_struct *mm = current->mm;
30319 + unsigned long ip = regs->ip;
30320 +
30321 + if (v8086_mode(regs))
30322 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30323 +
30324 +#ifdef CONFIG_PAX_PAGEEXEC
30325 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30326 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30327 + return true;
30328 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30329 + return true;
30330 + return false;
30331 + }
30332 +#endif
30333 +
30334 +#ifdef CONFIG_PAX_SEGMEXEC
30335 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30336 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30337 + return true;
30338 + return false;
30339 + }
30340 +#endif
30341 +
30342 + return false;
30343 +}
30344 +#endif
30345 +
30346 +#ifdef CONFIG_PAX_EMUTRAMP
30347 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30348 +{
30349 + int err;
30350 +
30351 + do { /* PaX: libffi trampoline emulation */
30352 + unsigned char mov, jmp;
30353 + unsigned int addr1, addr2;
30354 +
30355 +#ifdef CONFIG_X86_64
30356 + if ((regs->ip + 9) >> 32)
30357 + break;
30358 +#endif
30359 +
30360 + err = get_user(mov, (unsigned char __user *)regs->ip);
30361 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30362 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30363 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30364 +
30365 + if (err)
30366 + break;
30367 +
30368 + if (mov == 0xB8 && jmp == 0xE9) {
30369 + regs->ax = addr1;
30370 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30371 + return 2;
30372 + }
30373 + } while (0);
30374 +
30375 + do { /* PaX: gcc trampoline emulation #1 */
30376 + unsigned char mov1, mov2;
30377 + unsigned short jmp;
30378 + unsigned int addr1, addr2;
30379 +
30380 +#ifdef CONFIG_X86_64
30381 + if ((regs->ip + 11) >> 32)
30382 + break;
30383 +#endif
30384 +
30385 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30386 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30387 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30388 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30389 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30390 +
30391 + if (err)
30392 + break;
30393 +
30394 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30395 + regs->cx = addr1;
30396 + regs->ax = addr2;
30397 + regs->ip = addr2;
30398 + return 2;
30399 + }
30400 + } while (0);
30401 +
30402 + do { /* PaX: gcc trampoline emulation #2 */
30403 + unsigned char mov, jmp;
30404 + unsigned int addr1, addr2;
30405 +
30406 +#ifdef CONFIG_X86_64
30407 + if ((regs->ip + 9) >> 32)
30408 + break;
30409 +#endif
30410 +
30411 + err = get_user(mov, (unsigned char __user *)regs->ip);
30412 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30413 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30414 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30415 +
30416 + if (err)
30417 + break;
30418 +
30419 + if (mov == 0xB9 && jmp == 0xE9) {
30420 + regs->cx = addr1;
30421 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30422 + return 2;
30423 + }
30424 + } while (0);
30425 +
30426 + return 1; /* PaX in action */
30427 +}
30428 +
30429 +#ifdef CONFIG_X86_64
30430 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30431 +{
30432 + int err;
30433 +
30434 + do { /* PaX: libffi trampoline emulation */
30435 + unsigned short mov1, mov2, jmp1;
30436 + unsigned char stcclc, jmp2;
30437 + unsigned long addr1, addr2;
30438 +
30439 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30440 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30441 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30442 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30443 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30444 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30445 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30446 +
30447 + if (err)
30448 + break;
30449 +
30450 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30451 + regs->r11 = addr1;
30452 + regs->r10 = addr2;
30453 + if (stcclc == 0xF8)
30454 + regs->flags &= ~X86_EFLAGS_CF;
30455 + else
30456 + regs->flags |= X86_EFLAGS_CF;
30457 + regs->ip = addr1;
30458 + return 2;
30459 + }
30460 + } while (0);
30461 +
30462 + do { /* PaX: gcc trampoline emulation #1 */
30463 + unsigned short mov1, mov2, jmp1;
30464 + unsigned char jmp2;
30465 + unsigned int addr1;
30466 + unsigned long addr2;
30467 +
30468 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30469 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30470 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30471 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30472 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30473 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30474 +
30475 + if (err)
30476 + break;
30477 +
30478 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30479 + regs->r11 = addr1;
30480 + regs->r10 = addr2;
30481 + regs->ip = addr1;
30482 + return 2;
30483 + }
30484 + } while (0);
30485 +
30486 + do { /* PaX: gcc trampoline emulation #2 */
30487 + unsigned short mov1, mov2, jmp1;
30488 + unsigned char jmp2;
30489 + unsigned long addr1, addr2;
30490 +
30491 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30492 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30493 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30494 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30495 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30496 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30497 +
30498 + if (err)
30499 + break;
30500 +
30501 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30502 + regs->r11 = addr1;
30503 + regs->r10 = addr2;
30504 + regs->ip = addr1;
30505 + return 2;
30506 + }
30507 + } while (0);
30508 +
30509 + return 1; /* PaX in action */
30510 +}
30511 +#endif
30512 +
30513 +/*
30514 + * PaX: decide what to do with offenders (regs->ip = fault address)
30515 + *
30516 + * returns 1 when task should be killed
30517 + * 2 when gcc trampoline was detected
30518 + */
30519 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30520 +{
30521 + if (v8086_mode(regs))
30522 + return 1;
30523 +
30524 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30525 + return 1;
30526 +
30527 +#ifdef CONFIG_X86_32
30528 + return pax_handle_fetch_fault_32(regs);
30529 +#else
30530 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30531 + return pax_handle_fetch_fault_32(regs);
30532 + else
30533 + return pax_handle_fetch_fault_64(regs);
30534 +#endif
30535 +}
30536 +#endif
30537 +
30538 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30539 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30540 +{
30541 + long i;
30542 +
30543 + printk(KERN_ERR "PAX: bytes at PC: ");
30544 + for (i = 0; i < 20; i++) {
30545 + unsigned char c;
30546 + if (get_user(c, (unsigned char __force_user *)pc+i))
30547 + printk(KERN_CONT "?? ");
30548 + else
30549 + printk(KERN_CONT "%02x ", c);
30550 + }
30551 + printk("\n");
30552 +
30553 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30554 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30555 + unsigned long c;
30556 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30557 +#ifdef CONFIG_X86_32
30558 + printk(KERN_CONT "???????? ");
30559 +#else
30560 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30561 + printk(KERN_CONT "???????? ???????? ");
30562 + else
30563 + printk(KERN_CONT "???????????????? ");
30564 +#endif
30565 + } else {
30566 +#ifdef CONFIG_X86_64
30567 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30568 + printk(KERN_CONT "%08x ", (unsigned int)c);
30569 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30570 + } else
30571 +#endif
30572 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30573 + }
30574 + }
30575 + printk("\n");
30576 +}
30577 +#endif
30578 +
30579 +/**
30580 + * probe_kernel_write(): safely attempt to write to a location
30581 + * @dst: address to write to
30582 + * @src: pointer to the data that shall be written
30583 + * @size: size of the data chunk
30584 + *
30585 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30586 + * happens, handle that and return -EFAULT.
30587 + */
30588 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30589 +{
30590 + long ret;
30591 + mm_segment_t old_fs = get_fs();
30592 +
30593 + set_fs(KERNEL_DS);
30594 + pagefault_disable();
30595 + pax_open_kernel();
30596 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30597 + pax_close_kernel();
30598 + pagefault_enable();
30599 + set_fs(old_fs);
30600 +
30601 + return ret ? -EFAULT : 0;
30602 +}
30603 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30604 index dd74e46..7d26398 100644
30605 --- a/arch/x86/mm/gup.c
30606 +++ b/arch/x86/mm/gup.c
30607 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30608 addr = start;
30609 len = (unsigned long) nr_pages << PAGE_SHIFT;
30610 end = start + len;
30611 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30612 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30613 (void __user *)start, len)))
30614 return 0;
30615
30616 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30617 index 4500142..53a363c 100644
30618 --- a/arch/x86/mm/highmem_32.c
30619 +++ b/arch/x86/mm/highmem_32.c
30620 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30621 idx = type + KM_TYPE_NR*smp_processor_id();
30622 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30623 BUG_ON(!pte_none(*(kmap_pte-idx)));
30624 +
30625 + pax_open_kernel();
30626 set_pte(kmap_pte-idx, mk_pte(page, prot));
30627 + pax_close_kernel();
30628 +
30629 arch_flush_lazy_mmu_mode();
30630
30631 return (void *)vaddr;
30632 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30633 index 9d980d8..6bbfacb 100644
30634 --- a/arch/x86/mm/hugetlbpage.c
30635 +++ b/arch/x86/mm/hugetlbpage.c
30636 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
30637 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30638 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30639 unsigned long addr, unsigned long len,
30640 - unsigned long pgoff, unsigned long flags)
30641 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30642 {
30643 struct hstate *h = hstate_file(file);
30644 struct vm_unmapped_area_info info;
30645 -
30646 +
30647 info.flags = 0;
30648 info.length = len;
30649 info.low_limit = TASK_UNMAPPED_BASE;
30650 +
30651 +#ifdef CONFIG_PAX_RANDMMAP
30652 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30653 + info.low_limit += current->mm->delta_mmap;
30654 +#endif
30655 +
30656 info.high_limit = TASK_SIZE;
30657 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30658 info.align_offset = 0;
30659 + info.threadstack_offset = offset;
30660 return vm_unmapped_area(&info);
30661 }
30662
30663 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30664 unsigned long addr0, unsigned long len,
30665 - unsigned long pgoff, unsigned long flags)
30666 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30667 {
30668 struct hstate *h = hstate_file(file);
30669 struct vm_unmapped_area_info info;
30670 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30671 info.high_limit = current->mm->mmap_base;
30672 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30673 info.align_offset = 0;
30674 + info.threadstack_offset = offset;
30675 addr = vm_unmapped_area(&info);
30676
30677 /*
30678 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30679 VM_BUG_ON(addr != -ENOMEM);
30680 info.flags = 0;
30681 info.low_limit = TASK_UNMAPPED_BASE;
30682 +
30683 +#ifdef CONFIG_PAX_RANDMMAP
30684 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30685 + info.low_limit += current->mm->delta_mmap;
30686 +#endif
30687 +
30688 info.high_limit = TASK_SIZE;
30689 addr = vm_unmapped_area(&info);
30690 }
30691 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30692 struct hstate *h = hstate_file(file);
30693 struct mm_struct *mm = current->mm;
30694 struct vm_area_struct *vma;
30695 + unsigned long pax_task_size = TASK_SIZE;
30696 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30697
30698 if (len & ~huge_page_mask(h))
30699 return -EINVAL;
30700 - if (len > TASK_SIZE)
30701 +
30702 +#ifdef CONFIG_PAX_SEGMEXEC
30703 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30704 + pax_task_size = SEGMEXEC_TASK_SIZE;
30705 +#endif
30706 +
30707 + pax_task_size -= PAGE_SIZE;
30708 +
30709 + if (len > pax_task_size)
30710 return -ENOMEM;
30711
30712 if (flags & MAP_FIXED) {
30713 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30714 return addr;
30715 }
30716
30717 +#ifdef CONFIG_PAX_RANDMMAP
30718 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30719 +#endif
30720 +
30721 if (addr) {
30722 addr = ALIGN(addr, huge_page_size(h));
30723 vma = find_vma(mm, addr);
30724 - if (TASK_SIZE - len >= addr &&
30725 - (!vma || addr + len <= vma->vm_start))
30726 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30727 return addr;
30728 }
30729 if (mm->get_unmapped_area == arch_get_unmapped_area)
30730 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30731 - pgoff, flags);
30732 + pgoff, flags, offset);
30733 else
30734 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30735 - pgoff, flags);
30736 + pgoff, flags, offset);
30737 }
30738
30739 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30740 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30741 index 04664cd..dae6e5d 100644
30742 --- a/arch/x86/mm/init.c
30743 +++ b/arch/x86/mm/init.c
30744 @@ -4,6 +4,7 @@
30745 #include <linux/swap.h>
30746 #include <linux/memblock.h>
30747 #include <linux/bootmem.h> /* for max_low_pfn */
30748 +#include <linux/tboot.h>
30749
30750 #include <asm/cacheflush.h>
30751 #include <asm/e820.h>
30752 @@ -17,6 +18,8 @@
30753 #include <asm/proto.h>
30754 #include <asm/dma.h> /* for MAX_DMA_PFN */
30755 #include <asm/microcode.h>
30756 +#include <asm/desc.h>
30757 +#include <asm/bios_ebda.h>
30758
30759 #include "mm_internal.h"
30760
30761 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30762 early_ioremap_page_table_range_init();
30763 #endif
30764
30765 +#ifdef CONFIG_PAX_PER_CPU_PGD
30766 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30767 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30768 + KERNEL_PGD_PTRS);
30769 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30770 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30771 + KERNEL_PGD_PTRS);
30772 + load_cr3(get_cpu_pgd(0, kernel));
30773 +#else
30774 load_cr3(swapper_pg_dir);
30775 +#endif
30776 +
30777 __flush_tlb_all();
30778
30779 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30780 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30781 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30782 * mmio resources as well as potential bios/acpi data regions.
30783 */
30784 +
30785 +#ifdef CONFIG_GRKERNSEC_KMEM
30786 +static unsigned int ebda_start __read_only;
30787 +static unsigned int ebda_end __read_only;
30788 +#endif
30789 +
30790 int devmem_is_allowed(unsigned long pagenr)
30791 {
30792 - if (pagenr < 256)
30793 +#ifdef CONFIG_GRKERNSEC_KMEM
30794 + /* allow BDA */
30795 + if (!pagenr)
30796 return 1;
30797 + /* allow EBDA */
30798 + if (pagenr >= ebda_start && pagenr < ebda_end)
30799 + return 1;
30800 + /* if tboot is in use, allow access to its hardcoded serial log range */
30801 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30802 + return 1;
30803 +#else
30804 + if (!pagenr)
30805 + return 1;
30806 +#ifdef CONFIG_VM86
30807 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30808 + return 1;
30809 +#endif
30810 +#endif
30811 +
30812 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30813 + return 1;
30814 +#ifdef CONFIG_GRKERNSEC_KMEM
30815 + /* throw out everything else below 1MB */
30816 + if (pagenr <= 256)
30817 + return 0;
30818 +#endif
30819 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30820 return 0;
30821 if (!page_is_ram(pagenr))
30822 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30823 #endif
30824 }
30825
30826 +#ifdef CONFIG_GRKERNSEC_KMEM
30827 +static inline void gr_init_ebda(void)
30828 +{
30829 + unsigned int ebda_addr;
30830 + unsigned int ebda_size = 0;
30831 +
30832 + ebda_addr = get_bios_ebda();
30833 + if (ebda_addr) {
30834 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30835 + ebda_size <<= 10;
30836 + }
30837 + if (ebda_addr && ebda_size) {
30838 + ebda_start = ebda_addr >> PAGE_SHIFT;
30839 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30840 + } else {
30841 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30842 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30843 + }
30844 +}
30845 +#else
30846 +static inline void gr_init_ebda(void) { }
30847 +#endif
30848 +
30849 void free_initmem(void)
30850 {
30851 +#ifdef CONFIG_PAX_KERNEXEC
30852 +#ifdef CONFIG_X86_32
30853 + /* PaX: limit KERNEL_CS to actual size */
30854 + unsigned long addr, limit;
30855 + struct desc_struct d;
30856 + int cpu;
30857 +#else
30858 + pgd_t *pgd;
30859 + pud_t *pud;
30860 + pmd_t *pmd;
30861 + unsigned long addr, end;
30862 +#endif
30863 +#endif
30864 +
30865 + gr_init_ebda();
30866 +
30867 +#ifdef CONFIG_PAX_KERNEXEC
30868 +#ifdef CONFIG_X86_32
30869 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30870 + limit = (limit - 1UL) >> PAGE_SHIFT;
30871 +
30872 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30873 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30874 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30875 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30876 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30877 + }
30878 +
30879 + /* PaX: make KERNEL_CS read-only */
30880 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30881 + if (!paravirt_enabled())
30882 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30883 +/*
30884 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30885 + pgd = pgd_offset_k(addr);
30886 + pud = pud_offset(pgd, addr);
30887 + pmd = pmd_offset(pud, addr);
30888 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30889 + }
30890 +*/
30891 +#ifdef CONFIG_X86_PAE
30892 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30893 +/*
30894 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30895 + pgd = pgd_offset_k(addr);
30896 + pud = pud_offset(pgd, addr);
30897 + pmd = pmd_offset(pud, addr);
30898 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30899 + }
30900 +*/
30901 +#endif
30902 +
30903 +#ifdef CONFIG_MODULES
30904 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30905 +#endif
30906 +
30907 +#else
30908 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30909 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30910 + pgd = pgd_offset_k(addr);
30911 + pud = pud_offset(pgd, addr);
30912 + pmd = pmd_offset(pud, addr);
30913 + if (!pmd_present(*pmd))
30914 + continue;
30915 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30916 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30917 + else
30918 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30919 + }
30920 +
30921 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30922 + end = addr + KERNEL_IMAGE_SIZE;
30923 + for (; addr < end; addr += PMD_SIZE) {
30924 + pgd = pgd_offset_k(addr);
30925 + pud = pud_offset(pgd, addr);
30926 + pmd = pmd_offset(pud, addr);
30927 + if (!pmd_present(*pmd))
30928 + continue;
30929 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30930 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30931 + }
30932 +#endif
30933 +
30934 + flush_tlb_all();
30935 +#endif
30936 +
30937 free_init_pages("unused kernel",
30938 (unsigned long)(&__init_begin),
30939 (unsigned long)(&__init_end));
30940 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30941 index 4287f1f..3b99c71 100644
30942 --- a/arch/x86/mm/init_32.c
30943 +++ b/arch/x86/mm/init_32.c
30944 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30945 bool __read_mostly __vmalloc_start_set = false;
30946
30947 /*
30948 - * Creates a middle page table and puts a pointer to it in the
30949 - * given global directory entry. This only returns the gd entry
30950 - * in non-PAE compilation mode, since the middle layer is folded.
30951 - */
30952 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30953 -{
30954 - pud_t *pud;
30955 - pmd_t *pmd_table;
30956 -
30957 -#ifdef CONFIG_X86_PAE
30958 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30959 - pmd_table = (pmd_t *)alloc_low_page();
30960 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30961 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30962 - pud = pud_offset(pgd, 0);
30963 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30964 -
30965 - return pmd_table;
30966 - }
30967 -#endif
30968 - pud = pud_offset(pgd, 0);
30969 - pmd_table = pmd_offset(pud, 0);
30970 -
30971 - return pmd_table;
30972 -}
30973 -
30974 -/*
30975 * Create a page table and place a pointer to it in a middle page
30976 * directory entry:
30977 */
30978 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30979 pte_t *page_table = (pte_t *)alloc_low_page();
30980
30981 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30982 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30983 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30984 +#else
30985 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30986 +#endif
30987 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30988 }
30989
30990 return pte_offset_kernel(pmd, 0);
30991 }
30992
30993 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30994 +{
30995 + pud_t *pud;
30996 + pmd_t *pmd_table;
30997 +
30998 + pud = pud_offset(pgd, 0);
30999 + pmd_table = pmd_offset(pud, 0);
31000 +
31001 + return pmd_table;
31002 +}
31003 +
31004 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31005 {
31006 int pgd_idx = pgd_index(vaddr);
31007 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31008 int pgd_idx, pmd_idx;
31009 unsigned long vaddr;
31010 pgd_t *pgd;
31011 + pud_t *pud;
31012 pmd_t *pmd;
31013 pte_t *pte = NULL;
31014 unsigned long count = page_table_range_init_count(start, end);
31015 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31016 pgd = pgd_base + pgd_idx;
31017
31018 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31019 - pmd = one_md_table_init(pgd);
31020 - pmd = pmd + pmd_index(vaddr);
31021 + pud = pud_offset(pgd, vaddr);
31022 + pmd = pmd_offset(pud, vaddr);
31023 +
31024 +#ifdef CONFIG_X86_PAE
31025 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31026 +#endif
31027 +
31028 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31029 pmd++, pmd_idx++) {
31030 pte = page_table_kmap_check(one_page_table_init(pmd),
31031 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31032 }
31033 }
31034
31035 -static inline int is_kernel_text(unsigned long addr)
31036 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31037 {
31038 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31039 - return 1;
31040 - return 0;
31041 + if ((start > ktla_ktva((unsigned long)_etext) ||
31042 + end <= ktla_ktva((unsigned long)_stext)) &&
31043 + (start > ktla_ktva((unsigned long)_einittext) ||
31044 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31045 +
31046 +#ifdef CONFIG_ACPI_SLEEP
31047 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31048 +#endif
31049 +
31050 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31051 + return 0;
31052 + return 1;
31053 }
31054
31055 /*
31056 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31057 unsigned long last_map_addr = end;
31058 unsigned long start_pfn, end_pfn;
31059 pgd_t *pgd_base = swapper_pg_dir;
31060 - int pgd_idx, pmd_idx, pte_ofs;
31061 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31062 unsigned long pfn;
31063 pgd_t *pgd;
31064 + pud_t *pud;
31065 pmd_t *pmd;
31066 pte_t *pte;
31067 unsigned pages_2m, pages_4k;
31068 @@ -291,8 +295,13 @@ repeat:
31069 pfn = start_pfn;
31070 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31071 pgd = pgd_base + pgd_idx;
31072 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31073 - pmd = one_md_table_init(pgd);
31074 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31075 + pud = pud_offset(pgd, 0);
31076 + pmd = pmd_offset(pud, 0);
31077 +
31078 +#ifdef CONFIG_X86_PAE
31079 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31080 +#endif
31081
31082 if (pfn >= end_pfn)
31083 continue;
31084 @@ -304,14 +313,13 @@ repeat:
31085 #endif
31086 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31087 pmd++, pmd_idx++) {
31088 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31089 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31090
31091 /*
31092 * Map with big pages if possible, otherwise
31093 * create normal page tables:
31094 */
31095 if (use_pse) {
31096 - unsigned int addr2;
31097 pgprot_t prot = PAGE_KERNEL_LARGE;
31098 /*
31099 * first pass will use the same initial
31100 @@ -322,11 +330,7 @@ repeat:
31101 _PAGE_PSE);
31102
31103 pfn &= PMD_MASK >> PAGE_SHIFT;
31104 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31105 - PAGE_OFFSET + PAGE_SIZE-1;
31106 -
31107 - if (is_kernel_text(addr) ||
31108 - is_kernel_text(addr2))
31109 + if (is_kernel_text(address, address + PMD_SIZE))
31110 prot = PAGE_KERNEL_LARGE_EXEC;
31111
31112 pages_2m++;
31113 @@ -343,7 +347,7 @@ repeat:
31114 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31115 pte += pte_ofs;
31116 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31117 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31118 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31119 pgprot_t prot = PAGE_KERNEL;
31120 /*
31121 * first pass will use the same initial
31122 @@ -351,7 +355,7 @@ repeat:
31123 */
31124 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31125
31126 - if (is_kernel_text(addr))
31127 + if (is_kernel_text(address, address + PAGE_SIZE))
31128 prot = PAGE_KERNEL_EXEC;
31129
31130 pages_4k++;
31131 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31132
31133 pud = pud_offset(pgd, va);
31134 pmd = pmd_offset(pud, va);
31135 - if (!pmd_present(*pmd))
31136 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31137 break;
31138
31139 /* should not be large page here */
31140 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31141
31142 static void __init pagetable_init(void)
31143 {
31144 - pgd_t *pgd_base = swapper_pg_dir;
31145 -
31146 - permanent_kmaps_init(pgd_base);
31147 + permanent_kmaps_init(swapper_pg_dir);
31148 }
31149
31150 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31151 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31152 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31153
31154 /* user-defined highmem size */
31155 @@ -787,10 +789,10 @@ void __init mem_init(void)
31156 ((unsigned long)&__init_end -
31157 (unsigned long)&__init_begin) >> 10,
31158
31159 - (unsigned long)&_etext, (unsigned long)&_edata,
31160 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31161 + (unsigned long)&_sdata, (unsigned long)&_edata,
31162 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31163
31164 - (unsigned long)&_text, (unsigned long)&_etext,
31165 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31166 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31167
31168 /*
31169 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31170 if (!kernel_set_to_readonly)
31171 return;
31172
31173 + start = ktla_ktva(start);
31174 pr_debug("Set kernel text: %lx - %lx for read write\n",
31175 start, start+size);
31176
31177 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31178 if (!kernel_set_to_readonly)
31179 return;
31180
31181 + start = ktla_ktva(start);
31182 pr_debug("Set kernel text: %lx - %lx for read only\n",
31183 start, start+size);
31184
31185 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31186 unsigned long start = PFN_ALIGN(_text);
31187 unsigned long size = PFN_ALIGN(_etext) - start;
31188
31189 + start = ktla_ktva(start);
31190 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31191 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31192 size >> 10);
31193 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31194 index 104d56a..62ba13f1 100644
31195 --- a/arch/x86/mm/init_64.c
31196 +++ b/arch/x86/mm/init_64.c
31197 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31198 * around without checking the pgd every time.
31199 */
31200
31201 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31202 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31203 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31204
31205 int force_personality32;
31206 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31207
31208 for (address = start; address <= end; address += PGDIR_SIZE) {
31209 const pgd_t *pgd_ref = pgd_offset_k(address);
31210 +
31211 +#ifdef CONFIG_PAX_PER_CPU_PGD
31212 + unsigned long cpu;
31213 +#else
31214 struct page *page;
31215 +#endif
31216
31217 if (pgd_none(*pgd_ref))
31218 continue;
31219
31220 spin_lock(&pgd_lock);
31221 +
31222 +#ifdef CONFIG_PAX_PER_CPU_PGD
31223 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31224 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31225 +
31226 + if (pgd_none(*pgd))
31227 + set_pgd(pgd, *pgd_ref);
31228 + else
31229 + BUG_ON(pgd_page_vaddr(*pgd)
31230 + != pgd_page_vaddr(*pgd_ref));
31231 + pgd = pgd_offset_cpu(cpu, kernel, address);
31232 +#else
31233 list_for_each_entry(page, &pgd_list, lru) {
31234 pgd_t *pgd;
31235 spinlock_t *pgt_lock;
31236 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31237 /* the pgt_lock only for Xen */
31238 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31239 spin_lock(pgt_lock);
31240 +#endif
31241
31242 if (pgd_none(*pgd))
31243 set_pgd(pgd, *pgd_ref);
31244 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31245 BUG_ON(pgd_page_vaddr(*pgd)
31246 != pgd_page_vaddr(*pgd_ref));
31247
31248 +#ifndef CONFIG_PAX_PER_CPU_PGD
31249 spin_unlock(pgt_lock);
31250 +#endif
31251 +
31252 }
31253 spin_unlock(&pgd_lock);
31254 }
31255 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31256 {
31257 if (pgd_none(*pgd)) {
31258 pud_t *pud = (pud_t *)spp_getpage();
31259 - pgd_populate(&init_mm, pgd, pud);
31260 + pgd_populate_kernel(&init_mm, pgd, pud);
31261 if (pud != pud_offset(pgd, 0))
31262 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31263 pud, pud_offset(pgd, 0));
31264 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31265 {
31266 if (pud_none(*pud)) {
31267 pmd_t *pmd = (pmd_t *) spp_getpage();
31268 - pud_populate(&init_mm, pud, pmd);
31269 + pud_populate_kernel(&init_mm, pud, pmd);
31270 if (pmd != pmd_offset(pud, 0))
31271 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31272 pmd, pmd_offset(pud, 0));
31273 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31274 pmd = fill_pmd(pud, vaddr);
31275 pte = fill_pte(pmd, vaddr);
31276
31277 + pax_open_kernel();
31278 set_pte(pte, new_pte);
31279 + pax_close_kernel();
31280
31281 /*
31282 * It's enough to flush this one mapping.
31283 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31284 pgd = pgd_offset_k((unsigned long)__va(phys));
31285 if (pgd_none(*pgd)) {
31286 pud = (pud_t *) spp_getpage();
31287 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31288 - _PAGE_USER));
31289 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31290 }
31291 pud = pud_offset(pgd, (unsigned long)__va(phys));
31292 if (pud_none(*pud)) {
31293 pmd = (pmd_t *) spp_getpage();
31294 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31295 - _PAGE_USER));
31296 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31297 }
31298 pmd = pmd_offset(pud, phys);
31299 BUG_ON(!pmd_none(*pmd));
31300 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31301 prot);
31302
31303 spin_lock(&init_mm.page_table_lock);
31304 - pud_populate(&init_mm, pud, pmd);
31305 + pud_populate_kernel(&init_mm, pud, pmd);
31306 spin_unlock(&init_mm.page_table_lock);
31307 }
31308 __flush_tlb_all();
31309 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31310 page_size_mask);
31311
31312 spin_lock(&init_mm.page_table_lock);
31313 - pgd_populate(&init_mm, pgd, pud);
31314 + pgd_populate_kernel(&init_mm, pgd, pud);
31315 spin_unlock(&init_mm.page_table_lock);
31316 pgd_changed = true;
31317 }
31318 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31319 static struct vm_area_struct gate_vma = {
31320 .vm_start = VSYSCALL_START,
31321 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31322 - .vm_page_prot = PAGE_READONLY_EXEC,
31323 - .vm_flags = VM_READ | VM_EXEC
31324 + .vm_page_prot = PAGE_READONLY,
31325 + .vm_flags = VM_READ
31326 };
31327
31328 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31329 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31330
31331 const char *arch_vma_name(struct vm_area_struct *vma)
31332 {
31333 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31334 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31335 return "[vdso]";
31336 if (vma == &gate_vma)
31337 return "[vsyscall]";
31338 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31339 index 7b179b4..6bd17777 100644
31340 --- a/arch/x86/mm/iomap_32.c
31341 +++ b/arch/x86/mm/iomap_32.c
31342 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31343 type = kmap_atomic_idx_push();
31344 idx = type + KM_TYPE_NR * smp_processor_id();
31345 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31346 +
31347 + pax_open_kernel();
31348 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31349 + pax_close_kernel();
31350 +
31351 arch_flush_lazy_mmu_mode();
31352
31353 return (void *)vaddr;
31354 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31355 index 799580c..72f9fe0 100644
31356 --- a/arch/x86/mm/ioremap.c
31357 +++ b/arch/x86/mm/ioremap.c
31358 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31359 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31360 int is_ram = page_is_ram(pfn);
31361
31362 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31363 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31364 return NULL;
31365 WARN_ON_ONCE(is_ram);
31366 }
31367 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31368 *
31369 * Caller must ensure there is only one unmapping for the same pointer.
31370 */
31371 -void iounmap(volatile void __iomem *addr)
31372 +void iounmap(const volatile void __iomem *addr)
31373 {
31374 struct vm_struct *p, *o;
31375
31376 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31377
31378 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31379 if (page_is_ram(start >> PAGE_SHIFT))
31380 +#ifdef CONFIG_HIGHMEM
31381 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31382 +#endif
31383 return __va(phys);
31384
31385 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31386 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31387 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31388 {
31389 if (page_is_ram(phys >> PAGE_SHIFT))
31390 +#ifdef CONFIG_HIGHMEM
31391 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31392 +#endif
31393 return;
31394
31395 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31396 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31397 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31398
31399 static __initdata int after_paging_init;
31400 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31401 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31402
31403 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31404 {
31405 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31406 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31407
31408 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31409 - memset(bm_pte, 0, sizeof(bm_pte));
31410 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31411 + pmd_populate_user(&init_mm, pmd, bm_pte);
31412
31413 /*
31414 * The boot-ioremap range spans multiple pmds, for which
31415 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31416 index d87dd6d..bf3fa66 100644
31417 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31418 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31419 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31420 * memory (e.g. tracked pages)? For now, we need this to avoid
31421 * invoking kmemcheck for PnP BIOS calls.
31422 */
31423 - if (regs->flags & X86_VM_MASK)
31424 + if (v8086_mode(regs))
31425 return false;
31426 - if (regs->cs != __KERNEL_CS)
31427 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31428 return false;
31429
31430 pte = kmemcheck_pte_lookup(address);
31431 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31432 index 25e7e13..1964579 100644
31433 --- a/arch/x86/mm/mmap.c
31434 +++ b/arch/x86/mm/mmap.c
31435 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31436 * Leave an at least ~128 MB hole with possible stack randomization.
31437 */
31438 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31439 -#define MAX_GAP (TASK_SIZE/6*5)
31440 +#define MAX_GAP (pax_task_size/6*5)
31441
31442 static int mmap_is_legacy(void)
31443 {
31444 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31445 return rnd << PAGE_SHIFT;
31446 }
31447
31448 -static unsigned long mmap_base(void)
31449 +static unsigned long mmap_base(struct mm_struct *mm)
31450 {
31451 unsigned long gap = rlimit(RLIMIT_STACK);
31452 + unsigned long pax_task_size = TASK_SIZE;
31453 +
31454 +#ifdef CONFIG_PAX_SEGMEXEC
31455 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31456 + pax_task_size = SEGMEXEC_TASK_SIZE;
31457 +#endif
31458
31459 if (gap < MIN_GAP)
31460 gap = MIN_GAP;
31461 else if (gap > MAX_GAP)
31462 gap = MAX_GAP;
31463
31464 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31465 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31466 }
31467
31468 /*
31469 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31470 * does, but not when emulating X86_32
31471 */
31472 -static unsigned long mmap_legacy_base(void)
31473 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31474 {
31475 - if (mmap_is_ia32())
31476 + if (mmap_is_ia32()) {
31477 +
31478 +#ifdef CONFIG_PAX_SEGMEXEC
31479 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31480 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31481 + else
31482 +#endif
31483 +
31484 return TASK_UNMAPPED_BASE;
31485 - else
31486 + } else
31487 return TASK_UNMAPPED_BASE + mmap_rnd();
31488 }
31489
31490 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31491 */
31492 void arch_pick_mmap_layout(struct mm_struct *mm)
31493 {
31494 - mm->mmap_legacy_base = mmap_legacy_base();
31495 - mm->mmap_base = mmap_base();
31496 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31497 + mm->mmap_base = mmap_base(mm);
31498 +
31499 +#ifdef CONFIG_PAX_RANDMMAP
31500 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31501 + mm->mmap_legacy_base += mm->delta_mmap;
31502 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31503 + }
31504 +#endif
31505
31506 if (mmap_is_legacy()) {
31507 mm->mmap_base = mm->mmap_legacy_base;
31508 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31509 index 0057a7a..95c7edd 100644
31510 --- a/arch/x86/mm/mmio-mod.c
31511 +++ b/arch/x86/mm/mmio-mod.c
31512 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31513 break;
31514 default:
31515 {
31516 - unsigned char *ip = (unsigned char *)instptr;
31517 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31518 my_trace->opcode = MMIO_UNKNOWN_OP;
31519 my_trace->width = 0;
31520 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31521 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31522 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31523 void __iomem *addr)
31524 {
31525 - static atomic_t next_id;
31526 + static atomic_unchecked_t next_id;
31527 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31528 /* These are page-unaligned. */
31529 struct mmiotrace_map map = {
31530 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31531 .private = trace
31532 },
31533 .phys = offset,
31534 - .id = atomic_inc_return(&next_id)
31535 + .id = atomic_inc_return_unchecked(&next_id)
31536 };
31537 map.map_id = trace->id;
31538
31539 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31540 ioremap_trace_core(offset, size, addr);
31541 }
31542
31543 -static void iounmap_trace_core(volatile void __iomem *addr)
31544 +static void iounmap_trace_core(const volatile void __iomem *addr)
31545 {
31546 struct mmiotrace_map map = {
31547 .phys = 0,
31548 @@ -328,7 +328,7 @@ not_enabled:
31549 }
31550 }
31551
31552 -void mmiotrace_iounmap(volatile void __iomem *addr)
31553 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31554 {
31555 might_sleep();
31556 if (is_enabled()) /* recheck and proper locking in *_core() */
31557 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31558 index 8bf93ba..dbcd670 100644
31559 --- a/arch/x86/mm/numa.c
31560 +++ b/arch/x86/mm/numa.c
31561 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31562 return true;
31563 }
31564
31565 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31566 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31567 {
31568 unsigned long uninitialized_var(pfn_align);
31569 int i, nid;
31570 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31571 index d0b1773..4c3327c 100644
31572 --- a/arch/x86/mm/pageattr-test.c
31573 +++ b/arch/x86/mm/pageattr-test.c
31574 @@ -36,7 +36,7 @@ enum {
31575
31576 static int pte_testbit(pte_t pte)
31577 {
31578 - return pte_flags(pte) & _PAGE_UNUSED1;
31579 + return pte_flags(pte) & _PAGE_CPA_TEST;
31580 }
31581
31582 struct split_state {
31583 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31584 index bb32480..75f2f5e 100644
31585 --- a/arch/x86/mm/pageattr.c
31586 +++ b/arch/x86/mm/pageattr.c
31587 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31588 */
31589 #ifdef CONFIG_PCI_BIOS
31590 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31591 - pgprot_val(forbidden) |= _PAGE_NX;
31592 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31593 #endif
31594
31595 /*
31596 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31597 * Does not cover __inittext since that is gone later on. On
31598 * 64bit we do not enforce !NX on the low mapping
31599 */
31600 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31601 - pgprot_val(forbidden) |= _PAGE_NX;
31602 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31603 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31604
31605 +#ifdef CONFIG_DEBUG_RODATA
31606 /*
31607 * The .rodata section needs to be read-only. Using the pfn
31608 * catches all aliases.
31609 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31610 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31611 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31612 pgprot_val(forbidden) |= _PAGE_RW;
31613 +#endif
31614
31615 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31616 /*
31617 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31618 }
31619 #endif
31620
31621 +#ifdef CONFIG_PAX_KERNEXEC
31622 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31623 + pgprot_val(forbidden) |= _PAGE_RW;
31624 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31625 + }
31626 +#endif
31627 +
31628 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31629
31630 return prot;
31631 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31632 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31633 {
31634 /* change init_mm */
31635 + pax_open_kernel();
31636 set_pte_atomic(kpte, pte);
31637 +
31638 #ifdef CONFIG_X86_32
31639 if (!SHARED_KERNEL_PMD) {
31640 +
31641 +#ifdef CONFIG_PAX_PER_CPU_PGD
31642 + unsigned long cpu;
31643 +#else
31644 struct page *page;
31645 +#endif
31646
31647 +#ifdef CONFIG_PAX_PER_CPU_PGD
31648 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31649 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31650 +#else
31651 list_for_each_entry(page, &pgd_list, lru) {
31652 - pgd_t *pgd;
31653 + pgd_t *pgd = (pgd_t *)page_address(page);
31654 +#endif
31655 +
31656 pud_t *pud;
31657 pmd_t *pmd;
31658
31659 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31660 + pgd += pgd_index(address);
31661 pud = pud_offset(pgd, address);
31662 pmd = pmd_offset(pud, address);
31663 set_pte_atomic((pte_t *)pmd, pte);
31664 }
31665 }
31666 #endif
31667 + pax_close_kernel();
31668 }
31669
31670 static int
31671 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31672 index 6574388..87e9bef 100644
31673 --- a/arch/x86/mm/pat.c
31674 +++ b/arch/x86/mm/pat.c
31675 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31676
31677 if (!entry) {
31678 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31679 - current->comm, current->pid, start, end - 1);
31680 + current->comm, task_pid_nr(current), start, end - 1);
31681 return -EINVAL;
31682 }
31683
31684 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31685
31686 while (cursor < to) {
31687 if (!devmem_is_allowed(pfn)) {
31688 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31689 - current->comm, from, to - 1);
31690 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31691 + current->comm, from, to - 1, cursor);
31692 return 0;
31693 }
31694 cursor += PAGE_SIZE;
31695 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31696 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31697 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31698 "for [mem %#010Lx-%#010Lx]\n",
31699 - current->comm, current->pid,
31700 + current->comm, task_pid_nr(current),
31701 cattr_name(flags),
31702 base, (unsigned long long)(base + size-1));
31703 return -EINVAL;
31704 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31705 flags = lookup_memtype(paddr);
31706 if (want_flags != flags) {
31707 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31708 - current->comm, current->pid,
31709 + current->comm, task_pid_nr(current),
31710 cattr_name(want_flags),
31711 (unsigned long long)paddr,
31712 (unsigned long long)(paddr + size - 1),
31713 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31714 free_memtype(paddr, paddr + size);
31715 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31716 " for [mem %#010Lx-%#010Lx], got %s\n",
31717 - current->comm, current->pid,
31718 + current->comm, task_pid_nr(current),
31719 cattr_name(want_flags),
31720 (unsigned long long)paddr,
31721 (unsigned long long)(paddr + size - 1),
31722 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31723 index 415f6c4..d319983 100644
31724 --- a/arch/x86/mm/pat_rbtree.c
31725 +++ b/arch/x86/mm/pat_rbtree.c
31726 @@ -160,7 +160,7 @@ success:
31727
31728 failure:
31729 printk(KERN_INFO "%s:%d conflicting memory types "
31730 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31731 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31732 end, cattr_name(found_type), cattr_name(match->type));
31733 return -EBUSY;
31734 }
31735 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31736 index 9f0614d..92ae64a 100644
31737 --- a/arch/x86/mm/pf_in.c
31738 +++ b/arch/x86/mm/pf_in.c
31739 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31740 int i;
31741 enum reason_type rv = OTHERS;
31742
31743 - p = (unsigned char *)ins_addr;
31744 + p = (unsigned char *)ktla_ktva(ins_addr);
31745 p += skip_prefix(p, &prf);
31746 p += get_opcode(p, &opcode);
31747
31748 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31749 struct prefix_bits prf;
31750 int i;
31751
31752 - p = (unsigned char *)ins_addr;
31753 + p = (unsigned char *)ktla_ktva(ins_addr);
31754 p += skip_prefix(p, &prf);
31755 p += get_opcode(p, &opcode);
31756
31757 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31758 struct prefix_bits prf;
31759 int i;
31760
31761 - p = (unsigned char *)ins_addr;
31762 + p = (unsigned char *)ktla_ktva(ins_addr);
31763 p += skip_prefix(p, &prf);
31764 p += get_opcode(p, &opcode);
31765
31766 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31767 struct prefix_bits prf;
31768 int i;
31769
31770 - p = (unsigned char *)ins_addr;
31771 + p = (unsigned char *)ktla_ktva(ins_addr);
31772 p += skip_prefix(p, &prf);
31773 p += get_opcode(p, &opcode);
31774 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31775 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31776 struct prefix_bits prf;
31777 int i;
31778
31779 - p = (unsigned char *)ins_addr;
31780 + p = (unsigned char *)ktla_ktva(ins_addr);
31781 p += skip_prefix(p, &prf);
31782 p += get_opcode(p, &opcode);
31783 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31784 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31785 index dfa537a..fd45c64 100644
31786 --- a/arch/x86/mm/pgtable.c
31787 +++ b/arch/x86/mm/pgtable.c
31788 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31789 list_del(&page->lru);
31790 }
31791
31792 -#define UNSHARED_PTRS_PER_PGD \
31793 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31795 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31796
31797 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31798 +{
31799 + unsigned int count = USER_PGD_PTRS;
31800
31801 + if (!pax_user_shadow_base)
31802 + return;
31803 +
31804 + while (count--)
31805 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31806 +}
31807 +#endif
31808 +
31809 +#ifdef CONFIG_PAX_PER_CPU_PGD
31810 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31811 +{
31812 + unsigned int count = USER_PGD_PTRS;
31813 +
31814 + while (count--) {
31815 + pgd_t pgd;
31816 +
31817 +#ifdef CONFIG_X86_64
31818 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31819 +#else
31820 + pgd = *src++;
31821 +#endif
31822 +
31823 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31824 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31825 +#endif
31826 +
31827 + *dst++ = pgd;
31828 + }
31829 +
31830 +}
31831 +#endif
31832 +
31833 +#ifdef CONFIG_X86_64
31834 +#define pxd_t pud_t
31835 +#define pyd_t pgd_t
31836 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31837 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31838 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31839 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31840 +#define PYD_SIZE PGDIR_SIZE
31841 +#else
31842 +#define pxd_t pmd_t
31843 +#define pyd_t pud_t
31844 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31845 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31846 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31847 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31848 +#define PYD_SIZE PUD_SIZE
31849 +#endif
31850 +
31851 +#ifdef CONFIG_PAX_PER_CPU_PGD
31852 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31853 +static inline void pgd_dtor(pgd_t *pgd) {}
31854 +#else
31855 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31856 {
31857 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31858 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31859 pgd_list_del(pgd);
31860 spin_unlock(&pgd_lock);
31861 }
31862 +#endif
31863
31864 /*
31865 * List of all pgd's needed for non-PAE so it can invalidate entries
31866 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31867 * -- nyc
31868 */
31869
31870 -#ifdef CONFIG_X86_PAE
31871 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31872 /*
31873 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31874 * updating the top-level pagetable entries to guarantee the
31875 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31876 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31877 * and initialize the kernel pmds here.
31878 */
31879 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31880 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31881
31882 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31883 {
31884 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31885 */
31886 flush_tlb_mm(mm);
31887 }
31888 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31889 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31890 #else /* !CONFIG_X86_PAE */
31891
31892 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31893 -#define PREALLOCATED_PMDS 0
31894 +#define PREALLOCATED_PXDS 0
31895
31896 #endif /* CONFIG_X86_PAE */
31897
31898 -static void free_pmds(pmd_t *pmds[])
31899 +static void free_pxds(pxd_t *pxds[])
31900 {
31901 int i;
31902
31903 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31904 - if (pmds[i])
31905 - free_page((unsigned long)pmds[i]);
31906 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31907 + if (pxds[i])
31908 + free_page((unsigned long)pxds[i]);
31909 }
31910
31911 -static int preallocate_pmds(pmd_t *pmds[])
31912 +static int preallocate_pxds(pxd_t *pxds[])
31913 {
31914 int i;
31915 bool failed = false;
31916
31917 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31918 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31919 - if (pmd == NULL)
31920 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31921 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31922 + if (pxd == NULL)
31923 failed = true;
31924 - pmds[i] = pmd;
31925 + pxds[i] = pxd;
31926 }
31927
31928 if (failed) {
31929 - free_pmds(pmds);
31930 + free_pxds(pxds);
31931 return -ENOMEM;
31932 }
31933
31934 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31935 * preallocate which never got a corresponding vma will need to be
31936 * freed manually.
31937 */
31938 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31939 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31940 {
31941 int i;
31942
31943 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31944 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31945 pgd_t pgd = pgdp[i];
31946
31947 if (pgd_val(pgd) != 0) {
31948 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31949 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31950
31951 - pgdp[i] = native_make_pgd(0);
31952 + set_pgd(pgdp + i, native_make_pgd(0));
31953
31954 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31955 - pmd_free(mm, pmd);
31956 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31957 + pxd_free(mm, pxd);
31958 }
31959 }
31960 }
31961
31962 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31963 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31964 {
31965 - pud_t *pud;
31966 + pyd_t *pyd;
31967 int i;
31968
31969 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31970 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31971 return;
31972
31973 - pud = pud_offset(pgd, 0);
31974 -
31975 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31976 - pmd_t *pmd = pmds[i];
31977 +#ifdef CONFIG_X86_64
31978 + pyd = pyd_offset(mm, 0L);
31979 +#else
31980 + pyd = pyd_offset(pgd, 0L);
31981 +#endif
31982
31983 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31984 + pxd_t *pxd = pxds[i];
31985 if (i >= KERNEL_PGD_BOUNDARY)
31986 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31987 - sizeof(pmd_t) * PTRS_PER_PMD);
31988 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31989 + sizeof(pxd_t) * PTRS_PER_PMD);
31990
31991 - pud_populate(mm, pud, pmd);
31992 + pyd_populate(mm, pyd, pxd);
31993 }
31994 }
31995
31996 pgd_t *pgd_alloc(struct mm_struct *mm)
31997 {
31998 pgd_t *pgd;
31999 - pmd_t *pmds[PREALLOCATED_PMDS];
32000 + pxd_t *pxds[PREALLOCATED_PXDS];
32001
32002 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32003
32004 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32005
32006 mm->pgd = pgd;
32007
32008 - if (preallocate_pmds(pmds) != 0)
32009 + if (preallocate_pxds(pxds) != 0)
32010 goto out_free_pgd;
32011
32012 if (paravirt_pgd_alloc(mm) != 0)
32013 - goto out_free_pmds;
32014 + goto out_free_pxds;
32015
32016 /*
32017 * Make sure that pre-populating the pmds is atomic with
32018 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32019 spin_lock(&pgd_lock);
32020
32021 pgd_ctor(mm, pgd);
32022 - pgd_prepopulate_pmd(mm, pgd, pmds);
32023 + pgd_prepopulate_pxd(mm, pgd, pxds);
32024
32025 spin_unlock(&pgd_lock);
32026
32027 return pgd;
32028
32029 -out_free_pmds:
32030 - free_pmds(pmds);
32031 +out_free_pxds:
32032 + free_pxds(pxds);
32033 out_free_pgd:
32034 free_page((unsigned long)pgd);
32035 out:
32036 @@ -300,7 +363,7 @@ out:
32037
32038 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32039 {
32040 - pgd_mop_up_pmds(mm, pgd);
32041 + pgd_mop_up_pxds(mm, pgd);
32042 pgd_dtor(pgd);
32043 paravirt_pgd_free(mm, pgd);
32044 free_page((unsigned long)pgd);
32045 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32046 index a69bcb8..19068ab 100644
32047 --- a/arch/x86/mm/pgtable_32.c
32048 +++ b/arch/x86/mm/pgtable_32.c
32049 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32050 return;
32051 }
32052 pte = pte_offset_kernel(pmd, vaddr);
32053 +
32054 + pax_open_kernel();
32055 if (pte_val(pteval))
32056 set_pte_at(&init_mm, vaddr, pte, pteval);
32057 else
32058 pte_clear(&init_mm, vaddr, pte);
32059 + pax_close_kernel();
32060
32061 /*
32062 * It's enough to flush this one mapping.
32063 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32064 index e666cbb..61788c45 100644
32065 --- a/arch/x86/mm/physaddr.c
32066 +++ b/arch/x86/mm/physaddr.c
32067 @@ -10,7 +10,7 @@
32068 #ifdef CONFIG_X86_64
32069
32070 #ifdef CONFIG_DEBUG_VIRTUAL
32071 -unsigned long __phys_addr(unsigned long x)
32072 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32073 {
32074 unsigned long y = x - __START_KERNEL_map;
32075
32076 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32077 #else
32078
32079 #ifdef CONFIG_DEBUG_VIRTUAL
32080 -unsigned long __phys_addr(unsigned long x)
32081 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32082 {
32083 unsigned long phys_addr = x - PAGE_OFFSET;
32084 /* VMALLOC_* aren't constants */
32085 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32086 index 90555bf..f5f1828 100644
32087 --- a/arch/x86/mm/setup_nx.c
32088 +++ b/arch/x86/mm/setup_nx.c
32089 @@ -5,8 +5,10 @@
32090 #include <asm/pgtable.h>
32091 #include <asm/proto.h>
32092
32093 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32094 static int disable_nx;
32095
32096 +#ifndef CONFIG_PAX_PAGEEXEC
32097 /*
32098 * noexec = on|off
32099 *
32100 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32101 return 0;
32102 }
32103 early_param("noexec", noexec_setup);
32104 +#endif
32105 +
32106 +#endif
32107
32108 void x86_configure_nx(void)
32109 {
32110 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32111 if (cpu_has_nx && !disable_nx)
32112 __supported_pte_mask |= _PAGE_NX;
32113 else
32114 +#endif
32115 __supported_pte_mask &= ~_PAGE_NX;
32116 }
32117
32118 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32119 index ae699b3..f1b2ad2 100644
32120 --- a/arch/x86/mm/tlb.c
32121 +++ b/arch/x86/mm/tlb.c
32122 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32123 BUG();
32124 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32125 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32126 +
32127 +#ifndef CONFIG_PAX_PER_CPU_PGD
32128 load_cr3(swapper_pg_dir);
32129 +#endif
32130 +
32131 }
32132 }
32133 EXPORT_SYMBOL_GPL(leave_mm);
32134 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32135 new file mode 100644
32136 index 0000000..dace51c
32137 --- /dev/null
32138 +++ b/arch/x86/mm/uderef_64.c
32139 @@ -0,0 +1,37 @@
32140 +#include <linux/mm.h>
32141 +#include <asm/pgtable.h>
32142 +#include <asm/uaccess.h>
32143 +
32144 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32145 +/* PaX: due to the special call convention these functions must
32146 + * - remain leaf functions under all configurations,
32147 + * - never be called directly, only dereferenced from the wrappers.
32148 + */
32149 +void __pax_open_userland(void)
32150 +{
32151 + unsigned int cpu;
32152 +
32153 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32154 + return;
32155 +
32156 + cpu = raw_get_cpu();
32157 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32158 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32159 + raw_put_cpu_no_resched();
32160 +}
32161 +EXPORT_SYMBOL(__pax_open_userland);
32162 +
32163 +void __pax_close_userland(void)
32164 +{
32165 + unsigned int cpu;
32166 +
32167 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32168 + return;
32169 +
32170 + cpu = raw_get_cpu();
32171 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32172 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32173 + raw_put_cpu_no_resched();
32174 +}
32175 +EXPORT_SYMBOL(__pax_close_userland);
32176 +#endif
32177 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32178 index 877b9a1..a8ecf42 100644
32179 --- a/arch/x86/net/bpf_jit.S
32180 +++ b/arch/x86/net/bpf_jit.S
32181 @@ -9,6 +9,7 @@
32182 */
32183 #include <linux/linkage.h>
32184 #include <asm/dwarf2.h>
32185 +#include <asm/alternative-asm.h>
32186
32187 /*
32188 * Calling convention :
32189 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32190 jle bpf_slow_path_word
32191 mov (SKBDATA,%rsi),%eax
32192 bswap %eax /* ntohl() */
32193 + pax_force_retaddr
32194 ret
32195
32196 sk_load_half:
32197 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32198 jle bpf_slow_path_half
32199 movzwl (SKBDATA,%rsi),%eax
32200 rol $8,%ax # ntohs()
32201 + pax_force_retaddr
32202 ret
32203
32204 sk_load_byte:
32205 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32206 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32207 jle bpf_slow_path_byte
32208 movzbl (SKBDATA,%rsi),%eax
32209 + pax_force_retaddr
32210 ret
32211
32212 /**
32213 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32214 movzbl (SKBDATA,%rsi),%ebx
32215 and $15,%bl
32216 shl $2,%bl
32217 + pax_force_retaddr
32218 ret
32219
32220 /* rsi contains offset and can be scratched */
32221 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32222 js bpf_error
32223 mov -12(%rbp),%eax
32224 bswap %eax
32225 + pax_force_retaddr
32226 ret
32227
32228 bpf_slow_path_half:
32229 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32230 mov -12(%rbp),%ax
32231 rol $8,%ax
32232 movzwl %ax,%eax
32233 + pax_force_retaddr
32234 ret
32235
32236 bpf_slow_path_byte:
32237 bpf_slow_path_common(1)
32238 js bpf_error
32239 movzbl -12(%rbp),%eax
32240 + pax_force_retaddr
32241 ret
32242
32243 bpf_slow_path_byte_msh:
32244 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32245 and $15,%al
32246 shl $2,%al
32247 xchg %eax,%ebx
32248 + pax_force_retaddr
32249 ret
32250
32251 #define sk_negative_common(SIZE) \
32252 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32253 sk_negative_common(4)
32254 mov (%rax), %eax
32255 bswap %eax
32256 + pax_force_retaddr
32257 ret
32258
32259 bpf_slow_path_half_neg:
32260 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32261 mov (%rax),%ax
32262 rol $8,%ax
32263 movzwl %ax,%eax
32264 + pax_force_retaddr
32265 ret
32266
32267 bpf_slow_path_byte_neg:
32268 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32269 .globl sk_load_byte_negative_offset
32270 sk_negative_common(1)
32271 movzbl (%rax), %eax
32272 + pax_force_retaddr
32273 ret
32274
32275 bpf_slow_path_byte_msh_neg:
32276 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32277 and $15,%al
32278 shl $2,%al
32279 xchg %eax,%ebx
32280 + pax_force_retaddr
32281 ret
32282
32283 bpf_error:
32284 @@ -197,4 +210,5 @@ bpf_error:
32285 xor %eax,%eax
32286 mov -8(%rbp),%rbx
32287 leaveq
32288 + pax_force_retaddr
32289 ret
32290 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32291 index 516593e..29d3c55 100644
32292 --- a/arch/x86/net/bpf_jit_comp.c
32293 +++ b/arch/x86/net/bpf_jit_comp.c
32294 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32295 return ptr + len;
32296 }
32297
32298 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32299 +#define MAX_INSTR_CODE_SIZE 96
32300 +#else
32301 +#define MAX_INSTR_CODE_SIZE 64
32302 +#endif
32303 +
32304 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32305
32306 #define EMIT1(b1) EMIT(b1, 1)
32307 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32308 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32309 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32310 +
32311 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32312 +/* original constant will appear in ecx */
32313 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32314 +do { \
32315 + /* mov ecx, randkey */ \
32316 + EMIT1(0xb9); \
32317 + EMIT(_key, 4); \
32318 + /* xor ecx, randkey ^ off */ \
32319 + EMIT2(0x81, 0xf1); \
32320 + EMIT((_key) ^ (_off), 4); \
32321 +} while (0)
32322 +
32323 +#define EMIT1_off32(b1, _off) \
32324 +do { \
32325 + switch (b1) { \
32326 + case 0x05: /* add eax, imm32 */ \
32327 + case 0x2d: /* sub eax, imm32 */ \
32328 + case 0x25: /* and eax, imm32 */ \
32329 + case 0x0d: /* or eax, imm32 */ \
32330 + case 0xb8: /* mov eax, imm32 */ \
32331 + case 0x35: /* xor eax, imm32 */ \
32332 + case 0x3d: /* cmp eax, imm32 */ \
32333 + case 0xa9: /* test eax, imm32 */ \
32334 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32335 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32336 + break; \
32337 + case 0xbb: /* mov ebx, imm32 */ \
32338 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32339 + /* mov ebx, ecx */ \
32340 + EMIT2(0x89, 0xcb); \
32341 + break; \
32342 + case 0xbe: /* mov esi, imm32 */ \
32343 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32344 + /* mov esi, ecx */ \
32345 + EMIT2(0x89, 0xce); \
32346 + break; \
32347 + case 0xe8: /* call rel imm32, always to known funcs */ \
32348 + EMIT1(b1); \
32349 + EMIT(_off, 4); \
32350 + break; \
32351 + case 0xe9: /* jmp rel imm32 */ \
32352 + EMIT1(b1); \
32353 + EMIT(_off, 4); \
32354 + /* prevent fall-through, we're not called if off = 0 */ \
32355 + EMIT(0xcccccccc, 4); \
32356 + EMIT(0xcccccccc, 4); \
32357 + break; \
32358 + default: \
32359 + BUILD_BUG(); \
32360 + } \
32361 +} while (0)
32362 +
32363 +#define EMIT2_off32(b1, b2, _off) \
32364 +do { \
32365 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32366 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32367 + EMIT(randkey, 4); \
32368 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32369 + EMIT((_off) - randkey, 4); \
32370 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32371 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32372 + /* imul eax, ecx */ \
32373 + EMIT3(0x0f, 0xaf, 0xc1); \
32374 + } else { \
32375 + BUILD_BUG(); \
32376 + } \
32377 +} while (0)
32378 +#else
32379 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32380 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32381 +#endif
32382
32383 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32384 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32385 @@ -91,6 +168,24 @@ do { \
32386 #define X86_JBE 0x76
32387 #define X86_JA 0x77
32388
32389 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32390 +#define APPEND_FLOW_VERIFY() \
32391 +do { \
32392 + /* mov ecx, randkey */ \
32393 + EMIT1(0xb9); \
32394 + EMIT(randkey, 4); \
32395 + /* cmp ecx, randkey */ \
32396 + EMIT2(0x81, 0xf9); \
32397 + EMIT(randkey, 4); \
32398 + /* jz after 8 int 3s */ \
32399 + EMIT2(0x74, 0x08); \
32400 + EMIT(0xcccccccc, 4); \
32401 + EMIT(0xcccccccc, 4); \
32402 +} while (0)
32403 +#else
32404 +#define APPEND_FLOW_VERIFY() do { } while (0)
32405 +#endif
32406 +
32407 #define EMIT_COND_JMP(op, offset) \
32408 do { \
32409 if (is_near(offset)) \
32410 @@ -98,6 +193,7 @@ do { \
32411 else { \
32412 EMIT2(0x0f, op + 0x10); \
32413 EMIT(offset, 4); /* jxx .+off32 */ \
32414 + APPEND_FLOW_VERIFY(); \
32415 } \
32416 } while (0)
32417
32418 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32419 return -1;
32420 }
32421
32422 -struct bpf_binary_header {
32423 - unsigned int pages;
32424 - /* Note : for security reasons, bpf code will follow a randomly
32425 - * sized amount of int3 instructions
32426 - */
32427 - u8 image[];
32428 -};
32429 -
32430 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32431 +/* Note : for security reasons, bpf code will follow a randomly
32432 + * sized amount of int3 instructions
32433 + */
32434 +static u8 *bpf_alloc_binary(unsigned int proglen,
32435 u8 **image_ptr)
32436 {
32437 unsigned int sz, hole;
32438 - struct bpf_binary_header *header;
32439 + u8 *header;
32440
32441 /* Most of BPF filters are really small,
32442 * but if some of them fill a page, allow at least
32443 * 128 extra bytes to insert a random section of int3
32444 */
32445 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32446 - header = module_alloc(sz);
32447 + sz = round_up(proglen + 128, PAGE_SIZE);
32448 + header = module_alloc_exec(sz);
32449 if (!header)
32450 return NULL;
32451
32452 + pax_open_kernel();
32453 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32454 + pax_close_kernel();
32455
32456 - header->pages = sz / PAGE_SIZE;
32457 - hole = sz - (proglen + sizeof(*header));
32458 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32459
32460 /* insert a random number of int3 instructions before BPF code */
32461 - *image_ptr = &header->image[prandom_u32() % hole];
32462 + *image_ptr = &header[prandom_u32() % hole];
32463 return header;
32464 }
32465
32466 void bpf_jit_compile(struct sk_filter *fp)
32467 {
32468 - u8 temp[64];
32469 + u8 temp[MAX_INSTR_CODE_SIZE];
32470 u8 *prog;
32471 unsigned int proglen, oldproglen = 0;
32472 int ilen, i;
32473 int t_offset, f_offset;
32474 u8 t_op, f_op, seen = 0, pass;
32475 u8 *image = NULL;
32476 - struct bpf_binary_header *header = NULL;
32477 + u8 *header = NULL;
32478 u8 *func;
32479 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32480 unsigned int cleanup_addr; /* epilogue code offset */
32481 unsigned int *addrs;
32482 const struct sock_filter *filter = fp->insns;
32483 int flen = fp->len;
32484 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32485 + unsigned int randkey;
32486 +#endif
32487
32488 if (!bpf_jit_enable)
32489 return;
32490 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32491 if (addrs == NULL)
32492 return;
32493
32494 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32495 + randkey = get_random_int();
32496 +#endif
32497 +
32498 /* Before first pass, make a rough estimation of addrs[]
32499 - * each bpf instruction is translated to less than 64 bytes
32500 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32501 */
32502 for (proglen = 0, i = 0; i < flen; i++) {
32503 - proglen += 64;
32504 + proglen += MAX_INSTR_CODE_SIZE;
32505 addrs[i] = proglen;
32506 }
32507 cleanup_addr = proglen; /* epilogue address */
32508 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32509 case BPF_S_ALU_MUL_K: /* A *= K */
32510 if (is_imm8(K))
32511 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32512 - else {
32513 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32514 - EMIT(K, 4);
32515 - }
32516 + else
32517 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32518 break;
32519 case BPF_S_ALU_DIV_X: /* A /= X; */
32520 seen |= SEEN_XREG;
32521 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32522 break;
32523 case BPF_S_ALU_MOD_K: /* A %= K; */
32524 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32525 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32526 + DILUTE_CONST_SEQUENCE(K, randkey);
32527 +#else
32528 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32529 +#endif
32530 EMIT2(0xf7, 0xf1); /* div %ecx */
32531 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32532 break;
32533 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32534 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32535 + DILUTE_CONST_SEQUENCE(K, randkey);
32536 + // imul rax, rcx
32537 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32538 +#else
32539 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32540 EMIT(K, 4);
32541 +#endif
32542 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32543 break;
32544 case BPF_S_ALU_AND_X:
32545 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32546 if (is_imm8(K)) {
32547 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32548 } else {
32549 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32550 - EMIT(K, 4);
32551 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32552 }
32553 } else {
32554 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32555 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32556 if (unlikely(proglen + ilen > oldproglen)) {
32557 pr_err("bpb_jit_compile fatal error\n");
32558 kfree(addrs);
32559 - module_free(NULL, header);
32560 + module_free_exec(NULL, image);
32561 return;
32562 }
32563 + pax_open_kernel();
32564 memcpy(image + proglen, temp, ilen);
32565 + pax_close_kernel();
32566 }
32567 proglen += ilen;
32568 addrs[i] = proglen;
32569 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32570
32571 if (image) {
32572 bpf_flush_icache(header, image + proglen);
32573 - set_memory_ro((unsigned long)header, header->pages);
32574 fp->bpf_func = (void *)image;
32575 }
32576 out:
32577 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
32578 {
32579 struct sk_filter *fp = container_of(work, struct sk_filter, work);
32580 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32581 - struct bpf_binary_header *header = (void *)addr;
32582
32583 - set_memory_rw(addr, header->pages);
32584 - module_free(NULL, header);
32585 + set_memory_rw(addr, 1);
32586 + module_free_exec(NULL, (void *)addr);
32587 kfree(fp);
32588 }
32589
32590 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32591 index d6aa6e8..266395a 100644
32592 --- a/arch/x86/oprofile/backtrace.c
32593 +++ b/arch/x86/oprofile/backtrace.c
32594 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32595 struct stack_frame_ia32 *fp;
32596 unsigned long bytes;
32597
32598 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32599 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32600 if (bytes != sizeof(bufhead))
32601 return NULL;
32602
32603 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32604 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32605
32606 oprofile_add_trace(bufhead[0].return_address);
32607
32608 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32609 struct stack_frame bufhead[2];
32610 unsigned long bytes;
32611
32612 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32613 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32614 if (bytes != sizeof(bufhead))
32615 return NULL;
32616
32617 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32618 {
32619 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32620
32621 - if (!user_mode_vm(regs)) {
32622 + if (!user_mode(regs)) {
32623 unsigned long stack = kernel_stack_pointer(regs);
32624 if (depth)
32625 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32626 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32627 index 6890d84..1dad1f1 100644
32628 --- a/arch/x86/oprofile/nmi_int.c
32629 +++ b/arch/x86/oprofile/nmi_int.c
32630 @@ -23,6 +23,7 @@
32631 #include <asm/nmi.h>
32632 #include <asm/msr.h>
32633 #include <asm/apic.h>
32634 +#include <asm/pgtable.h>
32635
32636 #include "op_counter.h"
32637 #include "op_x86_model.h"
32638 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32639 if (ret)
32640 return ret;
32641
32642 - if (!model->num_virt_counters)
32643 - model->num_virt_counters = model->num_counters;
32644 + if (!model->num_virt_counters) {
32645 + pax_open_kernel();
32646 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32647 + pax_close_kernel();
32648 + }
32649
32650 mux_init(ops);
32651
32652 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32653 index 50d86c0..7985318 100644
32654 --- a/arch/x86/oprofile/op_model_amd.c
32655 +++ b/arch/x86/oprofile/op_model_amd.c
32656 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32657 num_counters = AMD64_NUM_COUNTERS;
32658 }
32659
32660 - op_amd_spec.num_counters = num_counters;
32661 - op_amd_spec.num_controls = num_counters;
32662 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32663 + pax_open_kernel();
32664 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32665 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32666 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_close_kernel();
32668
32669 return 0;
32670 }
32671 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32672 index d90528e..0127e2b 100644
32673 --- a/arch/x86/oprofile/op_model_ppro.c
32674 +++ b/arch/x86/oprofile/op_model_ppro.c
32675 @@ -19,6 +19,7 @@
32676 #include <asm/msr.h>
32677 #include <asm/apic.h>
32678 #include <asm/nmi.h>
32679 +#include <asm/pgtable.h>
32680
32681 #include "op_x86_model.h"
32682 #include "op_counter.h"
32683 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32684
32685 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32686
32687 - op_arch_perfmon_spec.num_counters = num_counters;
32688 - op_arch_perfmon_spec.num_controls = num_counters;
32689 + pax_open_kernel();
32690 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32691 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32692 + pax_close_kernel();
32693 }
32694
32695 static int arch_perfmon_init(struct oprofile_operations *ignore)
32696 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32697 index 71e8a67..6a313bb 100644
32698 --- a/arch/x86/oprofile/op_x86_model.h
32699 +++ b/arch/x86/oprofile/op_x86_model.h
32700 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32701 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32702 struct op_msrs const * const msrs);
32703 #endif
32704 -};
32705 +} __do_const;
32706
32707 struct op_counter_config;
32708
32709 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32710 index 372e9b8..e775a6c 100644
32711 --- a/arch/x86/pci/irq.c
32712 +++ b/arch/x86/pci/irq.c
32713 @@ -50,7 +50,7 @@ struct irq_router {
32714 struct irq_router_handler {
32715 u16 vendor;
32716 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32717 -};
32718 +} __do_const;
32719
32720 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32721 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32722 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32723 return 0;
32724 }
32725
32726 -static __initdata struct irq_router_handler pirq_routers[] = {
32727 +static __initconst const struct irq_router_handler pirq_routers[] = {
32728 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32729 { PCI_VENDOR_ID_AL, ali_router_probe },
32730 { PCI_VENDOR_ID_ITE, ite_router_probe },
32731 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32732 static void __init pirq_find_router(struct irq_router *r)
32733 {
32734 struct irq_routing_table *rt = pirq_table;
32735 - struct irq_router_handler *h;
32736 + const struct irq_router_handler *h;
32737
32738 #ifdef CONFIG_PCI_BIOS
32739 if (!rt->signature) {
32740 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32741 return 0;
32742 }
32743
32744 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32745 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32746 {
32747 .callback = fix_broken_hp_bios_irq9,
32748 .ident = "HP Pavilion N5400 Series Laptop",
32749 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32750 index 903fded..94b0d88 100644
32751 --- a/arch/x86/pci/mrst.c
32752 +++ b/arch/x86/pci/mrst.c
32753 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
32754 pr_info("Intel MID platform detected, using MID PCI ops\n");
32755 pci_mmcfg_late_init();
32756 pcibios_enable_irq = mrst_pci_irq_enable;
32757 - pci_root_ops = pci_mrst_ops;
32758 + pax_open_kernel();
32759 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32760 + pax_close_kernel();
32761 pci_soc_mode = 1;
32762 /* Continue with standard init */
32763 return 1;
32764 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32765 index c77b24a..c979855 100644
32766 --- a/arch/x86/pci/pcbios.c
32767 +++ b/arch/x86/pci/pcbios.c
32768 @@ -79,7 +79,7 @@ union bios32 {
32769 static struct {
32770 unsigned long address;
32771 unsigned short segment;
32772 -} bios32_indirect = { 0, __KERNEL_CS };
32773 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32774
32775 /*
32776 * Returns the entry point for the given service, NULL on error
32777 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32778 unsigned long length; /* %ecx */
32779 unsigned long entry; /* %edx */
32780 unsigned long flags;
32781 + struct desc_struct d, *gdt;
32782
32783 local_irq_save(flags);
32784 - __asm__("lcall *(%%edi); cld"
32785 +
32786 + gdt = get_cpu_gdt_table(smp_processor_id());
32787 +
32788 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32789 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32790 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32791 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32792 +
32793 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32794 : "=a" (return_code),
32795 "=b" (address),
32796 "=c" (length),
32797 "=d" (entry)
32798 : "0" (service),
32799 "1" (0),
32800 - "D" (&bios32_indirect));
32801 + "D" (&bios32_indirect),
32802 + "r"(__PCIBIOS_DS)
32803 + : "memory");
32804 +
32805 + pax_open_kernel();
32806 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32807 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32808 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32809 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32810 + pax_close_kernel();
32811 +
32812 local_irq_restore(flags);
32813
32814 switch (return_code) {
32815 - case 0:
32816 - return address + entry;
32817 - case 0x80: /* Not present */
32818 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32819 - return 0;
32820 - default: /* Shouldn't happen */
32821 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32822 - service, return_code);
32823 + case 0: {
32824 + int cpu;
32825 + unsigned char flags;
32826 +
32827 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32828 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32829 + printk(KERN_WARNING "bios32_service: not valid\n");
32830 return 0;
32831 + }
32832 + address = address + PAGE_OFFSET;
32833 + length += 16UL; /* some BIOSs underreport this... */
32834 + flags = 4;
32835 + if (length >= 64*1024*1024) {
32836 + length >>= PAGE_SHIFT;
32837 + flags |= 8;
32838 + }
32839 +
32840 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32841 + gdt = get_cpu_gdt_table(cpu);
32842 + pack_descriptor(&d, address, length, 0x9b, flags);
32843 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32844 + pack_descriptor(&d, address, length, 0x93, flags);
32845 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32846 + }
32847 + return entry;
32848 + }
32849 + case 0x80: /* Not present */
32850 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32851 + return 0;
32852 + default: /* Shouldn't happen */
32853 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32854 + service, return_code);
32855 + return 0;
32856 }
32857 }
32858
32859 static struct {
32860 unsigned long address;
32861 unsigned short segment;
32862 -} pci_indirect = { 0, __KERNEL_CS };
32863 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32864
32865 -static int pci_bios_present;
32866 +static int pci_bios_present __read_only;
32867
32868 static int check_pcibios(void)
32869 {
32870 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32871 unsigned long flags, pcibios_entry;
32872
32873 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32874 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32875 + pci_indirect.address = pcibios_entry;
32876
32877 local_irq_save(flags);
32878 - __asm__(
32879 - "lcall *(%%edi); cld\n\t"
32880 + __asm__("movw %w6, %%ds\n\t"
32881 + "lcall *%%ss:(%%edi); cld\n\t"
32882 + "push %%ss\n\t"
32883 + "pop %%ds\n\t"
32884 "jc 1f\n\t"
32885 "xor %%ah, %%ah\n"
32886 "1:"
32887 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32888 "=b" (ebx),
32889 "=c" (ecx)
32890 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32891 - "D" (&pci_indirect)
32892 + "D" (&pci_indirect),
32893 + "r" (__PCIBIOS_DS)
32894 : "memory");
32895 local_irq_restore(flags);
32896
32897 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32898
32899 switch (len) {
32900 case 1:
32901 - __asm__("lcall *(%%esi); cld\n\t"
32902 + __asm__("movw %w6, %%ds\n\t"
32903 + "lcall *%%ss:(%%esi); cld\n\t"
32904 + "push %%ss\n\t"
32905 + "pop %%ds\n\t"
32906 "jc 1f\n\t"
32907 "xor %%ah, %%ah\n"
32908 "1:"
32909 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32910 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32911 "b" (bx),
32912 "D" ((long)reg),
32913 - "S" (&pci_indirect));
32914 + "S" (&pci_indirect),
32915 + "r" (__PCIBIOS_DS));
32916 /*
32917 * Zero-extend the result beyond 8 bits, do not trust the
32918 * BIOS having done it:
32919 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32920 *value &= 0xff;
32921 break;
32922 case 2:
32923 - __asm__("lcall *(%%esi); cld\n\t"
32924 + __asm__("movw %w6, %%ds\n\t"
32925 + "lcall *%%ss:(%%esi); cld\n\t"
32926 + "push %%ss\n\t"
32927 + "pop %%ds\n\t"
32928 "jc 1f\n\t"
32929 "xor %%ah, %%ah\n"
32930 "1:"
32931 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32932 : "1" (PCIBIOS_READ_CONFIG_WORD),
32933 "b" (bx),
32934 "D" ((long)reg),
32935 - "S" (&pci_indirect));
32936 + "S" (&pci_indirect),
32937 + "r" (__PCIBIOS_DS));
32938 /*
32939 * Zero-extend the result beyond 16 bits, do not trust the
32940 * BIOS having done it:
32941 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32942 *value &= 0xffff;
32943 break;
32944 case 4:
32945 - __asm__("lcall *(%%esi); cld\n\t"
32946 + __asm__("movw %w6, %%ds\n\t"
32947 + "lcall *%%ss:(%%esi); cld\n\t"
32948 + "push %%ss\n\t"
32949 + "pop %%ds\n\t"
32950 "jc 1f\n\t"
32951 "xor %%ah, %%ah\n"
32952 "1:"
32953 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32954 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32955 "b" (bx),
32956 "D" ((long)reg),
32957 - "S" (&pci_indirect));
32958 + "S" (&pci_indirect),
32959 + "r" (__PCIBIOS_DS));
32960 break;
32961 }
32962
32963 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32964
32965 switch (len) {
32966 case 1:
32967 - __asm__("lcall *(%%esi); cld\n\t"
32968 + __asm__("movw %w6, %%ds\n\t"
32969 + "lcall *%%ss:(%%esi); cld\n\t"
32970 + "push %%ss\n\t"
32971 + "pop %%ds\n\t"
32972 "jc 1f\n\t"
32973 "xor %%ah, %%ah\n"
32974 "1:"
32975 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32976 "c" (value),
32977 "b" (bx),
32978 "D" ((long)reg),
32979 - "S" (&pci_indirect));
32980 + "S" (&pci_indirect),
32981 + "r" (__PCIBIOS_DS));
32982 break;
32983 case 2:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 4:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 }
33018
33019 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33020
33021 DBG("PCI: Fetching IRQ routing table... ");
33022 __asm__("push %%es\n\t"
33023 + "movw %w8, %%ds\n\t"
33024 "push %%ds\n\t"
33025 "pop %%es\n\t"
33026 - "lcall *(%%esi); cld\n\t"
33027 + "lcall *%%ss:(%%esi); cld\n\t"
33028 "pop %%es\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33035 "1" (0),
33036 "D" ((long) &opt),
33037 "S" (&pci_indirect),
33038 - "m" (opt)
33039 + "m" (opt),
33040 + "r" (__PCIBIOS_DS)
33041 : "memory");
33042 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33043 if (ret & 0xff00)
33044 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33045 {
33046 int ret;
33047
33048 - __asm__("lcall *(%%esi); cld\n\t"
33049 + __asm__("movw %w5, %%ds\n\t"
33050 + "lcall *%%ss:(%%esi); cld\n\t"
33051 + "push %%ss\n\t"
33052 + "pop %%ds\n"
33053 "jc 1f\n\t"
33054 "xor %%ah, %%ah\n"
33055 "1:"
33056 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33057 : "0" (PCIBIOS_SET_PCI_HW_INT),
33058 "b" ((dev->bus->number << 8) | dev->devfn),
33059 "c" ((irq << 8) | (pin + 10)),
33060 - "S" (&pci_indirect));
33061 + "S" (&pci_indirect),
33062 + "r" (__PCIBIOS_DS));
33063 return !(ret & 0xff00);
33064 }
33065 EXPORT_SYMBOL(pcibios_set_irq_routing);
33066 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33067 index 40e4469..d915bf9 100644
33068 --- a/arch/x86/platform/efi/efi_32.c
33069 +++ b/arch/x86/platform/efi/efi_32.c
33070 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33071 {
33072 struct desc_ptr gdt_descr;
33073
33074 +#ifdef CONFIG_PAX_KERNEXEC
33075 + struct desc_struct d;
33076 +#endif
33077 +
33078 local_irq_save(efi_rt_eflags);
33079
33080 load_cr3(initial_page_table);
33081 __flush_tlb_all();
33082
33083 +#ifdef CONFIG_PAX_KERNEXEC
33084 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33085 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33086 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33087 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33088 +#endif
33089 +
33090 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33091 gdt_descr.size = GDT_SIZE - 1;
33092 load_gdt(&gdt_descr);
33093 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33094 {
33095 struct desc_ptr gdt_descr;
33096
33097 +#ifdef CONFIG_PAX_KERNEXEC
33098 + struct desc_struct d;
33099 +
33100 + memset(&d, 0, sizeof d);
33101 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33103 +#endif
33104 +
33105 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33106 gdt_descr.size = GDT_SIZE - 1;
33107 load_gdt(&gdt_descr);
33108
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#else
33112 load_cr3(swapper_pg_dir);
33113 +#endif
33114 +
33115 __flush_tlb_all();
33116
33117 local_irq_restore(efi_rt_eflags);
33118 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33119 index 39a0e7f1..872396e 100644
33120 --- a/arch/x86/platform/efi/efi_64.c
33121 +++ b/arch/x86/platform/efi/efi_64.c
33122 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33123 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33124 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33125 }
33126 +
33127 +#ifdef CONFIG_PAX_PER_CPU_PGD
33128 + load_cr3(swapper_pg_dir);
33129 +#endif
33130 +
33131 __flush_tlb_all();
33132 }
33133
33134 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33135 for (pgd = 0; pgd < n_pgds; pgd++)
33136 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33137 kfree(save_pgd);
33138 +
33139 +#ifdef CONFIG_PAX_PER_CPU_PGD
33140 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33141 +#endif
33142 +
33143 __flush_tlb_all();
33144 local_irq_restore(efi_flags);
33145 early_code_mapping_set_exec(0);
33146 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33147 index fbe66e6..eae5e38 100644
33148 --- a/arch/x86/platform/efi/efi_stub_32.S
33149 +++ b/arch/x86/platform/efi/efi_stub_32.S
33150 @@ -6,7 +6,9 @@
33151 */
33152
33153 #include <linux/linkage.h>
33154 +#include <linux/init.h>
33155 #include <asm/page_types.h>
33156 +#include <asm/segment.h>
33157
33158 /*
33159 * efi_call_phys(void *, ...) is a function with variable parameters.
33160 @@ -20,7 +22,7 @@
33161 * service functions will comply with gcc calling convention, too.
33162 */
33163
33164 -.text
33165 +__INIT
33166 ENTRY(efi_call_phys)
33167 /*
33168 * 0. The function can only be called in Linux kernel. So CS has been
33169 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33170 * The mapping of lower virtual memory has been created in prelog and
33171 * epilog.
33172 */
33173 - movl $1f, %edx
33174 - subl $__PAGE_OFFSET, %edx
33175 - jmp *%edx
33176 +#ifdef CONFIG_PAX_KERNEXEC
33177 + movl $(__KERNEXEC_EFI_DS), %edx
33178 + mov %edx, %ds
33179 + mov %edx, %es
33180 + mov %edx, %ss
33181 + addl $2f,(1f)
33182 + ljmp *(1f)
33183 +
33184 +__INITDATA
33185 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33186 +.previous
33187 +
33188 +2:
33189 + subl $2b,(1b)
33190 +#else
33191 + jmp 1f-__PAGE_OFFSET
33192 1:
33193 +#endif
33194
33195 /*
33196 * 2. Now on the top of stack is the return
33197 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33198 * parameter 2, ..., param n. To make things easy, we save the return
33199 * address of efi_call_phys in a global variable.
33200 */
33201 - popl %edx
33202 - movl %edx, saved_return_addr
33203 - /* get the function pointer into ECX*/
33204 - popl %ecx
33205 - movl %ecx, efi_rt_function_ptr
33206 - movl $2f, %edx
33207 - subl $__PAGE_OFFSET, %edx
33208 - pushl %edx
33209 + popl (saved_return_addr)
33210 + popl (efi_rt_function_ptr)
33211
33212 /*
33213 * 3. Clear PG bit in %CR0.
33214 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33215 /*
33216 * 5. Call the physical function.
33217 */
33218 - jmp *%ecx
33219 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33220
33221 -2:
33222 /*
33223 * 6. After EFI runtime service returns, control will return to
33224 * following instruction. We'd better readjust stack pointer first.
33225 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33226 movl %cr0, %edx
33227 orl $0x80000000, %edx
33228 movl %edx, %cr0
33229 - jmp 1f
33230 -1:
33231 +
33232 /*
33233 * 8. Now restore the virtual mode from flat mode by
33234 * adding EIP with PAGE_OFFSET.
33235 */
33236 - movl $1f, %edx
33237 - jmp *%edx
33238 +#ifdef CONFIG_PAX_KERNEXEC
33239 + movl $(__KERNEL_DS), %edx
33240 + mov %edx, %ds
33241 + mov %edx, %es
33242 + mov %edx, %ss
33243 + ljmp $(__KERNEL_CS),$1f
33244 +#else
33245 + jmp 1f+__PAGE_OFFSET
33246 +#endif
33247 1:
33248
33249 /*
33250 * 9. Balance the stack. And because EAX contain the return value,
33251 * we'd better not clobber it.
33252 */
33253 - leal efi_rt_function_ptr, %edx
33254 - movl (%edx), %ecx
33255 - pushl %ecx
33256 + pushl (efi_rt_function_ptr)
33257
33258 /*
33259 - * 10. Push the saved return address onto the stack and return.
33260 + * 10. Return to the saved return address.
33261 */
33262 - leal saved_return_addr, %edx
33263 - movl (%edx), %ecx
33264 - pushl %ecx
33265 - ret
33266 + jmpl *(saved_return_addr)
33267 ENDPROC(efi_call_phys)
33268 .previous
33269
33270 -.data
33271 +__INITDATA
33272 saved_return_addr:
33273 .long 0
33274 efi_rt_function_ptr:
33275 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33276 index 4c07cca..2c8427d 100644
33277 --- a/arch/x86/platform/efi/efi_stub_64.S
33278 +++ b/arch/x86/platform/efi/efi_stub_64.S
33279 @@ -7,6 +7,7 @@
33280 */
33281
33282 #include <linux/linkage.h>
33283 +#include <asm/alternative-asm.h>
33284
33285 #define SAVE_XMM \
33286 mov %rsp, %rax; \
33287 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33288 call *%rdi
33289 addq $32, %rsp
33290 RESTORE_XMM
33291 + pax_force_retaddr 0, 1
33292 ret
33293 ENDPROC(efi_call0)
33294
33295 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33296 call *%rdi
33297 addq $32, %rsp
33298 RESTORE_XMM
33299 + pax_force_retaddr 0, 1
33300 ret
33301 ENDPROC(efi_call1)
33302
33303 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33304 call *%rdi
33305 addq $32, %rsp
33306 RESTORE_XMM
33307 + pax_force_retaddr 0, 1
33308 ret
33309 ENDPROC(efi_call2)
33310
33311 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33312 call *%rdi
33313 addq $32, %rsp
33314 RESTORE_XMM
33315 + pax_force_retaddr 0, 1
33316 ret
33317 ENDPROC(efi_call3)
33318
33319 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33320 call *%rdi
33321 addq $32, %rsp
33322 RESTORE_XMM
33323 + pax_force_retaddr 0, 1
33324 ret
33325 ENDPROC(efi_call4)
33326
33327 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33328 call *%rdi
33329 addq $48, %rsp
33330 RESTORE_XMM
33331 + pax_force_retaddr 0, 1
33332 ret
33333 ENDPROC(efi_call5)
33334
33335 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33336 call *%rdi
33337 addq $48, %rsp
33338 RESTORE_XMM
33339 + pax_force_retaddr 0, 1
33340 ret
33341 ENDPROC(efi_call6)
33342 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33343 index 3ca5957..7909c18 100644
33344 --- a/arch/x86/platform/mrst/mrst.c
33345 +++ b/arch/x86/platform/mrst/mrst.c
33346 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33347 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33348 int sfi_mrtc_num;
33349
33350 -static void mrst_power_off(void)
33351 +static __noreturn void mrst_power_off(void)
33352 {
33353 + BUG();
33354 }
33355
33356 -static void mrst_reboot(void)
33357 +static __noreturn void mrst_reboot(void)
33358 {
33359 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33360 + BUG();
33361 }
33362
33363 /* parse all the mtimer info to a static mtimer array */
33364 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33365 index d6ee929..3637cb5 100644
33366 --- a/arch/x86/platform/olpc/olpc_dt.c
33367 +++ b/arch/x86/platform/olpc/olpc_dt.c
33368 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33369 return res;
33370 }
33371
33372 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33373 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33374 .nextprop = olpc_dt_nextprop,
33375 .getproplen = olpc_dt_getproplen,
33376 .getproperty = olpc_dt_getproperty,
33377 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33378 index 424f4c9..f2a2988 100644
33379 --- a/arch/x86/power/cpu.c
33380 +++ b/arch/x86/power/cpu.c
33381 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33382 static void fix_processor_context(void)
33383 {
33384 int cpu = smp_processor_id();
33385 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33386 -#ifdef CONFIG_X86_64
33387 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33388 - tss_desc tss;
33389 -#endif
33390 + struct tss_struct *t = init_tss + cpu;
33391 +
33392 set_tss_desc(cpu, t); /*
33393 * This just modifies memory; should not be
33394 * necessary. But... This is necessary, because
33395 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33396 */
33397
33398 #ifdef CONFIG_X86_64
33399 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33400 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33401 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33402 -
33403 syscall_init(); /* This sets MSR_*STAR and related */
33404 #endif
33405 load_TR_desc(); /* This does ltr */
33406 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33407 index a44f457..9140171 100644
33408 --- a/arch/x86/realmode/init.c
33409 +++ b/arch/x86/realmode/init.c
33410 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33411 __va(real_mode_header->trampoline_header);
33412
33413 #ifdef CONFIG_X86_32
33414 - trampoline_header->start = __pa_symbol(startup_32_smp);
33415 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33416 +
33417 +#ifdef CONFIG_PAX_KERNEXEC
33418 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33419 +#endif
33420 +
33421 + trampoline_header->boot_cs = __BOOT_CS;
33422 trampoline_header->gdt_limit = __BOOT_DS + 7;
33423 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33424 #else
33425 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33426 *trampoline_cr4_features = read_cr4();
33427
33428 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33429 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33430 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33431 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33432 #endif
33433 }
33434 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33435 index 8869287..d577672 100644
33436 --- a/arch/x86/realmode/rm/Makefile
33437 +++ b/arch/x86/realmode/rm/Makefile
33438 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33439 $(call cc-option, -fno-unit-at-a-time)) \
33440 $(call cc-option, -fno-stack-protector) \
33441 $(call cc-option, -mpreferred-stack-boundary=2)
33442 +ifdef CONSTIFY_PLUGIN
33443 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33444 +endif
33445 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33446 GCOV_PROFILE := n
33447 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33448 index a28221d..93c40f1 100644
33449 --- a/arch/x86/realmode/rm/header.S
33450 +++ b/arch/x86/realmode/rm/header.S
33451 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33452 #endif
33453 /* APM/BIOS reboot */
33454 .long pa_machine_real_restart_asm
33455 -#ifdef CONFIG_X86_64
33456 +#ifdef CONFIG_X86_32
33457 + .long __KERNEL_CS
33458 +#else
33459 .long __KERNEL32_CS
33460 #endif
33461 END(real_mode_header)
33462 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33463 index c1b2791..f9e31c7 100644
33464 --- a/arch/x86/realmode/rm/trampoline_32.S
33465 +++ b/arch/x86/realmode/rm/trampoline_32.S
33466 @@ -25,6 +25,12 @@
33467 #include <asm/page_types.h>
33468 #include "realmode.h"
33469
33470 +#ifdef CONFIG_PAX_KERNEXEC
33471 +#define ta(X) (X)
33472 +#else
33473 +#define ta(X) (pa_ ## X)
33474 +#endif
33475 +
33476 .text
33477 .code16
33478
33479 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33480
33481 cli # We should be safe anyway
33482
33483 - movl tr_start, %eax # where we need to go
33484 -
33485 movl $0xA5A5A5A5, trampoline_status
33486 # write marker for master knows we're running
33487
33488 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33489 movw $1, %dx # protected mode (PE) bit
33490 lmsw %dx # into protected mode
33491
33492 - ljmpl $__BOOT_CS, $pa_startup_32
33493 + ljmpl *(trampoline_header)
33494
33495 .section ".text32","ax"
33496 .code32
33497 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33498 .balign 8
33499 GLOBAL(trampoline_header)
33500 tr_start: .space 4
33501 - tr_gdt_pad: .space 2
33502 + tr_boot_cs: .space 2
33503 tr_gdt: .space 6
33504 END(trampoline_header)
33505
33506 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33507 index bb360dc..d0fd8f8 100644
33508 --- a/arch/x86/realmode/rm/trampoline_64.S
33509 +++ b/arch/x86/realmode/rm/trampoline_64.S
33510 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33511 movl %edx, %gs
33512
33513 movl pa_tr_cr4, %eax
33514 + andl $~X86_CR4_PCIDE, %eax
33515 movl %eax, %cr4 # Enable PAE mode
33516
33517 # Setup trampoline 4 level pagetables
33518 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33519 wrmsr
33520
33521 # Enable paging and in turn activate Long Mode
33522 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33523 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33524 movl %eax, %cr0
33525
33526 /*
33527 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33528 index e812034..c747134 100644
33529 --- a/arch/x86/tools/Makefile
33530 +++ b/arch/x86/tools/Makefile
33531 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33532
33533 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
33534
33535 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33536 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33537 hostprogs-y += relocs
33538 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33539 relocs: $(obj)/relocs
33540 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33541 index f7bab68..b6d9886 100644
33542 --- a/arch/x86/tools/relocs.c
33543 +++ b/arch/x86/tools/relocs.c
33544 @@ -1,5 +1,7 @@
33545 /* This is included from relocs_32/64.c */
33546
33547 +#include "../../../include/generated/autoconf.h"
33548 +
33549 #define ElfW(type) _ElfW(ELF_BITS, type)
33550 #define _ElfW(bits, type) __ElfW(bits, type)
33551 #define __ElfW(bits, type) Elf##bits##_##type
33552 @@ -11,6 +13,7 @@
33553 #define Elf_Sym ElfW(Sym)
33554
33555 static Elf_Ehdr ehdr;
33556 +static Elf_Phdr *phdr;
33557
33558 struct relocs {
33559 uint32_t *offset;
33560 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33561 }
33562 }
33563
33564 +static void read_phdrs(FILE *fp)
33565 +{
33566 + unsigned int i;
33567 +
33568 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33569 + if (!phdr) {
33570 + die("Unable to allocate %d program headers\n",
33571 + ehdr.e_phnum);
33572 + }
33573 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33574 + die("Seek to %d failed: %s\n",
33575 + ehdr.e_phoff, strerror(errno));
33576 + }
33577 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33578 + die("Cannot read ELF program headers: %s\n",
33579 + strerror(errno));
33580 + }
33581 + for(i = 0; i < ehdr.e_phnum; i++) {
33582 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33583 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33584 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33585 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33586 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33587 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33588 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33589 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33590 + }
33591 +
33592 +}
33593 +
33594 static void read_shdrs(FILE *fp)
33595 {
33596 - int i;
33597 + unsigned int i;
33598 Elf_Shdr shdr;
33599
33600 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33601 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33602
33603 static void read_strtabs(FILE *fp)
33604 {
33605 - int i;
33606 + unsigned int i;
33607 for (i = 0; i < ehdr.e_shnum; i++) {
33608 struct section *sec = &secs[i];
33609 if (sec->shdr.sh_type != SHT_STRTAB) {
33610 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33611
33612 static void read_symtabs(FILE *fp)
33613 {
33614 - int i,j;
33615 + unsigned int i,j;
33616 for (i = 0; i < ehdr.e_shnum; i++) {
33617 struct section *sec = &secs[i];
33618 if (sec->shdr.sh_type != SHT_SYMTAB) {
33619 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33620 }
33621
33622
33623 -static void read_relocs(FILE *fp)
33624 +static void read_relocs(FILE *fp, int use_real_mode)
33625 {
33626 - int i,j;
33627 + unsigned int i,j;
33628 + uint32_t base;
33629 +
33630 for (i = 0; i < ehdr.e_shnum; i++) {
33631 struct section *sec = &secs[i];
33632 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33633 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33634 die("Cannot read symbol table: %s\n",
33635 strerror(errno));
33636 }
33637 + base = 0;
33638 +
33639 +#ifdef CONFIG_X86_32
33640 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33641 + if (phdr[j].p_type != PT_LOAD )
33642 + continue;
33643 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
33644 + continue;
33645 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33646 + break;
33647 + }
33648 +#endif
33649 +
33650 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33651 Elf_Rel *rel = &sec->reltab[j];
33652 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33653 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33654 rel->r_info = elf_xword_to_cpu(rel->r_info);
33655 #if (SHT_REL_TYPE == SHT_RELA)
33656 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33657 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33658
33659 static void print_absolute_symbols(void)
33660 {
33661 - int i;
33662 + unsigned int i;
33663 const char *format;
33664
33665 if (ELF_BITS == 64)
33666 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33667 for (i = 0; i < ehdr.e_shnum; i++) {
33668 struct section *sec = &secs[i];
33669 char *sym_strtab;
33670 - int j;
33671 + unsigned int j;
33672
33673 if (sec->shdr.sh_type != SHT_SYMTAB) {
33674 continue;
33675 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33676
33677 static void print_absolute_relocs(void)
33678 {
33679 - int i, printed = 0;
33680 + unsigned int i, printed = 0;
33681 const char *format;
33682
33683 if (ELF_BITS == 64)
33684 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33685 struct section *sec_applies, *sec_symtab;
33686 char *sym_strtab;
33687 Elf_Sym *sh_symtab;
33688 - int j;
33689 + unsigned int j;
33690 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33691 continue;
33692 }
33693 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33694 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33695 Elf_Sym *sym, const char *symname))
33696 {
33697 - int i;
33698 + unsigned int i;
33699 /* Walk through the relocations */
33700 for (i = 0; i < ehdr.e_shnum; i++) {
33701 char *sym_strtab;
33702 Elf_Sym *sh_symtab;
33703 struct section *sec_applies, *sec_symtab;
33704 - int j;
33705 + unsigned int j;
33706 struct section *sec = &secs[i];
33707
33708 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33709 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33710 {
33711 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33712 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33713 + char *sym_strtab = sec->link->link->strtab;
33714 +
33715 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33716 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33717 + return 0;
33718 +
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33721 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33722 + return 0;
33723 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33724 + return 0;
33725 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33728 + return 0;
33729 +#endif
33730
33731 switch (r_type) {
33732 case R_386_NONE:
33733 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33734
33735 static void emit_relocs(int as_text, int use_real_mode)
33736 {
33737 - int i;
33738 + unsigned int i;
33739 int (*write_reloc)(uint32_t, FILE *) = write32;
33740 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33741 const char *symname);
33742 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33743 {
33744 regex_init(use_real_mode);
33745 read_ehdr(fp);
33746 + read_phdrs(fp);
33747 read_shdrs(fp);
33748 read_strtabs(fp);
33749 read_symtabs(fp);
33750 - read_relocs(fp);
33751 + read_relocs(fp, use_real_mode);
33752 if (ELF_BITS == 64)
33753 percpu_init();
33754 if (show_absolute_syms) {
33755 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33756 index 80ffa5b..a33bd15 100644
33757 --- a/arch/x86/um/tls_32.c
33758 +++ b/arch/x86/um/tls_32.c
33759 @@ -260,7 +260,7 @@ out:
33760 if (unlikely(task == current &&
33761 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33762 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33763 - "without flushed TLS.", current->pid);
33764 + "without flushed TLS.", task_pid_nr(current));
33765 }
33766
33767 return 0;
33768 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33769 index fd14be1..e3c79c0 100644
33770 --- a/arch/x86/vdso/Makefile
33771 +++ b/arch/x86/vdso/Makefile
33772 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33773 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33774 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33775
33776 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33777 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33778 GCOV_PROFILE := n
33779
33780 #
33781 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33782 index d6bfb87..876ee18 100644
33783 --- a/arch/x86/vdso/vdso32-setup.c
33784 +++ b/arch/x86/vdso/vdso32-setup.c
33785 @@ -25,6 +25,7 @@
33786 #include <asm/tlbflush.h>
33787 #include <asm/vdso.h>
33788 #include <asm/proto.h>
33789 +#include <asm/mman.h>
33790
33791 enum {
33792 VDSO_DISABLED = 0,
33793 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33794 void enable_sep_cpu(void)
33795 {
33796 int cpu = get_cpu();
33797 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33798 + struct tss_struct *tss = init_tss + cpu;
33799
33800 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33801 put_cpu();
33802 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33803 gate_vma.vm_start = FIXADDR_USER_START;
33804 gate_vma.vm_end = FIXADDR_USER_END;
33805 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33806 - gate_vma.vm_page_prot = __P101;
33807 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33808
33809 return 0;
33810 }
33811 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33812 if (compat)
33813 addr = VDSO_HIGH_BASE;
33814 else {
33815 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33816 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33817 if (IS_ERR_VALUE(addr)) {
33818 ret = addr;
33819 goto up_fail;
33820 }
33821 }
33822
33823 - current->mm->context.vdso = (void *)addr;
33824 + current->mm->context.vdso = addr;
33825
33826 if (compat_uses_vma || !compat) {
33827 /*
33828 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 }
33830
33831 current_thread_info()->sysenter_return =
33832 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33833 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33834
33835 up_fail:
33836 if (ret)
33837 - current->mm->context.vdso = NULL;
33838 + current->mm->context.vdso = 0;
33839
33840 up_write(&mm->mmap_sem);
33841
33842 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33843
33844 const char *arch_vma_name(struct vm_area_struct *vma)
33845 {
33846 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33847 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33848 return "[vdso]";
33849 +
33850 +#ifdef CONFIG_PAX_SEGMEXEC
33851 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33852 + return "[vdso]";
33853 +#endif
33854 +
33855 return NULL;
33856 }
33857
33858 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33859 * Check to see if the corresponding task was created in compat vdso
33860 * mode.
33861 */
33862 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33863 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33864 return &gate_vma;
33865 return NULL;
33866 }
33867 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33868 index 431e875..cbb23f3 100644
33869 --- a/arch/x86/vdso/vma.c
33870 +++ b/arch/x86/vdso/vma.c
33871 @@ -16,8 +16,6 @@
33872 #include <asm/vdso.h>
33873 #include <asm/page.h>
33874
33875 -unsigned int __read_mostly vdso_enabled = 1;
33876 -
33877 extern char vdso_start[], vdso_end[];
33878 extern unsigned short vdso_sync_cpuid;
33879
33880 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33881 * unaligned here as a result of stack start randomization.
33882 */
33883 addr = PAGE_ALIGN(addr);
33884 - addr = align_vdso_addr(addr);
33885
33886 return addr;
33887 }
33888 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33889 unsigned size)
33890 {
33891 struct mm_struct *mm = current->mm;
33892 - unsigned long addr;
33893 + unsigned long addr = 0;
33894 int ret;
33895
33896 - if (!vdso_enabled)
33897 - return 0;
33898 -
33899 down_write(&mm->mmap_sem);
33900 +
33901 +#ifdef CONFIG_PAX_RANDMMAP
33902 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33903 +#endif
33904 +
33905 addr = vdso_addr(mm->start_stack, size);
33906 + addr = align_vdso_addr(addr);
33907 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33908 if (IS_ERR_VALUE(addr)) {
33909 ret = addr;
33910 goto up_fail;
33911 }
33912
33913 - current->mm->context.vdso = (void *)addr;
33914 + mm->context.vdso = addr;
33915
33916 ret = install_special_mapping(mm, addr, size,
33917 VM_READ|VM_EXEC|
33918 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33919 pages);
33920 - if (ret) {
33921 - current->mm->context.vdso = NULL;
33922 - goto up_fail;
33923 - }
33924 + if (ret)
33925 + mm->context.vdso = 0;
33926
33927 up_fail:
33928 up_write(&mm->mmap_sem);
33929 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33930 vdsox32_size);
33931 }
33932 #endif
33933 -
33934 -static __init int vdso_setup(char *s)
33935 -{
33936 - vdso_enabled = simple_strtoul(s, NULL, 0);
33937 - return 0;
33938 -}
33939 -__setup("vdso=", vdso_setup);
33940 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33941 index fa6ade7..73da73a5 100644
33942 --- a/arch/x86/xen/enlighten.c
33943 +++ b/arch/x86/xen/enlighten.c
33944 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33945
33946 struct shared_info xen_dummy_shared_info;
33947
33948 -void *xen_initial_gdt;
33949 -
33950 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33951 __read_mostly int xen_have_vector_callback;
33952 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33953 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33954 {
33955 unsigned long va = dtr->address;
33956 unsigned int size = dtr->size + 1;
33957 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33958 - unsigned long frames[pages];
33959 + unsigned long frames[65536 / PAGE_SIZE];
33960 int f;
33961
33962 /*
33963 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33964 {
33965 unsigned long va = dtr->address;
33966 unsigned int size = dtr->size + 1;
33967 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33968 - unsigned long frames[pages];
33969 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33970 int f;
33971
33972 /*
33973 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33974 * 8-byte entries, or 16 4k pages..
33975 */
33976
33977 - BUG_ON(size > 65536);
33978 + BUG_ON(size > GDT_SIZE);
33979 BUG_ON(va & ~PAGE_MASK);
33980
33981 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33982 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33983 return 0;
33984 }
33985
33986 -static void set_xen_basic_apic_ops(void)
33987 +static void __init set_xen_basic_apic_ops(void)
33988 {
33989 apic->read = xen_apic_read;
33990 apic->write = xen_apic_write;
33991 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33992 #endif
33993 };
33994
33995 -static void xen_reboot(int reason)
33996 +static __noreturn void xen_reboot(int reason)
33997 {
33998 struct sched_shutdown r = { .reason = reason };
33999
34000 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34001 - BUG();
34002 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34003 + BUG();
34004 }
34005
34006 -static void xen_restart(char *msg)
34007 +static __noreturn void xen_restart(char *msg)
34008 {
34009 xen_reboot(SHUTDOWN_reboot);
34010 }
34011
34012 -static void xen_emergency_restart(void)
34013 +static __noreturn void xen_emergency_restart(void)
34014 {
34015 xen_reboot(SHUTDOWN_reboot);
34016 }
34017
34018 -static void xen_machine_halt(void)
34019 +static __noreturn void xen_machine_halt(void)
34020 {
34021 xen_reboot(SHUTDOWN_poweroff);
34022 }
34023
34024 -static void xen_machine_power_off(void)
34025 +static __noreturn void xen_machine_power_off(void)
34026 {
34027 if (pm_power_off)
34028 pm_power_off();
34029 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34030 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34031
34032 /* Work out if we support NX */
34033 - x86_configure_nx();
34034 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34035 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34036 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34037 + unsigned l, h;
34038 +
34039 + __supported_pte_mask |= _PAGE_NX;
34040 + rdmsr(MSR_EFER, l, h);
34041 + l |= EFER_NX;
34042 + wrmsr(MSR_EFER, l, h);
34043 + }
34044 +#endif
34045
34046 xen_setup_features();
34047
34048 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34049
34050 machine_ops = xen_machine_ops;
34051
34052 - /*
34053 - * The only reliable way to retain the initial address of the
34054 - * percpu gdt_page is to remember it here, so we can go and
34055 - * mark it RW later, when the initial percpu area is freed.
34056 - */
34057 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34058 -
34059 xen_smp_init();
34060
34061 #ifdef CONFIG_ACPI_NUMA
34062 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34063 index fdc3ba2..23cae00 100644
34064 --- a/arch/x86/xen/mmu.c
34065 +++ b/arch/x86/xen/mmu.c
34066 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34067 return val;
34068 }
34069
34070 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34071 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34072 {
34073 if (val & _PAGE_PRESENT) {
34074 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34075 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34076 /* L3_k[510] -> level2_kernel_pgt
34077 * L3_i[511] -> level2_fixmap_pgt */
34078 convert_pfn_mfn(level3_kernel_pgt);
34079 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34080 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34081 + convert_pfn_mfn(level3_vmemmap_pgt);
34082
34083 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34084 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34085 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34086 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34088 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34089 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34090 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34091 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34092 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34093 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34094 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34095 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34096 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34097
34098 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34099 pv_mmu_ops.set_pud = xen_set_pud;
34100 #if PAGETABLE_LEVELS == 4
34101 pv_mmu_ops.set_pgd = xen_set_pgd;
34102 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34103 #endif
34104
34105 /* This will work as long as patching hasn't happened yet
34106 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34107 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34108 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34109 .set_pgd = xen_set_pgd_hyper,
34110 + .set_pgd_batched = xen_set_pgd_hyper,
34111
34112 .alloc_pud = xen_alloc_pmd_init,
34113 .release_pud = xen_release_pmd_init,
34114 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34115 index 31d0475..51af671 100644
34116 --- a/arch/x86/xen/smp.c
34117 +++ b/arch/x86/xen/smp.c
34118 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34119 native_smp_prepare_boot_cpu();
34120
34121 if (xen_pv_domain()) {
34122 - /* We've switched to the "real" per-cpu gdt, so make sure the
34123 - old memory can be recycled */
34124 - make_lowmem_page_readwrite(xen_initial_gdt);
34125 -
34126 #ifdef CONFIG_X86_32
34127 /*
34128 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34129 * expects __USER_DS
34130 */
34131 - loadsegment(ds, __USER_DS);
34132 - loadsegment(es, __USER_DS);
34133 + loadsegment(ds, __KERNEL_DS);
34134 + loadsegment(es, __KERNEL_DS);
34135 #endif
34136
34137 xen_filter_cpu_maps();
34138 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34139 ctxt->user_regs.ss = __KERNEL_DS;
34140 #ifdef CONFIG_X86_32
34141 ctxt->user_regs.fs = __KERNEL_PERCPU;
34142 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34143 + savesegment(gs, ctxt->user_regs.gs);
34144 #else
34145 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34146 #endif
34147 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34148
34149 {
34150 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34151 - ctxt->user_regs.ds = __USER_DS;
34152 - ctxt->user_regs.es = __USER_DS;
34153 + ctxt->user_regs.ds = __KERNEL_DS;
34154 + ctxt->user_regs.es = __KERNEL_DS;
34155
34156 xen_copy_trap_info(ctxt->trap_ctxt);
34157
34158 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34159 int rc;
34160
34161 per_cpu(current_task, cpu) = idle;
34162 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34163 #ifdef CONFIG_X86_32
34164 irq_ctx_init(cpu);
34165 #else
34166 clear_tsk_thread_flag(idle, TIF_FORK);
34167 - per_cpu(kernel_stack, cpu) =
34168 - (unsigned long)task_stack_page(idle) -
34169 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34170 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34171 #endif
34172 xen_setup_runstate_info(cpu);
34173 xen_setup_timer(cpu);
34174 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34175
34176 void __init xen_smp_init(void)
34177 {
34178 - smp_ops = xen_smp_ops;
34179 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34180 xen_fill_possible_map();
34181 }
34182
34183 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34184 index 33ca6e4..0ded929 100644
34185 --- a/arch/x86/xen/xen-asm_32.S
34186 +++ b/arch/x86/xen/xen-asm_32.S
34187 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34188 ESP_OFFSET=4 # bytes pushed onto stack
34189
34190 /*
34191 - * Store vcpu_info pointer for easy access. Do it this way to
34192 - * avoid having to reload %fs
34193 + * Store vcpu_info pointer for easy access.
34194 */
34195 #ifdef CONFIG_SMP
34196 - GET_THREAD_INFO(%eax)
34197 - movl %ss:TI_cpu(%eax), %eax
34198 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34199 - mov %ss:xen_vcpu(%eax), %eax
34200 + push %fs
34201 + mov $(__KERNEL_PERCPU), %eax
34202 + mov %eax, %fs
34203 + mov PER_CPU_VAR(xen_vcpu), %eax
34204 + pop %fs
34205 #else
34206 movl %ss:xen_vcpu, %eax
34207 #endif
34208 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34209 index 7faed58..ba4427c 100644
34210 --- a/arch/x86/xen/xen-head.S
34211 +++ b/arch/x86/xen/xen-head.S
34212 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34213 #ifdef CONFIG_X86_32
34214 mov %esi,xen_start_info
34215 mov $init_thread_union+THREAD_SIZE,%esp
34216 +#ifdef CONFIG_SMP
34217 + movl $cpu_gdt_table,%edi
34218 + movl $__per_cpu_load,%eax
34219 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34220 + rorl $16,%eax
34221 + movb %al,__KERNEL_PERCPU + 4(%edi)
34222 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34223 + movl $__per_cpu_end - 1,%eax
34224 + subl $__per_cpu_start,%eax
34225 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34226 +#endif
34227 #else
34228 mov %rsi,xen_start_info
34229 mov $init_thread_union+THREAD_SIZE,%rsp
34230 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34231 index 95f8c61..611d6e8 100644
34232 --- a/arch/x86/xen/xen-ops.h
34233 +++ b/arch/x86/xen/xen-ops.h
34234 @@ -10,8 +10,6 @@
34235 extern const char xen_hypervisor_callback[];
34236 extern const char xen_failsafe_callback[];
34237
34238 -extern void *xen_initial_gdt;
34239 -
34240 struct trap_info;
34241 void xen_copy_trap_info(struct trap_info *traps);
34242
34243 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34244 index 525bd3d..ef888b1 100644
34245 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34246 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34247 @@ -119,9 +119,9 @@
34248 ----------------------------------------------------------------------*/
34249
34250 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34251 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34252 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34253 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34254 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34255
34256 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34257 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34258 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34259 index 2f33760..835e50a 100644
34260 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34261 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34262 @@ -11,6 +11,7 @@
34263 #ifndef _XTENSA_CORE_H
34264 #define _XTENSA_CORE_H
34265
34266 +#include <linux/const.h>
34267
34268 /****************************************************************************
34269 Parameters Useful for Any Code, USER or PRIVILEGED
34270 @@ -112,9 +113,9 @@
34271 ----------------------------------------------------------------------*/
34272
34273 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34274 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34275 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34276 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34277 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34278
34279 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34280 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34281 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34282 index af00795..2bb8105 100644
34283 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34284 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34285 @@ -11,6 +11,7 @@
34286 #ifndef _XTENSA_CORE_CONFIGURATION_H
34287 #define _XTENSA_CORE_CONFIGURATION_H
34288
34289 +#include <linux/const.h>
34290
34291 /****************************************************************************
34292 Parameters Useful for Any Code, USER or PRIVILEGED
34293 @@ -118,9 +119,9 @@
34294 ----------------------------------------------------------------------*/
34295
34296 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34297 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34298 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34299 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34300 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34301
34302 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34303 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34304 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34305 index 4e491d9..c8e18e4 100644
34306 --- a/block/blk-cgroup.c
34307 +++ b/block/blk-cgroup.c
34308 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34309 static struct cgroup_subsys_state *
34310 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34311 {
34312 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34313 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34314 struct blkcg *blkcg;
34315
34316 if (!parent_css) {
34317 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34318
34319 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34320 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34321 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34322 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34323 done:
34324 spin_lock_init(&blkcg->lock);
34325 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34326 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34327 index 4b8d9b54..a7178c0 100644
34328 --- a/block/blk-iopoll.c
34329 +++ b/block/blk-iopoll.c
34330 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34331 }
34332 EXPORT_SYMBOL(blk_iopoll_complete);
34333
34334 -static void blk_iopoll_softirq(struct softirq_action *h)
34335 +static __latent_entropy void blk_iopoll_softirq(void)
34336 {
34337 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34338 int rearm = 0, budget = blk_iopoll_budget;
34339 diff --git a/block/blk-map.c b/block/blk-map.c
34340 index 623e1cd..ca1e109 100644
34341 --- a/block/blk-map.c
34342 +++ b/block/blk-map.c
34343 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34344 if (!len || !kbuf)
34345 return -EINVAL;
34346
34347 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34348 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34349 if (do_copy)
34350 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34351 else
34352 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34353 index ec9e606..3f38839 100644
34354 --- a/block/blk-softirq.c
34355 +++ b/block/blk-softirq.c
34356 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34357 * Softirq action handler - move entries to local list and loop over them
34358 * while passing them to the queue registered handler.
34359 */
34360 -static void blk_done_softirq(struct softirq_action *h)
34361 +static __latent_entropy void blk_done_softirq(void)
34362 {
34363 struct list_head *cpu_list, local_list;
34364
34365 diff --git a/block/bsg.c b/block/bsg.c
34366 index 420a5a9..23834aa 100644
34367 --- a/block/bsg.c
34368 +++ b/block/bsg.c
34369 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34370 struct sg_io_v4 *hdr, struct bsg_device *bd,
34371 fmode_t has_write_perm)
34372 {
34373 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34374 + unsigned char *cmdptr;
34375 +
34376 if (hdr->request_len > BLK_MAX_CDB) {
34377 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34378 if (!rq->cmd)
34379 return -ENOMEM;
34380 - }
34381 + cmdptr = rq->cmd;
34382 + } else
34383 + cmdptr = tmpcmd;
34384
34385 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34386 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34387 hdr->request_len))
34388 return -EFAULT;
34389
34390 + if (cmdptr != rq->cmd)
34391 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34392 +
34393 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34394 if (blk_verify_command(rq->cmd, has_write_perm))
34395 return -EPERM;
34396 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34397 index fbd5a67..5d631b5 100644
34398 --- a/block/compat_ioctl.c
34399 +++ b/block/compat_ioctl.c
34400 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34401 err |= __get_user(f->spec1, &uf->spec1);
34402 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34403 err |= __get_user(name, &uf->name);
34404 - f->name = compat_ptr(name);
34405 + f->name = (void __force_kernel *)compat_ptr(name);
34406 if (err) {
34407 err = -EFAULT;
34408 goto out;
34409 diff --git a/block/genhd.c b/block/genhd.c
34410 index 791f419..89f21c4 100644
34411 --- a/block/genhd.c
34412 +++ b/block/genhd.c
34413 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34414
34415 /*
34416 * Register device numbers dev..(dev+range-1)
34417 - * range must be nonzero
34418 + * Noop if @range is zero.
34419 * The hash chain is sorted on range, so that subranges can override.
34420 */
34421 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34422 struct kobject *(*probe)(dev_t, int *, void *),
34423 int (*lock)(dev_t, void *), void *data)
34424 {
34425 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34426 + if (range)
34427 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34428 }
34429
34430 EXPORT_SYMBOL(blk_register_region);
34431
34432 +/* undo blk_register_region(), noop if @range is zero */
34433 void blk_unregister_region(dev_t devt, unsigned long range)
34434 {
34435 - kobj_unmap(bdev_map, devt, range);
34436 + if (range)
34437 + kobj_unmap(bdev_map, devt, range);
34438 }
34439
34440 EXPORT_SYMBOL(blk_unregister_region);
34441 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34442 index a8287b4..241a48e 100644
34443 --- a/block/partitions/efi.c
34444 +++ b/block/partitions/efi.c
34445 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34446 if (!gpt)
34447 return NULL;
34448
34449 + if (!le32_to_cpu(gpt->num_partition_entries))
34450 + return NULL;
34451 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34452 + if (!pte)
34453 + return NULL;
34454 +
34455 count = le32_to_cpu(gpt->num_partition_entries) *
34456 le32_to_cpu(gpt->sizeof_partition_entry);
34457 - if (!count)
34458 - return NULL;
34459 - pte = kmalloc(count, GFP_KERNEL);
34460 - if (!pte)
34461 - return NULL;
34462 -
34463 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34464 (u8 *) pte, count) < count) {
34465 kfree(pte);
34466 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34467 index a5ffcc9..e057498 100644
34468 --- a/block/scsi_ioctl.c
34469 +++ b/block/scsi_ioctl.c
34470 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
34471 return put_user(0, p);
34472 }
34473
34474 -static int sg_get_timeout(struct request_queue *q)
34475 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
34476 {
34477 return jiffies_to_clock_t(q->sg_timeout);
34478 }
34479 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34480 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34481 struct sg_io_hdr *hdr, fmode_t mode)
34482 {
34483 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34484 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34485 + unsigned char *cmdptr;
34486 +
34487 + if (rq->cmd != rq->__cmd)
34488 + cmdptr = rq->cmd;
34489 + else
34490 + cmdptr = tmpcmd;
34491 +
34492 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34493 return -EFAULT;
34494 +
34495 + if (cmdptr != rq->cmd)
34496 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34497 +
34498 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34499 return -EPERM;
34500
34501 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34502 int err;
34503 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34504 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34505 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34506 + unsigned char *cmdptr;
34507
34508 if (!sic)
34509 return -EINVAL;
34510 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34511 */
34512 err = -EFAULT;
34513 rq->cmd_len = cmdlen;
34514 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34515 +
34516 + if (rq->cmd != rq->__cmd)
34517 + cmdptr = rq->cmd;
34518 + else
34519 + cmdptr = tmpcmd;
34520 +
34521 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34522 goto error;
34523
34524 + if (rq->cmd != cmdptr)
34525 + memcpy(rq->cmd, cmdptr, cmdlen);
34526 +
34527 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34528 goto error;
34529
34530 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34531 index 7bdd61b..afec999 100644
34532 --- a/crypto/cryptd.c
34533 +++ b/crypto/cryptd.c
34534 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34535
34536 struct cryptd_blkcipher_request_ctx {
34537 crypto_completion_t complete;
34538 -};
34539 +} __no_const;
34540
34541 struct cryptd_hash_ctx {
34542 struct crypto_shash *child;
34543 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34544
34545 struct cryptd_aead_request_ctx {
34546 crypto_completion_t complete;
34547 -};
34548 +} __no_const;
34549
34550 static void cryptd_queue_worker(struct work_struct *work);
34551
34552 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34553 index f8c920c..ab2cb5a 100644
34554 --- a/crypto/pcrypt.c
34555 +++ b/crypto/pcrypt.c
34556 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34557 int ret;
34558
34559 pinst->kobj.kset = pcrypt_kset;
34560 - ret = kobject_add(&pinst->kobj, NULL, name);
34561 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34562 if (!ret)
34563 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34564
34565 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34566 index f220d64..d359ad6 100644
34567 --- a/drivers/acpi/apei/apei-internal.h
34568 +++ b/drivers/acpi/apei/apei-internal.h
34569 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34570 struct apei_exec_ins_type {
34571 u32 flags;
34572 apei_exec_ins_func_t run;
34573 -};
34574 +} __do_const;
34575
34576 struct apei_exec_context {
34577 u32 ip;
34578 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34579 index 33dc6a0..4b24b47 100644
34580 --- a/drivers/acpi/apei/cper.c
34581 +++ b/drivers/acpi/apei/cper.c
34582 @@ -39,12 +39,12 @@
34583 */
34584 u64 cper_next_record_id(void)
34585 {
34586 - static atomic64_t seq;
34587 + static atomic64_unchecked_t seq;
34588
34589 - if (!atomic64_read(&seq))
34590 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34591 + if (!atomic64_read_unchecked(&seq))
34592 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34593
34594 - return atomic64_inc_return(&seq);
34595 + return atomic64_inc_return_unchecked(&seq);
34596 }
34597 EXPORT_SYMBOL_GPL(cper_next_record_id);
34598
34599 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34600 index 8ec37bb..b0716e5 100644
34601 --- a/drivers/acpi/apei/ghes.c
34602 +++ b/drivers/acpi/apei/ghes.c
34603 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
34604 const struct acpi_hest_generic *generic,
34605 const struct acpi_hest_generic_status *estatus)
34606 {
34607 - static atomic_t seqno;
34608 + static atomic_unchecked_t seqno;
34609 unsigned int curr_seqno;
34610 char pfx_seq[64];
34611
34612 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
34613 else
34614 pfx = KERN_ERR;
34615 }
34616 - curr_seqno = atomic_inc_return(&seqno);
34617 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34618 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34619 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34620 pfx_seq, generic->header.source_id);
34621 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34622 index a83e3c6..c3d617f 100644
34623 --- a/drivers/acpi/bgrt.c
34624 +++ b/drivers/acpi/bgrt.c
34625 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
34626 if (!bgrt_image)
34627 return -ENODEV;
34628
34629 - bin_attr_image.private = bgrt_image;
34630 - bin_attr_image.size = bgrt_image_size;
34631 + pax_open_kernel();
34632 + *(void **)&bin_attr_image.private = bgrt_image;
34633 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
34634 + pax_close_kernel();
34635
34636 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34637 if (!bgrt_kobj)
34638 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34639 index 9515f18..4b149c9 100644
34640 --- a/drivers/acpi/blacklist.c
34641 +++ b/drivers/acpi/blacklist.c
34642 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34643 u32 is_critical_error;
34644 };
34645
34646 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34647 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34648
34649 /*
34650 * POLICY: If *anything* doesn't work, put it on the blacklist.
34651 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
34652 return 0;
34653 }
34654
34655 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34656 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34657 {
34658 .callback = dmi_disable_osi_vista,
34659 .ident = "Fujitsu Siemens",
34660 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34661 index c7414a5..d5afd71 100644
34662 --- a/drivers/acpi/processor_idle.c
34663 +++ b/drivers/acpi/processor_idle.c
34664 @@ -966,7 +966,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34665 {
34666 int i, count = CPUIDLE_DRIVER_STATE_START;
34667 struct acpi_processor_cx *cx;
34668 - struct cpuidle_state *state;
34669 + cpuidle_state_no_const *state;
34670 struct cpuidle_driver *drv = &acpi_idle_driver;
34671
34672 if (!pr->flags.power_setup_done)
34673 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34674 index 05306a5..733d1f0 100644
34675 --- a/drivers/acpi/sysfs.c
34676 +++ b/drivers/acpi/sysfs.c
34677 @@ -423,11 +423,11 @@ static u32 num_counters;
34678 static struct attribute **all_attrs;
34679 static u32 acpi_gpe_count;
34680
34681 -static struct attribute_group interrupt_stats_attr_group = {
34682 +static attribute_group_no_const interrupt_stats_attr_group = {
34683 .name = "interrupts",
34684 };
34685
34686 -static struct kobj_attribute *counter_attrs;
34687 +static kobj_attribute_no_const *counter_attrs;
34688
34689 static void delete_gpe_attr_array(void)
34690 {
34691 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34692 index aaac4fb..e325c00 100644
34693 --- a/drivers/ata/libahci.c
34694 +++ b/drivers/ata/libahci.c
34695 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
34696 }
34697 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34698
34699 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34700 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34701 struct ata_taskfile *tf, int is_cmd, u16 flags,
34702 unsigned long timeout_msec)
34703 {
34704 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34705 index 83b1a9f..005b1ec 100644
34706 --- a/drivers/ata/libata-core.c
34707 +++ b/drivers/ata/libata-core.c
34708 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34709 static void ata_dev_xfermask(struct ata_device *dev);
34710 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34711
34712 -atomic_t ata_print_id = ATOMIC_INIT(0);
34713 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34714
34715 struct ata_force_param {
34716 const char *name;
34717 @@ -4808,7 +4808,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34718 struct ata_port *ap;
34719 unsigned int tag;
34720
34721 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34722 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34723 ap = qc->ap;
34724
34725 qc->flags = 0;
34726 @@ -4824,7 +4824,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34727 struct ata_port *ap;
34728 struct ata_link *link;
34729
34730 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34731 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34732 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34733 ap = qc->ap;
34734 link = qc->dev->link;
34735 @@ -5943,6 +5943,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34736 return;
34737
34738 spin_lock(&lock);
34739 + pax_open_kernel();
34740
34741 for (cur = ops->inherits; cur; cur = cur->inherits) {
34742 void **inherit = (void **)cur;
34743 @@ -5956,8 +5957,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34744 if (IS_ERR(*pp))
34745 *pp = NULL;
34746
34747 - ops->inherits = NULL;
34748 + *(struct ata_port_operations **)&ops->inherits = NULL;
34749
34750 + pax_close_kernel();
34751 spin_unlock(&lock);
34752 }
34753
34754 @@ -6150,7 +6152,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34755
34756 /* give ports names and add SCSI hosts */
34757 for (i = 0; i < host->n_ports; i++) {
34758 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34759 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34760 host->ports[i]->local_port_no = i + 1;
34761 }
34762
34763 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34764 index db6dfcf..770d1f0 100644
34765 --- a/drivers/ata/libata-scsi.c
34766 +++ b/drivers/ata/libata-scsi.c
34767 @@ -4113,7 +4113,7 @@ int ata_sas_port_init(struct ata_port *ap)
34768
34769 if (rc)
34770 return rc;
34771 - ap->print_id = atomic_inc_return(&ata_print_id);
34772 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34773 return 0;
34774 }
34775 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34776 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34777 index 45b5ab3..98446b8 100644
34778 --- a/drivers/ata/libata.h
34779 +++ b/drivers/ata/libata.h
34780 @@ -53,7 +53,7 @@ enum {
34781 ATA_DNXFER_QUIET = (1 << 31),
34782 };
34783
34784 -extern atomic_t ata_print_id;
34785 +extern atomic_unchecked_t ata_print_id;
34786 extern int atapi_passthru16;
34787 extern int libata_fua;
34788 extern int libata_noacpi;
34789 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34790 index 853f610..97d24da 100644
34791 --- a/drivers/ata/pata_arasan_cf.c
34792 +++ b/drivers/ata/pata_arasan_cf.c
34793 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34794 /* Handle platform specific quirks */
34795 if (quirk) {
34796 if (quirk & CF_BROKEN_PIO) {
34797 - ap->ops->set_piomode = NULL;
34798 + pax_open_kernel();
34799 + *(void **)&ap->ops->set_piomode = NULL;
34800 + pax_close_kernel();
34801 ap->pio_mask = 0;
34802 }
34803 if (quirk & CF_BROKEN_MWDMA)
34804 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34805 index f9b983a..887b9d8 100644
34806 --- a/drivers/atm/adummy.c
34807 +++ b/drivers/atm/adummy.c
34808 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34809 vcc->pop(vcc, skb);
34810 else
34811 dev_kfree_skb_any(skb);
34812 - atomic_inc(&vcc->stats->tx);
34813 + atomic_inc_unchecked(&vcc->stats->tx);
34814
34815 return 0;
34816 }
34817 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34818 index 62a7607..cc4be104 100644
34819 --- a/drivers/atm/ambassador.c
34820 +++ b/drivers/atm/ambassador.c
34821 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34822 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34823
34824 // VC layer stats
34825 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34826 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34827
34828 // free the descriptor
34829 kfree (tx_descr);
34830 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34831 dump_skb ("<<<", vc, skb);
34832
34833 // VC layer stats
34834 - atomic_inc(&atm_vcc->stats->rx);
34835 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34836 __net_timestamp(skb);
34837 // end of our responsibility
34838 atm_vcc->push (atm_vcc, skb);
34839 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34840 } else {
34841 PRINTK (KERN_INFO, "dropped over-size frame");
34842 // should we count this?
34843 - atomic_inc(&atm_vcc->stats->rx_drop);
34844 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34845 }
34846
34847 } else {
34848 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34849 }
34850
34851 if (check_area (skb->data, skb->len)) {
34852 - atomic_inc(&atm_vcc->stats->tx_err);
34853 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34854 return -ENOMEM; // ?
34855 }
34856
34857 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34858 index 0e3f8f9..765a7a5 100644
34859 --- a/drivers/atm/atmtcp.c
34860 +++ b/drivers/atm/atmtcp.c
34861 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34862 if (vcc->pop) vcc->pop(vcc,skb);
34863 else dev_kfree_skb(skb);
34864 if (dev_data) return 0;
34865 - atomic_inc(&vcc->stats->tx_err);
34866 + atomic_inc_unchecked(&vcc->stats->tx_err);
34867 return -ENOLINK;
34868 }
34869 size = skb->len+sizeof(struct atmtcp_hdr);
34870 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34871 if (!new_skb) {
34872 if (vcc->pop) vcc->pop(vcc,skb);
34873 else dev_kfree_skb(skb);
34874 - atomic_inc(&vcc->stats->tx_err);
34875 + atomic_inc_unchecked(&vcc->stats->tx_err);
34876 return -ENOBUFS;
34877 }
34878 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34879 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34880 if (vcc->pop) vcc->pop(vcc,skb);
34881 else dev_kfree_skb(skb);
34882 out_vcc->push(out_vcc,new_skb);
34883 - atomic_inc(&vcc->stats->tx);
34884 - atomic_inc(&out_vcc->stats->rx);
34885 + atomic_inc_unchecked(&vcc->stats->tx);
34886 + atomic_inc_unchecked(&out_vcc->stats->rx);
34887 return 0;
34888 }
34889
34890 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34891 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34892 read_unlock(&vcc_sklist_lock);
34893 if (!out_vcc) {
34894 - atomic_inc(&vcc->stats->tx_err);
34895 + atomic_inc_unchecked(&vcc->stats->tx_err);
34896 goto done;
34897 }
34898 skb_pull(skb,sizeof(struct atmtcp_hdr));
34899 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34900 __net_timestamp(new_skb);
34901 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34902 out_vcc->push(out_vcc,new_skb);
34903 - atomic_inc(&vcc->stats->tx);
34904 - atomic_inc(&out_vcc->stats->rx);
34905 + atomic_inc_unchecked(&vcc->stats->tx);
34906 + atomic_inc_unchecked(&out_vcc->stats->rx);
34907 done:
34908 if (vcc->pop) vcc->pop(vcc,skb);
34909 else dev_kfree_skb(skb);
34910 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34911 index b1955ba..b179940 100644
34912 --- a/drivers/atm/eni.c
34913 +++ b/drivers/atm/eni.c
34914 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34915 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34916 vcc->dev->number);
34917 length = 0;
34918 - atomic_inc(&vcc->stats->rx_err);
34919 + atomic_inc_unchecked(&vcc->stats->rx_err);
34920 }
34921 else {
34922 length = ATM_CELL_SIZE-1; /* no HEC */
34923 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34924 size);
34925 }
34926 eff = length = 0;
34927 - atomic_inc(&vcc->stats->rx_err);
34928 + atomic_inc_unchecked(&vcc->stats->rx_err);
34929 }
34930 else {
34931 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34932 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34933 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34934 vcc->dev->number,vcc->vci,length,size << 2,descr);
34935 length = eff = 0;
34936 - atomic_inc(&vcc->stats->rx_err);
34937 + atomic_inc_unchecked(&vcc->stats->rx_err);
34938 }
34939 }
34940 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34941 @@ -767,7 +767,7 @@ rx_dequeued++;
34942 vcc->push(vcc,skb);
34943 pushed++;
34944 }
34945 - atomic_inc(&vcc->stats->rx);
34946 + atomic_inc_unchecked(&vcc->stats->rx);
34947 }
34948 wake_up(&eni_dev->rx_wait);
34949 }
34950 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34951 PCI_DMA_TODEVICE);
34952 if (vcc->pop) vcc->pop(vcc,skb);
34953 else dev_kfree_skb_irq(skb);
34954 - atomic_inc(&vcc->stats->tx);
34955 + atomic_inc_unchecked(&vcc->stats->tx);
34956 wake_up(&eni_dev->tx_wait);
34957 dma_complete++;
34958 }
34959 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34960 index b41c948..a002b17 100644
34961 --- a/drivers/atm/firestream.c
34962 +++ b/drivers/atm/firestream.c
34963 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34964 }
34965 }
34966
34967 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34968 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34969
34970 fs_dprintk (FS_DEBUG_TXMEM, "i");
34971 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34972 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34973 #endif
34974 skb_put (skb, qe->p1 & 0xffff);
34975 ATM_SKB(skb)->vcc = atm_vcc;
34976 - atomic_inc(&atm_vcc->stats->rx);
34977 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34978 __net_timestamp(skb);
34979 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34980 atm_vcc->push (atm_vcc, skb);
34981 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34982 kfree (pe);
34983 }
34984 if (atm_vcc)
34985 - atomic_inc(&atm_vcc->stats->rx_drop);
34986 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34987 break;
34988 case 0x1f: /* Reassembly abort: no buffers. */
34989 /* Silently increment error counter. */
34990 if (atm_vcc)
34991 - atomic_inc(&atm_vcc->stats->rx_drop);
34992 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34993 break;
34994 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34995 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34996 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34997 index 204814e..cede831 100644
34998 --- a/drivers/atm/fore200e.c
34999 +++ b/drivers/atm/fore200e.c
35000 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35001 #endif
35002 /* check error condition */
35003 if (*entry->status & STATUS_ERROR)
35004 - atomic_inc(&vcc->stats->tx_err);
35005 + atomic_inc_unchecked(&vcc->stats->tx_err);
35006 else
35007 - atomic_inc(&vcc->stats->tx);
35008 + atomic_inc_unchecked(&vcc->stats->tx);
35009 }
35010 }
35011
35012 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35013 if (skb == NULL) {
35014 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35015
35016 - atomic_inc(&vcc->stats->rx_drop);
35017 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35018 return -ENOMEM;
35019 }
35020
35021 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35022
35023 dev_kfree_skb_any(skb);
35024
35025 - atomic_inc(&vcc->stats->rx_drop);
35026 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35027 return -ENOMEM;
35028 }
35029
35030 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35031
35032 vcc->push(vcc, skb);
35033 - atomic_inc(&vcc->stats->rx);
35034 + atomic_inc_unchecked(&vcc->stats->rx);
35035
35036 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35037
35038 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35039 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35040 fore200e->atm_dev->number,
35041 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35042 - atomic_inc(&vcc->stats->rx_err);
35043 + atomic_inc_unchecked(&vcc->stats->rx_err);
35044 }
35045 }
35046
35047 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35048 goto retry_here;
35049 }
35050
35051 - atomic_inc(&vcc->stats->tx_err);
35052 + atomic_inc_unchecked(&vcc->stats->tx_err);
35053
35054 fore200e->tx_sat++;
35055 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35056 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35057 index 8557adc..3fb5d55 100644
35058 --- a/drivers/atm/he.c
35059 +++ b/drivers/atm/he.c
35060 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35061
35062 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35063 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35064 - atomic_inc(&vcc->stats->rx_drop);
35065 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35066 goto return_host_buffers;
35067 }
35068
35069 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35070 RBRQ_LEN_ERR(he_dev->rbrq_head)
35071 ? "LEN_ERR" : "",
35072 vcc->vpi, vcc->vci);
35073 - atomic_inc(&vcc->stats->rx_err);
35074 + atomic_inc_unchecked(&vcc->stats->rx_err);
35075 goto return_host_buffers;
35076 }
35077
35078 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35079 vcc->push(vcc, skb);
35080 spin_lock(&he_dev->global_lock);
35081
35082 - atomic_inc(&vcc->stats->rx);
35083 + atomic_inc_unchecked(&vcc->stats->rx);
35084
35085 return_host_buffers:
35086 ++pdus_assembled;
35087 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35088 tpd->vcc->pop(tpd->vcc, tpd->skb);
35089 else
35090 dev_kfree_skb_any(tpd->skb);
35091 - atomic_inc(&tpd->vcc->stats->tx_err);
35092 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35093 }
35094 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35095 return;
35096 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35097 vcc->pop(vcc, skb);
35098 else
35099 dev_kfree_skb_any(skb);
35100 - atomic_inc(&vcc->stats->tx_err);
35101 + atomic_inc_unchecked(&vcc->stats->tx_err);
35102 return -EINVAL;
35103 }
35104
35105 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35106 vcc->pop(vcc, skb);
35107 else
35108 dev_kfree_skb_any(skb);
35109 - atomic_inc(&vcc->stats->tx_err);
35110 + atomic_inc_unchecked(&vcc->stats->tx_err);
35111 return -EINVAL;
35112 }
35113 #endif
35114 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35115 vcc->pop(vcc, skb);
35116 else
35117 dev_kfree_skb_any(skb);
35118 - atomic_inc(&vcc->stats->tx_err);
35119 + atomic_inc_unchecked(&vcc->stats->tx_err);
35120 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35121 return -ENOMEM;
35122 }
35123 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35124 vcc->pop(vcc, skb);
35125 else
35126 dev_kfree_skb_any(skb);
35127 - atomic_inc(&vcc->stats->tx_err);
35128 + atomic_inc_unchecked(&vcc->stats->tx_err);
35129 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35130 return -ENOMEM;
35131 }
35132 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35133 __enqueue_tpd(he_dev, tpd, cid);
35134 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35135
35136 - atomic_inc(&vcc->stats->tx);
35137 + atomic_inc_unchecked(&vcc->stats->tx);
35138
35139 return 0;
35140 }
35141 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35142 index 1dc0519..1aadaf7 100644
35143 --- a/drivers/atm/horizon.c
35144 +++ b/drivers/atm/horizon.c
35145 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35146 {
35147 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35148 // VC layer stats
35149 - atomic_inc(&vcc->stats->rx);
35150 + atomic_inc_unchecked(&vcc->stats->rx);
35151 __net_timestamp(skb);
35152 // end of our responsibility
35153 vcc->push (vcc, skb);
35154 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35155 dev->tx_iovec = NULL;
35156
35157 // VC layer stats
35158 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35159 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35160
35161 // free the skb
35162 hrz_kfree_skb (skb);
35163 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35164 index 272f009..a18ba55 100644
35165 --- a/drivers/atm/idt77252.c
35166 +++ b/drivers/atm/idt77252.c
35167 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35168 else
35169 dev_kfree_skb(skb);
35170
35171 - atomic_inc(&vcc->stats->tx);
35172 + atomic_inc_unchecked(&vcc->stats->tx);
35173 }
35174
35175 atomic_dec(&scq->used);
35176 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35177 if ((sb = dev_alloc_skb(64)) == NULL) {
35178 printk("%s: Can't allocate buffers for aal0.\n",
35179 card->name);
35180 - atomic_add(i, &vcc->stats->rx_drop);
35181 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35182 break;
35183 }
35184 if (!atm_charge(vcc, sb->truesize)) {
35185 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35186 card->name);
35187 - atomic_add(i - 1, &vcc->stats->rx_drop);
35188 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35189 dev_kfree_skb(sb);
35190 break;
35191 }
35192 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35193 ATM_SKB(sb)->vcc = vcc;
35194 __net_timestamp(sb);
35195 vcc->push(vcc, sb);
35196 - atomic_inc(&vcc->stats->rx);
35197 + atomic_inc_unchecked(&vcc->stats->rx);
35198
35199 cell += ATM_CELL_PAYLOAD;
35200 }
35201 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35202 "(CDC: %08x)\n",
35203 card->name, len, rpp->len, readl(SAR_REG_CDC));
35204 recycle_rx_pool_skb(card, rpp);
35205 - atomic_inc(&vcc->stats->rx_err);
35206 + atomic_inc_unchecked(&vcc->stats->rx_err);
35207 return;
35208 }
35209 if (stat & SAR_RSQE_CRC) {
35210 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35211 recycle_rx_pool_skb(card, rpp);
35212 - atomic_inc(&vcc->stats->rx_err);
35213 + atomic_inc_unchecked(&vcc->stats->rx_err);
35214 return;
35215 }
35216 if (skb_queue_len(&rpp->queue) > 1) {
35217 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35218 RXPRINTK("%s: Can't alloc RX skb.\n",
35219 card->name);
35220 recycle_rx_pool_skb(card, rpp);
35221 - atomic_inc(&vcc->stats->rx_err);
35222 + atomic_inc_unchecked(&vcc->stats->rx_err);
35223 return;
35224 }
35225 if (!atm_charge(vcc, skb->truesize)) {
35226 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35227 __net_timestamp(skb);
35228
35229 vcc->push(vcc, skb);
35230 - atomic_inc(&vcc->stats->rx);
35231 + atomic_inc_unchecked(&vcc->stats->rx);
35232
35233 return;
35234 }
35235 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35236 __net_timestamp(skb);
35237
35238 vcc->push(vcc, skb);
35239 - atomic_inc(&vcc->stats->rx);
35240 + atomic_inc_unchecked(&vcc->stats->rx);
35241
35242 if (skb->truesize > SAR_FB_SIZE_3)
35243 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35244 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35245 if (vcc->qos.aal != ATM_AAL0) {
35246 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35247 card->name, vpi, vci);
35248 - atomic_inc(&vcc->stats->rx_drop);
35249 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35250 goto drop;
35251 }
35252
35253 if ((sb = dev_alloc_skb(64)) == NULL) {
35254 printk("%s: Can't allocate buffers for AAL0.\n",
35255 card->name);
35256 - atomic_inc(&vcc->stats->rx_err);
35257 + atomic_inc_unchecked(&vcc->stats->rx_err);
35258 goto drop;
35259 }
35260
35261 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35262 ATM_SKB(sb)->vcc = vcc;
35263 __net_timestamp(sb);
35264 vcc->push(vcc, sb);
35265 - atomic_inc(&vcc->stats->rx);
35266 + atomic_inc_unchecked(&vcc->stats->rx);
35267
35268 drop:
35269 skb_pull(queue, 64);
35270 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35271
35272 if (vc == NULL) {
35273 printk("%s: NULL connection in send().\n", card->name);
35274 - atomic_inc(&vcc->stats->tx_err);
35275 + atomic_inc_unchecked(&vcc->stats->tx_err);
35276 dev_kfree_skb(skb);
35277 return -EINVAL;
35278 }
35279 if (!test_bit(VCF_TX, &vc->flags)) {
35280 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return -EINVAL;
35285 }
35286 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35287 break;
35288 default:
35289 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35290 - atomic_inc(&vcc->stats->tx_err);
35291 + atomic_inc_unchecked(&vcc->stats->tx_err);
35292 dev_kfree_skb(skb);
35293 return -EINVAL;
35294 }
35295
35296 if (skb_shinfo(skb)->nr_frags != 0) {
35297 printk("%s: No scatter-gather yet.\n", card->name);
35298 - atomic_inc(&vcc->stats->tx_err);
35299 + atomic_inc_unchecked(&vcc->stats->tx_err);
35300 dev_kfree_skb(skb);
35301 return -EINVAL;
35302 }
35303 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35304
35305 err = queue_skb(card, vc, skb, oam);
35306 if (err) {
35307 - atomic_inc(&vcc->stats->tx_err);
35308 + atomic_inc_unchecked(&vcc->stats->tx_err);
35309 dev_kfree_skb(skb);
35310 return err;
35311 }
35312 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35313 skb = dev_alloc_skb(64);
35314 if (!skb) {
35315 printk("%s: Out of memory in send_oam().\n", card->name);
35316 - atomic_inc(&vcc->stats->tx_err);
35317 + atomic_inc_unchecked(&vcc->stats->tx_err);
35318 return -ENOMEM;
35319 }
35320 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35321 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35322 index 4217f29..88f547a 100644
35323 --- a/drivers/atm/iphase.c
35324 +++ b/drivers/atm/iphase.c
35325 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35326 status = (u_short) (buf_desc_ptr->desc_mode);
35327 if (status & (RX_CER | RX_PTE | RX_OFL))
35328 {
35329 - atomic_inc(&vcc->stats->rx_err);
35330 + atomic_inc_unchecked(&vcc->stats->rx_err);
35331 IF_ERR(printk("IA: bad packet, dropping it");)
35332 if (status & RX_CER) {
35333 IF_ERR(printk(" cause: packet CRC error\n");)
35334 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35335 len = dma_addr - buf_addr;
35336 if (len > iadev->rx_buf_sz) {
35337 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35338 - atomic_inc(&vcc->stats->rx_err);
35339 + atomic_inc_unchecked(&vcc->stats->rx_err);
35340 goto out_free_desc;
35341 }
35342
35343 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35344 ia_vcc = INPH_IA_VCC(vcc);
35345 if (ia_vcc == NULL)
35346 {
35347 - atomic_inc(&vcc->stats->rx_err);
35348 + atomic_inc_unchecked(&vcc->stats->rx_err);
35349 atm_return(vcc, skb->truesize);
35350 dev_kfree_skb_any(skb);
35351 goto INCR_DLE;
35352 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35353 if ((length > iadev->rx_buf_sz) || (length >
35354 (skb->len - sizeof(struct cpcs_trailer))))
35355 {
35356 - atomic_inc(&vcc->stats->rx_err);
35357 + atomic_inc_unchecked(&vcc->stats->rx_err);
35358 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35359 length, skb->len);)
35360 atm_return(vcc, skb->truesize);
35361 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35362
35363 IF_RX(printk("rx_dle_intr: skb push");)
35364 vcc->push(vcc,skb);
35365 - atomic_inc(&vcc->stats->rx);
35366 + atomic_inc_unchecked(&vcc->stats->rx);
35367 iadev->rx_pkt_cnt++;
35368 }
35369 INCR_DLE:
35370 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35371 {
35372 struct k_sonet_stats *stats;
35373 stats = &PRIV(_ia_dev[board])->sonet_stats;
35374 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35375 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35376 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35377 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35378 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35379 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35380 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35381 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35382 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35383 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35384 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35385 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35386 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35387 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35388 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35389 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35390 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35391 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35392 }
35393 ia_cmds.status = 0;
35394 break;
35395 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35396 if ((desc == 0) || (desc > iadev->num_tx_desc))
35397 {
35398 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35399 - atomic_inc(&vcc->stats->tx);
35400 + atomic_inc_unchecked(&vcc->stats->tx);
35401 if (vcc->pop)
35402 vcc->pop(vcc, skb);
35403 else
35404 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35405 ATM_DESC(skb) = vcc->vci;
35406 skb_queue_tail(&iadev->tx_dma_q, skb);
35407
35408 - atomic_inc(&vcc->stats->tx);
35409 + atomic_inc_unchecked(&vcc->stats->tx);
35410 iadev->tx_pkt_cnt++;
35411 /* Increment transaction counter */
35412 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35413
35414 #if 0
35415 /* add flow control logic */
35416 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35417 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35418 if (iavcc->vc_desc_cnt > 10) {
35419 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35420 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35421 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35422 index fa7d701..1e404c7 100644
35423 --- a/drivers/atm/lanai.c
35424 +++ b/drivers/atm/lanai.c
35425 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35426 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35427 lanai_endtx(lanai, lvcc);
35428 lanai_free_skb(lvcc->tx.atmvcc, skb);
35429 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35430 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35431 }
35432
35433 /* Try to fill the buffer - don't call unless there is backlog */
35434 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35435 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35436 __net_timestamp(skb);
35437 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35438 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35439 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35440 out:
35441 lvcc->rx.buf.ptr = end;
35442 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35443 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35444 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35445 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35446 lanai->stats.service_rxnotaal5++;
35447 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35448 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35449 return 0;
35450 }
35451 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35452 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35453 int bytes;
35454 read_unlock(&vcc_sklist_lock);
35455 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35456 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35457 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35458 lvcc->stats.x.aal5.service_trash++;
35459 bytes = (SERVICE_GET_END(s) * 16) -
35460 (((unsigned long) lvcc->rx.buf.ptr) -
35461 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35462 }
35463 if (s & SERVICE_STREAM) {
35464 read_unlock(&vcc_sklist_lock);
35465 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35466 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35467 lvcc->stats.x.aal5.service_stream++;
35468 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35469 "PDU on VCI %d!\n", lanai->number, vci);
35470 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35471 return 0;
35472 }
35473 DPRINTK("got rx crc error on vci %d\n", vci);
35474 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35475 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35476 lvcc->stats.x.aal5.service_rxcrc++;
35477 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35478 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35479 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35480 index 5aca5f4..ce3a6b0 100644
35481 --- a/drivers/atm/nicstar.c
35482 +++ b/drivers/atm/nicstar.c
35483 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35484 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35485 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35486 card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 if (!vc->tx) {
35494 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35495 card->index);
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EINVAL;
35500 }
35501 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35502 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35503 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35504 card->index);
35505 - atomic_inc(&vcc->stats->tx_err);
35506 + atomic_inc_unchecked(&vcc->stats->tx_err);
35507 dev_kfree_skb_any(skb);
35508 return -EINVAL;
35509 }
35510
35511 if (skb_shinfo(skb)->nr_frags != 0) {
35512 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35513 - atomic_inc(&vcc->stats->tx_err);
35514 + atomic_inc_unchecked(&vcc->stats->tx_err);
35515 dev_kfree_skb_any(skb);
35516 return -EINVAL;
35517 }
35518 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35519 }
35520
35521 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35522 - atomic_inc(&vcc->stats->tx_err);
35523 + atomic_inc_unchecked(&vcc->stats->tx_err);
35524 dev_kfree_skb_any(skb);
35525 return -EIO;
35526 }
35527 - atomic_inc(&vcc->stats->tx);
35528 + atomic_inc_unchecked(&vcc->stats->tx);
35529
35530 return 0;
35531 }
35532 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35533 printk
35534 ("nicstar%d: Can't allocate buffers for aal0.\n",
35535 card->index);
35536 - atomic_add(i, &vcc->stats->rx_drop);
35537 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35538 break;
35539 }
35540 if (!atm_charge(vcc, sb->truesize)) {
35541 RXPRINTK
35542 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35543 card->index);
35544 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35545 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35546 dev_kfree_skb_any(sb);
35547 break;
35548 }
35549 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35550 ATM_SKB(sb)->vcc = vcc;
35551 __net_timestamp(sb);
35552 vcc->push(vcc, sb);
35553 - atomic_inc(&vcc->stats->rx);
35554 + atomic_inc_unchecked(&vcc->stats->rx);
35555 cell += ATM_CELL_PAYLOAD;
35556 }
35557
35558 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35559 if (iovb == NULL) {
35560 printk("nicstar%d: Out of iovec buffers.\n",
35561 card->index);
35562 - atomic_inc(&vcc->stats->rx_drop);
35563 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35564 recycle_rx_buf(card, skb);
35565 return;
35566 }
35567 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35568 small or large buffer itself. */
35569 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35570 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35571 - atomic_inc(&vcc->stats->rx_err);
35572 + atomic_inc_unchecked(&vcc->stats->rx_err);
35573 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35574 NS_MAX_IOVECS);
35575 NS_PRV_IOVCNT(iovb) = 0;
35576 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35577 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35578 card->index);
35579 which_list(card, skb);
35580 - atomic_inc(&vcc->stats->rx_err);
35581 + atomic_inc_unchecked(&vcc->stats->rx_err);
35582 recycle_rx_buf(card, skb);
35583 vc->rx_iov = NULL;
35584 recycle_iov_buf(card, iovb);
35585 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35586 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35587 card->index);
35588 which_list(card, skb);
35589 - atomic_inc(&vcc->stats->rx_err);
35590 + atomic_inc_unchecked(&vcc->stats->rx_err);
35591 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35592 NS_PRV_IOVCNT(iovb));
35593 vc->rx_iov = NULL;
35594 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35595 printk(" - PDU size mismatch.\n");
35596 else
35597 printk(".\n");
35598 - atomic_inc(&vcc->stats->rx_err);
35599 + atomic_inc_unchecked(&vcc->stats->rx_err);
35600 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35601 NS_PRV_IOVCNT(iovb));
35602 vc->rx_iov = NULL;
35603 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35604 /* skb points to a small buffer */
35605 if (!atm_charge(vcc, skb->truesize)) {
35606 push_rxbufs(card, skb);
35607 - atomic_inc(&vcc->stats->rx_drop);
35608 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35609 } else {
35610 skb_put(skb, len);
35611 dequeue_sm_buf(card, skb);
35612 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35613 ATM_SKB(skb)->vcc = vcc;
35614 __net_timestamp(skb);
35615 vcc->push(vcc, skb);
35616 - atomic_inc(&vcc->stats->rx);
35617 + atomic_inc_unchecked(&vcc->stats->rx);
35618 }
35619 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35620 struct sk_buff *sb;
35621 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35622 if (len <= NS_SMBUFSIZE) {
35623 if (!atm_charge(vcc, sb->truesize)) {
35624 push_rxbufs(card, sb);
35625 - atomic_inc(&vcc->stats->rx_drop);
35626 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35627 } else {
35628 skb_put(sb, len);
35629 dequeue_sm_buf(card, sb);
35630 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35631 ATM_SKB(sb)->vcc = vcc;
35632 __net_timestamp(sb);
35633 vcc->push(vcc, sb);
35634 - atomic_inc(&vcc->stats->rx);
35635 + atomic_inc_unchecked(&vcc->stats->rx);
35636 }
35637
35638 push_rxbufs(card, skb);
35639 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35640
35641 if (!atm_charge(vcc, skb->truesize)) {
35642 push_rxbufs(card, skb);
35643 - atomic_inc(&vcc->stats->rx_drop);
35644 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35645 } else {
35646 dequeue_lg_buf(card, skb);
35647 #ifdef NS_USE_DESTRUCTORS
35648 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35649 ATM_SKB(skb)->vcc = vcc;
35650 __net_timestamp(skb);
35651 vcc->push(vcc, skb);
35652 - atomic_inc(&vcc->stats->rx);
35653 + atomic_inc_unchecked(&vcc->stats->rx);
35654 }
35655
35656 push_rxbufs(card, sb);
35657 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35658 printk
35659 ("nicstar%d: Out of huge buffers.\n",
35660 card->index);
35661 - atomic_inc(&vcc->stats->rx_drop);
35662 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35663 recycle_iovec_rx_bufs(card,
35664 (struct iovec *)
35665 iovb->data,
35666 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35667 card->hbpool.count++;
35668 } else
35669 dev_kfree_skb_any(hb);
35670 - atomic_inc(&vcc->stats->rx_drop);
35671 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35672 } else {
35673 /* Copy the small buffer to the huge buffer */
35674 sb = (struct sk_buff *)iov->iov_base;
35675 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35676 #endif /* NS_USE_DESTRUCTORS */
35677 __net_timestamp(hb);
35678 vcc->push(vcc, hb);
35679 - atomic_inc(&vcc->stats->rx);
35680 + atomic_inc_unchecked(&vcc->stats->rx);
35681 }
35682 }
35683
35684 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35685 index 32784d1..4a8434a 100644
35686 --- a/drivers/atm/solos-pci.c
35687 +++ b/drivers/atm/solos-pci.c
35688 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35689 }
35690 atm_charge(vcc, skb->truesize);
35691 vcc->push(vcc, skb);
35692 - atomic_inc(&vcc->stats->rx);
35693 + atomic_inc_unchecked(&vcc->stats->rx);
35694 break;
35695
35696 case PKT_STATUS:
35697 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35698 vcc = SKB_CB(oldskb)->vcc;
35699
35700 if (vcc) {
35701 - atomic_inc(&vcc->stats->tx);
35702 + atomic_inc_unchecked(&vcc->stats->tx);
35703 solos_pop(vcc, oldskb);
35704 } else {
35705 dev_kfree_skb_irq(oldskb);
35706 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35707 index 0215934..ce9f5b1 100644
35708 --- a/drivers/atm/suni.c
35709 +++ b/drivers/atm/suni.c
35710 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35711
35712
35713 #define ADD_LIMITED(s,v) \
35714 - atomic_add((v),&stats->s); \
35715 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35716 + atomic_add_unchecked((v),&stats->s); \
35717 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35718
35719
35720 static void suni_hz(unsigned long from_timer)
35721 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35722 index 5120a96..e2572bd 100644
35723 --- a/drivers/atm/uPD98402.c
35724 +++ b/drivers/atm/uPD98402.c
35725 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35726 struct sonet_stats tmp;
35727 int error = 0;
35728
35729 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35730 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35731 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35732 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35733 if (zero && !error) {
35734 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35735
35736
35737 #define ADD_LIMITED(s,v) \
35738 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35739 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35740 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35741 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35742 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35743 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35744
35745
35746 static void stat_event(struct atm_dev *dev)
35747 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35748 if (reason & uPD98402_INT_PFM) stat_event(dev);
35749 if (reason & uPD98402_INT_PCO) {
35750 (void) GET(PCOCR); /* clear interrupt cause */
35751 - atomic_add(GET(HECCT),
35752 + atomic_add_unchecked(GET(HECCT),
35753 &PRIV(dev)->sonet_stats.uncorr_hcs);
35754 }
35755 if ((reason & uPD98402_INT_RFO) &&
35756 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35757 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35758 uPD98402_INT_LOS),PIMR); /* enable them */
35759 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35760 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35761 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35762 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35763 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35764 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35765 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35766 return 0;
35767 }
35768
35769 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35770 index 969c3c2..9b72956 100644
35771 --- a/drivers/atm/zatm.c
35772 +++ b/drivers/atm/zatm.c
35773 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35774 }
35775 if (!size) {
35776 dev_kfree_skb_irq(skb);
35777 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35778 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35779 continue;
35780 }
35781 if (!atm_charge(vcc,skb->truesize)) {
35782 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35783 skb->len = size;
35784 ATM_SKB(skb)->vcc = vcc;
35785 vcc->push(vcc,skb);
35786 - atomic_inc(&vcc->stats->rx);
35787 + atomic_inc_unchecked(&vcc->stats->rx);
35788 }
35789 zout(pos & 0xffff,MTA(mbx));
35790 #if 0 /* probably a stupid idea */
35791 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35792 skb_queue_head(&zatm_vcc->backlog,skb);
35793 break;
35794 }
35795 - atomic_inc(&vcc->stats->tx);
35796 + atomic_inc_unchecked(&vcc->stats->tx);
35797 wake_up(&zatm_vcc->tx_wait);
35798 }
35799
35800 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35801 index 4c289ab..de1c333 100644
35802 --- a/drivers/base/bus.c
35803 +++ b/drivers/base/bus.c
35804 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35805 return -EINVAL;
35806
35807 mutex_lock(&subsys->p->mutex);
35808 - list_add_tail(&sif->node, &subsys->p->interfaces);
35809 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35810 if (sif->add_dev) {
35811 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35812 while ((dev = subsys_dev_iter_next(&iter)))
35813 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35814 subsys = sif->subsys;
35815
35816 mutex_lock(&subsys->p->mutex);
35817 - list_del_init(&sif->node);
35818 + pax_list_del_init((struct list_head *)&sif->node);
35819 if (sif->remove_dev) {
35820 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35821 while ((dev = subsys_dev_iter_next(&iter)))
35822 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35823 index 7413d06..79155fa 100644
35824 --- a/drivers/base/devtmpfs.c
35825 +++ b/drivers/base/devtmpfs.c
35826 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35827 if (!thread)
35828 return 0;
35829
35830 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35831 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35832 if (err)
35833 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35834 else
35835 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35836 *err = sys_unshare(CLONE_NEWNS);
35837 if (*err)
35838 goto out;
35839 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35840 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35841 if (*err)
35842 goto out;
35843 - sys_chdir("/.."); /* will traverse into overmounted root */
35844 - sys_chroot(".");
35845 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35846 + sys_chroot((char __force_user *)".");
35847 complete(&setup_done);
35848 while (1) {
35849 spin_lock(&req_lock);
35850 diff --git a/drivers/base/node.c b/drivers/base/node.c
35851 index bc9f43b..29703b8 100644
35852 --- a/drivers/base/node.c
35853 +++ b/drivers/base/node.c
35854 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35855 struct node_attr {
35856 struct device_attribute attr;
35857 enum node_states state;
35858 -};
35859 +} __do_const;
35860
35861 static ssize_t show_node_state(struct device *dev,
35862 struct device_attribute *attr, char *buf)
35863 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35864 index bfb8955..42c9b9a 100644
35865 --- a/drivers/base/power/domain.c
35866 +++ b/drivers/base/power/domain.c
35867 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35868 {
35869 struct cpuidle_driver *cpuidle_drv;
35870 struct gpd_cpu_data *cpu_data;
35871 - struct cpuidle_state *idle_state;
35872 + cpuidle_state_no_const *idle_state;
35873 int ret = 0;
35874
35875 if (IS_ERR_OR_NULL(genpd) || state < 0)
35876 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35877 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35878 {
35879 struct gpd_cpu_data *cpu_data;
35880 - struct cpuidle_state *idle_state;
35881 + cpuidle_state_no_const *idle_state;
35882 int ret = 0;
35883
35884 if (IS_ERR_OR_NULL(genpd))
35885 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35886 index 03e089a..0e9560c 100644
35887 --- a/drivers/base/power/sysfs.c
35888 +++ b/drivers/base/power/sysfs.c
35889 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35890 return -EIO;
35891 }
35892 }
35893 - return sprintf(buf, p);
35894 + return sprintf(buf, "%s", p);
35895 }
35896
35897 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35898 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35899 index 2d56f41..8830f19 100644
35900 --- a/drivers/base/power/wakeup.c
35901 +++ b/drivers/base/power/wakeup.c
35902 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35903 * They need to be modified together atomically, so it's better to use one
35904 * atomic variable to hold them both.
35905 */
35906 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35907 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35908
35909 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35910 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35911
35912 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35913 {
35914 - unsigned int comb = atomic_read(&combined_event_count);
35915 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35916
35917 *cnt = (comb >> IN_PROGRESS_BITS);
35918 *inpr = comb & MAX_IN_PROGRESS;
35919 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35920 ws->start_prevent_time = ws->last_time;
35921
35922 /* Increment the counter of events in progress. */
35923 - cec = atomic_inc_return(&combined_event_count);
35924 + cec = atomic_inc_return_unchecked(&combined_event_count);
35925
35926 trace_wakeup_source_activate(ws->name, cec);
35927 }
35928 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35929 * Increment the counter of registered wakeup events and decrement the
35930 * couter of wakeup events in progress simultaneously.
35931 */
35932 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35933 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35934 trace_wakeup_source_deactivate(ws->name, cec);
35935
35936 split_counters(&cnt, &inpr);
35937 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35938 index e8d11b6..7b1b36f 100644
35939 --- a/drivers/base/syscore.c
35940 +++ b/drivers/base/syscore.c
35941 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35942 void register_syscore_ops(struct syscore_ops *ops)
35943 {
35944 mutex_lock(&syscore_ops_lock);
35945 - list_add_tail(&ops->node, &syscore_ops_list);
35946 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35947 mutex_unlock(&syscore_ops_lock);
35948 }
35949 EXPORT_SYMBOL_GPL(register_syscore_ops);
35950 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35951 void unregister_syscore_ops(struct syscore_ops *ops)
35952 {
35953 mutex_lock(&syscore_ops_lock);
35954 - list_del(&ops->node);
35955 + pax_list_del((struct list_head *)&ops->node);
35956 mutex_unlock(&syscore_ops_lock);
35957 }
35958 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35959 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35960 index edfa251..1734d4d 100644
35961 --- a/drivers/block/cciss.c
35962 +++ b/drivers/block/cciss.c
35963 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35964 while (!list_empty(&h->reqQ)) {
35965 c = list_entry(h->reqQ.next, CommandList_struct, list);
35966 /* can't do anything if fifo is full */
35967 - if ((h->access.fifo_full(h))) {
35968 + if ((h->access->fifo_full(h))) {
35969 dev_warn(&h->pdev->dev, "fifo full\n");
35970 break;
35971 }
35972 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35973 h->Qdepth--;
35974
35975 /* Tell the controller execute command */
35976 - h->access.submit_command(h, c);
35977 + h->access->submit_command(h, c);
35978
35979 /* Put job onto the completed Q */
35980 addQ(&h->cmpQ, c);
35981 @@ -3447,17 +3447,17 @@ startio:
35982
35983 static inline unsigned long get_next_completion(ctlr_info_t *h)
35984 {
35985 - return h->access.command_completed(h);
35986 + return h->access->command_completed(h);
35987 }
35988
35989 static inline int interrupt_pending(ctlr_info_t *h)
35990 {
35991 - return h->access.intr_pending(h);
35992 + return h->access->intr_pending(h);
35993 }
35994
35995 static inline long interrupt_not_for_us(ctlr_info_t *h)
35996 {
35997 - return ((h->access.intr_pending(h) == 0) ||
35998 + return ((h->access->intr_pending(h) == 0) ||
35999 (h->interrupts_enabled == 0));
36000 }
36001
36002 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36003 u32 a;
36004
36005 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36006 - return h->access.command_completed(h);
36007 + return h->access->command_completed(h);
36008
36009 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36010 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36011 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36012 trans_support & CFGTBL_Trans_use_short_tags);
36013
36014 /* Change the access methods to the performant access methods */
36015 - h->access = SA5_performant_access;
36016 + h->access = &SA5_performant_access;
36017 h->transMethod = CFGTBL_Trans_Performant;
36018
36019 return;
36020 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36021 if (prod_index < 0)
36022 return -ENODEV;
36023 h->product_name = products[prod_index].product_name;
36024 - h->access = *(products[prod_index].access);
36025 + h->access = products[prod_index].access;
36026
36027 if (cciss_board_disabled(h)) {
36028 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36029 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36030 }
36031
36032 /* make sure the board interrupts are off */
36033 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36034 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36035 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36036 if (rc)
36037 goto clean2;
36038 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36039 * fake ones to scoop up any residual completions.
36040 */
36041 spin_lock_irqsave(&h->lock, flags);
36042 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36043 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36044 spin_unlock_irqrestore(&h->lock, flags);
36045 free_irq(h->intr[h->intr_mode], h);
36046 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36047 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36048 dev_info(&h->pdev->dev, "Board READY.\n");
36049 dev_info(&h->pdev->dev,
36050 "Waiting for stale completions to drain.\n");
36051 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36052 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36053 msleep(10000);
36054 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36055 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36056
36057 rc = controller_reset_failed(h->cfgtable);
36058 if (rc)
36059 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36060 cciss_scsi_setup(h);
36061
36062 /* Turn the interrupts on so we can service requests */
36063 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36064 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36065
36066 /* Get the firmware version */
36067 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36068 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36069 kfree(flush_buf);
36070 if (return_code != IO_OK)
36071 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36072 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36073 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36074 free_irq(h->intr[h->intr_mode], h);
36075 }
36076
36077 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36078 index 7fda30e..eb5dfe0 100644
36079 --- a/drivers/block/cciss.h
36080 +++ b/drivers/block/cciss.h
36081 @@ -101,7 +101,7 @@ struct ctlr_info
36082 /* information about each logical volume */
36083 drive_info_struct *drv[CISS_MAX_LUN];
36084
36085 - struct access_method access;
36086 + struct access_method *access;
36087
36088 /* queue and queue Info */
36089 struct list_head reqQ;
36090 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36091 index 2b94403..fd6ad1f 100644
36092 --- a/drivers/block/cpqarray.c
36093 +++ b/drivers/block/cpqarray.c
36094 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36095 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36096 goto Enomem4;
36097 }
36098 - hba[i]->access.set_intr_mask(hba[i], 0);
36099 + hba[i]->access->set_intr_mask(hba[i], 0);
36100 if (request_irq(hba[i]->intr, do_ida_intr,
36101 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36102 {
36103 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36104 add_timer(&hba[i]->timer);
36105
36106 /* Enable IRQ now that spinlock and rate limit timer are set up */
36107 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36108 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36109
36110 for(j=0; j<NWD; j++) {
36111 struct gendisk *disk = ida_gendisk[i][j];
36112 @@ -694,7 +694,7 @@ DBGINFO(
36113 for(i=0; i<NR_PRODUCTS; i++) {
36114 if (board_id == products[i].board_id) {
36115 c->product_name = products[i].product_name;
36116 - c->access = *(products[i].access);
36117 + c->access = products[i].access;
36118 break;
36119 }
36120 }
36121 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36122 hba[ctlr]->intr = intr;
36123 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36124 hba[ctlr]->product_name = products[j].product_name;
36125 - hba[ctlr]->access = *(products[j].access);
36126 + hba[ctlr]->access = products[j].access;
36127 hba[ctlr]->ctlr = ctlr;
36128 hba[ctlr]->board_id = board_id;
36129 hba[ctlr]->pci_dev = NULL; /* not PCI */
36130 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36131
36132 while((c = h->reqQ) != NULL) {
36133 /* Can't do anything if we're busy */
36134 - if (h->access.fifo_full(h) == 0)
36135 + if (h->access->fifo_full(h) == 0)
36136 return;
36137
36138 /* Get the first entry from the request Q */
36139 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36140 h->Qdepth--;
36141
36142 /* Tell the controller to do our bidding */
36143 - h->access.submit_command(h, c);
36144 + h->access->submit_command(h, c);
36145
36146 /* Get onto the completion Q */
36147 addQ(&h->cmpQ, c);
36148 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36149 unsigned long flags;
36150 __u32 a,a1;
36151
36152 - istat = h->access.intr_pending(h);
36153 + istat = h->access->intr_pending(h);
36154 /* Is this interrupt for us? */
36155 if (istat == 0)
36156 return IRQ_NONE;
36157 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36158 */
36159 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36160 if (istat & FIFO_NOT_EMPTY) {
36161 - while((a = h->access.command_completed(h))) {
36162 + while((a = h->access->command_completed(h))) {
36163 a1 = a; a &= ~3;
36164 if ((c = h->cmpQ) == NULL)
36165 {
36166 @@ -1448,11 +1448,11 @@ static int sendcmd(
36167 /*
36168 * Disable interrupt
36169 */
36170 - info_p->access.set_intr_mask(info_p, 0);
36171 + info_p->access->set_intr_mask(info_p, 0);
36172 /* Make sure there is room in the command FIFO */
36173 /* Actually it should be completely empty at this time. */
36174 for (i = 200000; i > 0; i--) {
36175 - temp = info_p->access.fifo_full(info_p);
36176 + temp = info_p->access->fifo_full(info_p);
36177 if (temp != 0) {
36178 break;
36179 }
36180 @@ -1465,7 +1465,7 @@ DBG(
36181 /*
36182 * Send the cmd
36183 */
36184 - info_p->access.submit_command(info_p, c);
36185 + info_p->access->submit_command(info_p, c);
36186 complete = pollcomplete(ctlr);
36187
36188 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36189 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36190 * we check the new geometry. Then turn interrupts back on when
36191 * we're done.
36192 */
36193 - host->access.set_intr_mask(host, 0);
36194 + host->access->set_intr_mask(host, 0);
36195 getgeometry(ctlr);
36196 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36197 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36198
36199 for(i=0; i<NWD; i++) {
36200 struct gendisk *disk = ida_gendisk[ctlr][i];
36201 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36202 /* Wait (up to 2 seconds) for a command to complete */
36203
36204 for (i = 200000; i > 0; i--) {
36205 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36206 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36207 if (done == 0) {
36208 udelay(10); /* a short fixed delay */
36209 } else
36210 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36211 index be73e9d..7fbf140 100644
36212 --- a/drivers/block/cpqarray.h
36213 +++ b/drivers/block/cpqarray.h
36214 @@ -99,7 +99,7 @@ struct ctlr_info {
36215 drv_info_t drv[NWD];
36216 struct proc_dir_entry *proc;
36217
36218 - struct access_method access;
36219 + struct access_method *access;
36220
36221 cmdlist_t *reqQ;
36222 cmdlist_t *cmpQ;
36223 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36224 index 2d7f608..11245fe 100644
36225 --- a/drivers/block/drbd/drbd_int.h
36226 +++ b/drivers/block/drbd/drbd_int.h
36227 @@ -582,7 +582,7 @@ struct drbd_epoch {
36228 struct drbd_tconn *tconn;
36229 struct list_head list;
36230 unsigned int barrier_nr;
36231 - atomic_t epoch_size; /* increased on every request added. */
36232 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36233 atomic_t active; /* increased on every req. added, and dec on every finished. */
36234 unsigned long flags;
36235 };
36236 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36237 unsigned int al_tr_number;
36238 int al_tr_cycle;
36239 wait_queue_head_t seq_wait;
36240 - atomic_t packet_seq;
36241 + atomic_unchecked_t packet_seq;
36242 unsigned int peer_seq;
36243 spinlock_t peer_seq_lock;
36244 unsigned int minor;
36245 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36246 char __user *uoptval;
36247 int err;
36248
36249 - uoptval = (char __user __force *)optval;
36250 + uoptval = (char __force_user *)optval;
36251
36252 set_fs(KERNEL_DS);
36253 if (level == SOL_SOCKET)
36254 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36255 index 55635ed..40e837c 100644
36256 --- a/drivers/block/drbd/drbd_main.c
36257 +++ b/drivers/block/drbd/drbd_main.c
36258 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36259 p->sector = sector;
36260 p->block_id = block_id;
36261 p->blksize = blksize;
36262 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36263 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36264 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36265 }
36266
36267 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36268 return -EIO;
36269 p->sector = cpu_to_be64(req->i.sector);
36270 p->block_id = (unsigned long)req;
36271 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36272 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36273 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36274 if (mdev->state.conn >= C_SYNC_SOURCE &&
36275 mdev->state.conn <= C_PAUSED_SYNC_T)
36276 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36277 {
36278 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36279
36280 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36281 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36282 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36283 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36284 kfree(tconn->current_epoch);
36285
36286 idr_destroy(&tconn->volumes);
36287 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36288 index 8cc1e64..ba7ffa9 100644
36289 --- a/drivers/block/drbd/drbd_nl.c
36290 +++ b/drivers/block/drbd/drbd_nl.c
36291 @@ -3440,7 +3440,7 @@ out:
36292
36293 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36294 {
36295 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36296 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36297 struct sk_buff *msg;
36298 struct drbd_genlmsghdr *d_out;
36299 unsigned seq;
36300 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36301 return;
36302 }
36303
36304 - seq = atomic_inc_return(&drbd_genl_seq);
36305 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36306 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36307 if (!msg)
36308 goto failed;
36309 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36310 index cc29cd3..d4b058b 100644
36311 --- a/drivers/block/drbd/drbd_receiver.c
36312 +++ b/drivers/block/drbd/drbd_receiver.c
36313 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36314 {
36315 int err;
36316
36317 - atomic_set(&mdev->packet_seq, 0);
36318 + atomic_set_unchecked(&mdev->packet_seq, 0);
36319 mdev->peer_seq = 0;
36320
36321 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36322 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36323 do {
36324 next_epoch = NULL;
36325
36326 - epoch_size = atomic_read(&epoch->epoch_size);
36327 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36328
36329 switch (ev & ~EV_CLEANUP) {
36330 case EV_PUT:
36331 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36332 rv = FE_DESTROYED;
36333 } else {
36334 epoch->flags = 0;
36335 - atomic_set(&epoch->epoch_size, 0);
36336 + atomic_set_unchecked(&epoch->epoch_size, 0);
36337 /* atomic_set(&epoch->active, 0); is already zero */
36338 if (rv == FE_STILL_LIVE)
36339 rv = FE_RECYCLED;
36340 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36341 conn_wait_active_ee_empty(tconn);
36342 drbd_flush(tconn);
36343
36344 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36345 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36346 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36347 if (epoch)
36348 break;
36349 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36350 }
36351
36352 epoch->flags = 0;
36353 - atomic_set(&epoch->epoch_size, 0);
36354 + atomic_set_unchecked(&epoch->epoch_size, 0);
36355 atomic_set(&epoch->active, 0);
36356
36357 spin_lock(&tconn->epoch_lock);
36358 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36359 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36360 list_add(&epoch->list, &tconn->current_epoch->list);
36361 tconn->current_epoch = epoch;
36362 tconn->epochs++;
36363 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36364
36365 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36366 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36367 - atomic_inc(&tconn->current_epoch->epoch_size);
36368 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36369 err2 = drbd_drain_block(mdev, pi->size);
36370 if (!err)
36371 err = err2;
36372 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36373
36374 spin_lock(&tconn->epoch_lock);
36375 peer_req->epoch = tconn->current_epoch;
36376 - atomic_inc(&peer_req->epoch->epoch_size);
36377 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36378 atomic_inc(&peer_req->epoch->active);
36379 spin_unlock(&tconn->epoch_lock);
36380
36381 @@ -4347,7 +4347,7 @@ struct data_cmd {
36382 int expect_payload;
36383 size_t pkt_size;
36384 int (*fn)(struct drbd_tconn *, struct packet_info *);
36385 -};
36386 +} __do_const;
36387
36388 static struct data_cmd drbd_cmd_handler[] = {
36389 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36390 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36391 if (!list_empty(&tconn->current_epoch->list))
36392 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36393 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36394 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36395 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36396 tconn->send.seen_any_write_yet = false;
36397
36398 conn_info(tconn, "Connection closed\n");
36399 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36400 struct asender_cmd {
36401 size_t pkt_size;
36402 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36403 -};
36404 +} __do_const;
36405
36406 static struct asender_cmd asender_tbl[] = {
36407 [P_PING] = { 0, got_Ping },
36408 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36409 index 2f036ca..68d3f40 100644
36410 --- a/drivers/block/loop.c
36411 +++ b/drivers/block/loop.c
36412 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36413
36414 file_start_write(file);
36415 set_fs(get_ds());
36416 - bw = file->f_op->write(file, buf, len, &pos);
36417 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36418 set_fs(old_fs);
36419 file_end_write(file);
36420 if (likely(bw == len))
36421 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36422 index 5618847..5a46f3b 100644
36423 --- a/drivers/block/pktcdvd.c
36424 +++ b/drivers/block/pktcdvd.c
36425 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
36426
36427 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
36428 {
36429 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
36430 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
36431 }
36432
36433 /*
36434 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
36435 return -EROFS;
36436 }
36437 pd->settings.fp = ti.fp;
36438 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
36439 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
36440
36441 if (ti.nwa_v) {
36442 pd->nwa = be32_to_cpu(ti.next_writable);
36443 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36444 index 60abf59..80789e1 100644
36445 --- a/drivers/bluetooth/btwilink.c
36446 +++ b/drivers/bluetooth/btwilink.c
36447 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36448
36449 static int bt_ti_probe(struct platform_device *pdev)
36450 {
36451 - static struct ti_st *hst;
36452 + struct ti_st *hst;
36453 struct hci_dev *hdev;
36454 int err;
36455
36456 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36457 index 2009266..7be9ca2 100644
36458 --- a/drivers/bus/arm-cci.c
36459 +++ b/drivers/bus/arm-cci.c
36460 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
36461
36462 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36463
36464 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36465 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36466 if (!ports)
36467 return -ENOMEM;
36468
36469 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36470 index 8a3aff7..d7538c2 100644
36471 --- a/drivers/cdrom/cdrom.c
36472 +++ b/drivers/cdrom/cdrom.c
36473 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36474 ENSURE(reset, CDC_RESET);
36475 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36476 cdi->mc_flags = 0;
36477 - cdo->n_minors = 0;
36478 cdi->options = CDO_USE_FFLAGS;
36479
36480 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36481 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36482 else
36483 cdi->cdda_method = CDDA_OLD;
36484
36485 - if (!cdo->generic_packet)
36486 - cdo->generic_packet = cdrom_dummy_generic_packet;
36487 + if (!cdo->generic_packet) {
36488 + pax_open_kernel();
36489 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36490 + pax_close_kernel();
36491 + }
36492
36493 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36494 mutex_lock(&cdrom_mutex);
36495 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36496 if (cdi->exit)
36497 cdi->exit(cdi);
36498
36499 - cdi->ops->n_minors--;
36500 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36501 }
36502
36503 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36504 */
36505 nr = nframes;
36506 do {
36507 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36508 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36509 if (cgc.buffer)
36510 break;
36511
36512 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36513 struct cdrom_device_info *cdi;
36514 int ret;
36515
36516 - ret = scnprintf(info + *pos, max_size - *pos, header);
36517 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36518 if (!ret)
36519 return 1;
36520
36521 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36522 index 5980cb9..6d7bd7e 100644
36523 --- a/drivers/cdrom/gdrom.c
36524 +++ b/drivers/cdrom/gdrom.c
36525 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36526 .audio_ioctl = gdrom_audio_ioctl,
36527 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36528 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36529 - .n_minors = 1,
36530 };
36531
36532 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36533 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36534 index 1421997..33f5d6d 100644
36535 --- a/drivers/char/Kconfig
36536 +++ b/drivers/char/Kconfig
36537 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36538
36539 config DEVKMEM
36540 bool "/dev/kmem virtual device support"
36541 - default y
36542 + default n
36543 + depends on !GRKERNSEC_KMEM
36544 help
36545 Say Y here if you want to support the /dev/kmem device. The
36546 /dev/kmem device is rarely used, but can be used for certain
36547 @@ -570,6 +571,7 @@ config DEVPORT
36548 bool
36549 depends on !M68K
36550 depends on ISA || PCI
36551 + depends on !GRKERNSEC_KMEM
36552 default y
36553
36554 source "drivers/s390/char/Kconfig"
36555 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36556 index a48e05b..6bac831 100644
36557 --- a/drivers/char/agp/compat_ioctl.c
36558 +++ b/drivers/char/agp/compat_ioctl.c
36559 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36560 return -ENOMEM;
36561 }
36562
36563 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36564 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36565 sizeof(*usegment) * ureserve.seg_count)) {
36566 kfree(usegment);
36567 kfree(ksegment);
36568 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36569 index 1b19239..b87b143 100644
36570 --- a/drivers/char/agp/frontend.c
36571 +++ b/drivers/char/agp/frontend.c
36572 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36573 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36574 return -EFAULT;
36575
36576 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36577 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36578 return -EFAULT;
36579
36580 client = agp_find_client_by_pid(reserve.pid);
36581 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36582 if (segment == NULL)
36583 return -ENOMEM;
36584
36585 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36586 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36587 sizeof(struct agp_segment) * reserve.seg_count)) {
36588 kfree(segment);
36589 return -EFAULT;
36590 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36591 index 4f94375..413694e 100644
36592 --- a/drivers/char/genrtc.c
36593 +++ b/drivers/char/genrtc.c
36594 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36595 switch (cmd) {
36596
36597 case RTC_PLL_GET:
36598 + memset(&pll, 0, sizeof(pll));
36599 if (get_rtc_pll(&pll))
36600 return -EINVAL;
36601 else
36602 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36603 index 448ce5e..3a76625 100644
36604 --- a/drivers/char/hpet.c
36605 +++ b/drivers/char/hpet.c
36606 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36607 }
36608
36609 static int
36610 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36611 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36612 struct hpet_info *info)
36613 {
36614 struct hpet_timer __iomem *timer;
36615 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36616 index 86fe45c..c0ea948 100644
36617 --- a/drivers/char/hw_random/intel-rng.c
36618 +++ b/drivers/char/hw_random/intel-rng.c
36619 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36620
36621 if (no_fwh_detect)
36622 return -ENODEV;
36623 - printk(warning);
36624 + printk("%s", warning);
36625 return -EBUSY;
36626 }
36627
36628 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36629 index ec4e10f..f2a763b 100644
36630 --- a/drivers/char/ipmi/ipmi_msghandler.c
36631 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36632 @@ -420,7 +420,7 @@ struct ipmi_smi {
36633 struct proc_dir_entry *proc_dir;
36634 char proc_dir_name[10];
36635
36636 - atomic_t stats[IPMI_NUM_STATS];
36637 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36638
36639 /*
36640 * run_to_completion duplicate of smb_info, smi_info
36641 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36642
36643
36644 #define ipmi_inc_stat(intf, stat) \
36645 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36646 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36647 #define ipmi_get_stat(intf, stat) \
36648 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36649 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36650
36651 static int is_lan_addr(struct ipmi_addr *addr)
36652 {
36653 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36654 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36655 init_waitqueue_head(&intf->waitq);
36656 for (i = 0; i < IPMI_NUM_STATS; i++)
36657 - atomic_set(&intf->stats[i], 0);
36658 + atomic_set_unchecked(&intf->stats[i], 0);
36659
36660 intf->proc_dir = NULL;
36661
36662 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36663 index 15e4a60..b046093 100644
36664 --- a/drivers/char/ipmi/ipmi_si_intf.c
36665 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36666 @@ -280,7 +280,7 @@ struct smi_info {
36667 unsigned char slave_addr;
36668
36669 /* Counters and things for the proc filesystem. */
36670 - atomic_t stats[SI_NUM_STATS];
36671 + atomic_unchecked_t stats[SI_NUM_STATS];
36672
36673 struct task_struct *thread;
36674
36675 @@ -289,9 +289,9 @@ struct smi_info {
36676 };
36677
36678 #define smi_inc_stat(smi, stat) \
36679 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36680 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36681 #define smi_get_stat(smi, stat) \
36682 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36683 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36684
36685 #define SI_MAX_PARMS 4
36686
36687 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
36688 atomic_set(&new_smi->req_events, 0);
36689 new_smi->run_to_completion = 0;
36690 for (i = 0; i < SI_NUM_STATS; i++)
36691 - atomic_set(&new_smi->stats[i], 0);
36692 + atomic_set_unchecked(&new_smi->stats[i], 0);
36693
36694 new_smi->interrupt_disabled = 1;
36695 atomic_set(&new_smi->stop_operation, 0);
36696 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36697 index f895a8c..2bc9147 100644
36698 --- a/drivers/char/mem.c
36699 +++ b/drivers/char/mem.c
36700 @@ -18,6 +18,7 @@
36701 #include <linux/raw.h>
36702 #include <linux/tty.h>
36703 #include <linux/capability.h>
36704 +#include <linux/security.h>
36705 #include <linux/ptrace.h>
36706 #include <linux/device.h>
36707 #include <linux/highmem.h>
36708 @@ -37,6 +38,10 @@
36709
36710 #define DEVPORT_MINOR 4
36711
36712 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36713 +extern const struct file_operations grsec_fops;
36714 +#endif
36715 +
36716 static inline unsigned long size_inside_page(unsigned long start,
36717 unsigned long size)
36718 {
36719 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36720
36721 while (cursor < to) {
36722 if (!devmem_is_allowed(pfn)) {
36723 +#ifdef CONFIG_GRKERNSEC_KMEM
36724 + gr_handle_mem_readwrite(from, to);
36725 +#else
36726 printk(KERN_INFO
36727 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36728 current->comm, from, to);
36729 +#endif
36730 return 0;
36731 }
36732 cursor += PAGE_SIZE;
36733 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36734 }
36735 return 1;
36736 }
36737 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36738 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36739 +{
36740 + return 0;
36741 +}
36742 #else
36743 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36744 {
36745 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36746
36747 while (count > 0) {
36748 unsigned long remaining;
36749 + char *temp;
36750
36751 sz = size_inside_page(p, count);
36752
36753 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36754 if (!ptr)
36755 return -EFAULT;
36756
36757 - remaining = copy_to_user(buf, ptr, sz);
36758 +#ifdef CONFIG_PAX_USERCOPY
36759 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36760 + if (!temp) {
36761 + unxlate_dev_mem_ptr(p, ptr);
36762 + return -ENOMEM;
36763 + }
36764 + memcpy(temp, ptr, sz);
36765 +#else
36766 + temp = ptr;
36767 +#endif
36768 +
36769 + remaining = copy_to_user(buf, temp, sz);
36770 +
36771 +#ifdef CONFIG_PAX_USERCOPY
36772 + kfree(temp);
36773 +#endif
36774 +
36775 unxlate_dev_mem_ptr(p, ptr);
36776 if (remaining)
36777 return -EFAULT;
36778 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36779 size_t count, loff_t *ppos)
36780 {
36781 unsigned long p = *ppos;
36782 - ssize_t low_count, read, sz;
36783 + ssize_t low_count, read, sz, err = 0;
36784 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36785 - int err = 0;
36786
36787 read = 0;
36788 if (p < (unsigned long) high_memory) {
36789 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36790 }
36791 #endif
36792 while (low_count > 0) {
36793 + char *temp;
36794 +
36795 sz = size_inside_page(p, low_count);
36796
36797 /*
36798 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36799 */
36800 kbuf = xlate_dev_kmem_ptr((char *)p);
36801
36802 - if (copy_to_user(buf, kbuf, sz))
36803 +#ifdef CONFIG_PAX_USERCOPY
36804 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36805 + if (!temp)
36806 + return -ENOMEM;
36807 + memcpy(temp, kbuf, sz);
36808 +#else
36809 + temp = kbuf;
36810 +#endif
36811 +
36812 + err = copy_to_user(buf, temp, sz);
36813 +
36814 +#ifdef CONFIG_PAX_USERCOPY
36815 + kfree(temp);
36816 +#endif
36817 +
36818 + if (err)
36819 return -EFAULT;
36820 buf += sz;
36821 p += sz;
36822 @@ -822,6 +869,9 @@ static const struct memdev {
36823 #ifdef CONFIG_PRINTK
36824 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36825 #endif
36826 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36827 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36828 +#endif
36829 };
36830
36831 static int memory_open(struct inode *inode, struct file *filp)
36832 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36833 continue;
36834
36835 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36836 - NULL, devlist[minor].name);
36837 + NULL, "%s", devlist[minor].name);
36838 }
36839
36840 return tty_init();
36841 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36842 index 9df78e2..01ba9ae 100644
36843 --- a/drivers/char/nvram.c
36844 +++ b/drivers/char/nvram.c
36845 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36846
36847 spin_unlock_irq(&rtc_lock);
36848
36849 - if (copy_to_user(buf, contents, tmp - contents))
36850 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36851 return -EFAULT;
36852
36853 *ppos = i;
36854 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36855 index d39cca6..8c1e269 100644
36856 --- a/drivers/char/pcmcia/synclink_cs.c
36857 +++ b/drivers/char/pcmcia/synclink_cs.c
36858 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36859
36860 if (debug_level >= DEBUG_LEVEL_INFO)
36861 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36862 - __FILE__, __LINE__, info->device_name, port->count);
36863 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36864
36865 - WARN_ON(!port->count);
36866 + WARN_ON(!atomic_read(&port->count));
36867
36868 if (tty_port_close_start(port, tty, filp) == 0)
36869 goto cleanup;
36870 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36871 cleanup:
36872 if (debug_level >= DEBUG_LEVEL_INFO)
36873 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36874 - tty->driver->name, port->count);
36875 + tty->driver->name, atomic_read(&port->count));
36876 }
36877
36878 /* Wait until the transmitter is empty.
36879 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36880
36881 if (debug_level >= DEBUG_LEVEL_INFO)
36882 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36883 - __FILE__, __LINE__, tty->driver->name, port->count);
36884 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36885
36886 /* If port is closing, signal caller to try again */
36887 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36888 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36889 goto cleanup;
36890 }
36891 spin_lock(&port->lock);
36892 - port->count++;
36893 + atomic_inc(&port->count);
36894 spin_unlock(&port->lock);
36895 spin_unlock_irqrestore(&info->netlock, flags);
36896
36897 - if (port->count == 1) {
36898 + if (atomic_read(&port->count) == 1) {
36899 /* 1st open on this device, init hardware */
36900 retval = startup(info, tty);
36901 if (retval < 0)
36902 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36903 unsigned short new_crctype;
36904
36905 /* return error if TTY interface open */
36906 - if (info->port.count)
36907 + if (atomic_read(&info->port.count))
36908 return -EBUSY;
36909
36910 switch (encoding)
36911 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36912
36913 /* arbitrate between network and tty opens */
36914 spin_lock_irqsave(&info->netlock, flags);
36915 - if (info->port.count != 0 || info->netcount != 0) {
36916 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36917 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36918 spin_unlock_irqrestore(&info->netlock, flags);
36919 return -EBUSY;
36920 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36921 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36922
36923 /* return error if TTY interface open */
36924 - if (info->port.count)
36925 + if (atomic_read(&info->port.count))
36926 return -EBUSY;
36927
36928 if (cmd != SIOCWANDEV)
36929 diff --git a/drivers/char/random.c b/drivers/char/random.c
36930 index 7a744d3..35a177ee 100644
36931 --- a/drivers/char/random.c
36932 +++ b/drivers/char/random.c
36933 @@ -269,8 +269,13 @@
36934 /*
36935 * Configuration information
36936 */
36937 +#ifdef CONFIG_GRKERNSEC_RANDNET
36938 +#define INPUT_POOL_WORDS 512
36939 +#define OUTPUT_POOL_WORDS 128
36940 +#else
36941 #define INPUT_POOL_WORDS 128
36942 #define OUTPUT_POOL_WORDS 32
36943 +#endif
36944 #define SEC_XFER_SIZE 512
36945 #define EXTRACT_SIZE 10
36946
36947 @@ -310,10 +315,17 @@ static struct poolinfo {
36948 int poolwords;
36949 int tap1, tap2, tap3, tap4, tap5;
36950 } poolinfo_table[] = {
36951 +#ifdef CONFIG_GRKERNSEC_RANDNET
36952 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36953 + { 512, 411, 308, 208, 104, 1 },
36954 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36955 + { 128, 103, 76, 51, 25, 1 },
36956 +#else
36957 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36958 { 128, 103, 76, 51, 25, 1 },
36959 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36960 { 32, 26, 20, 14, 7, 1 },
36961 +#endif
36962 #if 0
36963 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36964 { 2048, 1638, 1231, 819, 411, 1 },
36965 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36966 input_rotate += i ? 7 : 14;
36967 }
36968
36969 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36970 - ACCESS_ONCE(r->add_ptr) = i;
36971 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36972 + ACCESS_ONCE_RW(r->add_ptr) = i;
36973 smp_wmb();
36974
36975 if (out)
36976 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36977
36978 extract_buf(r, tmp);
36979 i = min_t(int, nbytes, EXTRACT_SIZE);
36980 - if (copy_to_user(buf, tmp, i)) {
36981 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36982 ret = -EFAULT;
36983 break;
36984 }
36985 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36986 #include <linux/sysctl.h>
36987
36988 static int min_read_thresh = 8, min_write_thresh;
36989 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36990 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36991 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36992 static char sysctl_bootid[16];
36993
36994 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
36995 static int proc_do_uuid(struct ctl_table *table, int write,
36996 void __user *buffer, size_t *lenp, loff_t *ppos)
36997 {
36998 - struct ctl_table fake_table;
36999 + ctl_table_no_const fake_table;
37000 unsigned char buf[64], tmp_uuid[16], *uuid;
37001
37002 uuid = table->data;
37003 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37004 index 7cc1fe22..b602d6b 100644
37005 --- a/drivers/char/sonypi.c
37006 +++ b/drivers/char/sonypi.c
37007 @@ -54,6 +54,7 @@
37008
37009 #include <asm/uaccess.h>
37010 #include <asm/io.h>
37011 +#include <asm/local.h>
37012
37013 #include <linux/sonypi.h>
37014
37015 @@ -490,7 +491,7 @@ static struct sonypi_device {
37016 spinlock_t fifo_lock;
37017 wait_queue_head_t fifo_proc_list;
37018 struct fasync_struct *fifo_async;
37019 - int open_count;
37020 + local_t open_count;
37021 int model;
37022 struct input_dev *input_jog_dev;
37023 struct input_dev *input_key_dev;
37024 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37025 static int sonypi_misc_release(struct inode *inode, struct file *file)
37026 {
37027 mutex_lock(&sonypi_device.lock);
37028 - sonypi_device.open_count--;
37029 + local_dec(&sonypi_device.open_count);
37030 mutex_unlock(&sonypi_device.lock);
37031 return 0;
37032 }
37033 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37034 {
37035 mutex_lock(&sonypi_device.lock);
37036 /* Flush input queue on first open */
37037 - if (!sonypi_device.open_count)
37038 + if (!local_read(&sonypi_device.open_count))
37039 kfifo_reset(&sonypi_device.fifo);
37040 - sonypi_device.open_count++;
37041 + local_inc(&sonypi_device.open_count);
37042 mutex_unlock(&sonypi_device.lock);
37043
37044 return 0;
37045 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37046 index 64420b3..5c40b56 100644
37047 --- a/drivers/char/tpm/tpm_acpi.c
37048 +++ b/drivers/char/tpm/tpm_acpi.c
37049 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37050 virt = acpi_os_map_memory(start, len);
37051 if (!virt) {
37052 kfree(log->bios_event_log);
37053 + log->bios_event_log = NULL;
37054 printk("%s: ERROR - Unable to map memory\n", __func__);
37055 return -EIO;
37056 }
37057
37058 - memcpy_fromio(log->bios_event_log, virt, len);
37059 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37060
37061 acpi_os_unmap_memory(virt, len);
37062 return 0;
37063 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37064 index 84ddc55..1d32f1e 100644
37065 --- a/drivers/char/tpm/tpm_eventlog.c
37066 +++ b/drivers/char/tpm/tpm_eventlog.c
37067 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37068 event = addr;
37069
37070 if ((event->event_type == 0 && event->event_size == 0) ||
37071 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37072 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37073 return NULL;
37074
37075 return addr;
37076 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37077 return NULL;
37078
37079 if ((event->event_type == 0 && event->event_size == 0) ||
37080 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37081 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37082 return NULL;
37083
37084 (*pos)++;
37085 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37086 int i;
37087
37088 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37089 - seq_putc(m, data[i]);
37090 + if (!seq_putc(m, data[i]))
37091 + return -EFAULT;
37092
37093 return 0;
37094 }
37095 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37096 index b79cf3e..de172d64f 100644
37097 --- a/drivers/char/virtio_console.c
37098 +++ b/drivers/char/virtio_console.c
37099 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37100 if (to_user) {
37101 ssize_t ret;
37102
37103 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37104 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37105 if (ret)
37106 return -EFAULT;
37107 } else {
37108 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37109 if (!port_has_data(port) && !port->host_connected)
37110 return 0;
37111
37112 - return fill_readbuf(port, ubuf, count, true);
37113 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37114 }
37115
37116 static int wait_port_writable(struct port *port, bool nonblock)
37117 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37118 index a33f46f..a720eed 100644
37119 --- a/drivers/clk/clk-composite.c
37120 +++ b/drivers/clk/clk-composite.c
37121 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37122 struct clk *clk;
37123 struct clk_init_data init;
37124 struct clk_composite *composite;
37125 - struct clk_ops *clk_composite_ops;
37126 + clk_ops_no_const *clk_composite_ops;
37127
37128 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37129 if (!composite) {
37130 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37131 index 81dd31a..ef5c542 100644
37132 --- a/drivers/clk/socfpga/clk.c
37133 +++ b/drivers/clk/socfpga/clk.c
37134 @@ -22,6 +22,7 @@
37135 #include <linux/clk-provider.h>
37136 #include <linux/io.h>
37137 #include <linux/of.h>
37138 +#include <asm/pgtable.h>
37139
37140 /* Clock Manager offsets */
37141 #define CLKMGR_CTRL 0x0
37142 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37143 streq(clk_name, "periph_pll") ||
37144 streq(clk_name, "sdram_pll")) {
37145 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37146 - clk_pll_ops.enable = clk_gate_ops.enable;
37147 - clk_pll_ops.disable = clk_gate_ops.disable;
37148 + pax_open_kernel();
37149 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37150 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37151 + pax_close_kernel();
37152 }
37153
37154 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37155 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37156 return parent_rate / div;
37157 }
37158
37159 -static struct clk_ops gateclk_ops = {
37160 +static clk_ops_no_const gateclk_ops __read_only = {
37161 .recalc_rate = socfpga_clk_recalc_rate,
37162 .get_parent = socfpga_clk_get_parent,
37163 .set_parent = socfpga_clk_set_parent,
37164 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37165 index 506fd23..01a593f 100644
37166 --- a/drivers/cpufreq/acpi-cpufreq.c
37167 +++ b/drivers/cpufreq/acpi-cpufreq.c
37168 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37169 return sprintf(buf, "%u\n", boost_enabled);
37170 }
37171
37172 -static struct global_attr global_boost = __ATTR(boost, 0644,
37173 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37174 show_global_boost,
37175 store_global_boost);
37176
37177 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37178 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37179 per_cpu(acfreq_data, cpu) = data;
37180
37181 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37182 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37183 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37184 + pax_open_kernel();
37185 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37186 + pax_close_kernel();
37187 + }
37188
37189 result = acpi_processor_register_performance(data->acpi_data, cpu);
37190 if (result)
37191 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37192 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37193 break;
37194 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37195 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37196 + pax_open_kernel();
37197 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37198 + pax_close_kernel();
37199 policy->cur = get_cur_freq_on_cpu(cpu);
37200 break;
37201 default:
37202 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37203 index 04548f7..457a342 100644
37204 --- a/drivers/cpufreq/cpufreq.c
37205 +++ b/drivers/cpufreq/cpufreq.c
37206 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37207 return NOTIFY_OK;
37208 }
37209
37210 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37211 +static struct notifier_block cpufreq_cpu_notifier = {
37212 .notifier_call = cpufreq_cpu_callback,
37213 };
37214
37215 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37216
37217 pr_debug("trying to register driver %s\n", driver_data->name);
37218
37219 - if (driver_data->setpolicy)
37220 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37221 + if (driver_data->setpolicy) {
37222 + pax_open_kernel();
37223 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37224 + pax_close_kernel();
37225 + }
37226
37227 write_lock_irqsave(&cpufreq_driver_lock, flags);
37228 if (cpufreq_driver) {
37229 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37230 index 0806c31..6a73276 100644
37231 --- a/drivers/cpufreq/cpufreq_governor.c
37232 +++ b/drivers/cpufreq/cpufreq_governor.c
37233 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37234 struct dbs_data *dbs_data;
37235 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37236 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37237 - struct od_ops *od_ops = NULL;
37238 + const struct od_ops *od_ops = NULL;
37239 struct od_dbs_tuners *od_tuners = NULL;
37240 struct cs_dbs_tuners *cs_tuners = NULL;
37241 struct cpu_dbs_common_info *cpu_cdbs;
37242 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37243
37244 if ((cdata->governor == GOV_CONSERVATIVE) &&
37245 (!policy->governor->initialized)) {
37246 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37247 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37248
37249 cpufreq_register_notifier(cs_ops->notifier_block,
37250 CPUFREQ_TRANSITION_NOTIFIER);
37251 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37252
37253 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37254 (policy->governor->initialized == 1)) {
37255 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37256 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37257
37258 cpufreq_unregister_notifier(cs_ops->notifier_block,
37259 CPUFREQ_TRANSITION_NOTIFIER);
37260 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37261 index 88cd39f..87f0393 100644
37262 --- a/drivers/cpufreq/cpufreq_governor.h
37263 +++ b/drivers/cpufreq/cpufreq_governor.h
37264 @@ -202,7 +202,7 @@ struct common_dbs_data {
37265 void (*exit)(struct dbs_data *dbs_data);
37266
37267 /* Governor specific ops, see below */
37268 - void *gov_ops;
37269 + const void *gov_ops;
37270 };
37271
37272 /* Governor Per policy data */
37273 @@ -222,7 +222,7 @@ struct od_ops {
37274 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37275 unsigned int freq_next, unsigned int relation);
37276 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37277 -};
37278 +} __no_const;
37279
37280 struct cs_ops {
37281 struct notifier_block *notifier_block;
37282 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37283 index 32f26f6..feb657b 100644
37284 --- a/drivers/cpufreq/cpufreq_ondemand.c
37285 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37286 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37287
37288 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37289
37290 -static struct od_ops od_ops = {
37291 +static struct od_ops od_ops __read_only = {
37292 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37293 .powersave_bias_target = generic_powersave_bias_target,
37294 .freq_increase = dbs_freq_increase,
37295 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37296 (struct cpufreq_policy *, unsigned int, unsigned int),
37297 unsigned int powersave_bias)
37298 {
37299 - od_ops.powersave_bias_target = f;
37300 + pax_open_kernel();
37301 + *(void **)&od_ops.powersave_bias_target = f;
37302 + pax_close_kernel();
37303 od_set_powersave_bias(powersave_bias);
37304 }
37305 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37306
37307 void od_unregister_powersave_bias_handler(void)
37308 {
37309 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37310 + pax_open_kernel();
37311 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37312 + pax_close_kernel();
37313 od_set_powersave_bias(0);
37314 }
37315 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37316 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37317 index 4cf0d28..5830372 100644
37318 --- a/drivers/cpufreq/cpufreq_stats.c
37319 +++ b/drivers/cpufreq/cpufreq_stats.c
37320 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37321 }
37322
37323 /* priority=1 so this will get called before cpufreq_remove_dev */
37324 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37325 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37326 .notifier_call = cpufreq_stat_cpu_callback,
37327 .priority = 1,
37328 };
37329 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37330 index 2f0a2a6..93d728e 100644
37331 --- a/drivers/cpufreq/p4-clockmod.c
37332 +++ b/drivers/cpufreq/p4-clockmod.c
37333 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37334 case 0x0F: /* Core Duo */
37335 case 0x16: /* Celeron Core */
37336 case 0x1C: /* Atom */
37337 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37338 + pax_open_kernel();
37339 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37340 + pax_close_kernel();
37341 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37342 case 0x0D: /* Pentium M (Dothan) */
37343 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37344 + pax_open_kernel();
37345 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37346 + pax_close_kernel();
37347 /* fall through */
37348 case 0x09: /* Pentium M (Banias) */
37349 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37350 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37351
37352 /* on P-4s, the TSC runs with constant frequency independent whether
37353 * throttling is active or not. */
37354 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37355 + pax_open_kernel();
37356 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37357 + pax_close_kernel();
37358
37359 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37360 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37361 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37362 index ac76b48..2445bc6 100644
37363 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37364 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37365 @@ -18,14 +18,12 @@
37366 #include <asm/head.h>
37367 #include <asm/timer.h>
37368
37369 -static struct cpufreq_driver *cpufreq_us3_driver;
37370 -
37371 struct us3_freq_percpu_info {
37372 struct cpufreq_frequency_table table[4];
37373 };
37374
37375 /* Indexed by cpu number. */
37376 -static struct us3_freq_percpu_info *us3_freq_table;
37377 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37378
37379 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37380 * in the Safari config register.
37381 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37382
37383 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37384 {
37385 - if (cpufreq_us3_driver)
37386 - us3_set_cpu_divider_index(policy, 0);
37387 + us3_set_cpu_divider_index(policy->cpu, 0);
37388
37389 return 0;
37390 }
37391
37392 +static int __init us3_freq_init(void);
37393 +static void __exit us3_freq_exit(void);
37394 +
37395 +static struct cpufreq_driver cpufreq_us3_driver = {
37396 + .init = us3_freq_cpu_init,
37397 + .verify = us3_freq_verify,
37398 + .target = us3_freq_target,
37399 + .get = us3_freq_get,
37400 + .exit = us3_freq_cpu_exit,
37401 + .owner = THIS_MODULE,
37402 + .name = "UltraSPARC-III",
37403 +
37404 +};
37405 +
37406 static int __init us3_freq_init(void)
37407 {
37408 unsigned long manuf, impl, ver;
37409 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
37410 (impl == CHEETAH_IMPL ||
37411 impl == CHEETAH_PLUS_IMPL ||
37412 impl == JAGUAR_IMPL ||
37413 - impl == PANTHER_IMPL)) {
37414 - struct cpufreq_driver *driver;
37415 -
37416 - ret = -ENOMEM;
37417 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
37418 - if (!driver)
37419 - goto err_out;
37420 -
37421 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
37422 - GFP_KERNEL);
37423 - if (!us3_freq_table)
37424 - goto err_out;
37425 -
37426 - driver->init = us3_freq_cpu_init;
37427 - driver->verify = us3_freq_verify;
37428 - driver->target = us3_freq_target;
37429 - driver->get = us3_freq_get;
37430 - driver->exit = us3_freq_cpu_exit;
37431 - strcpy(driver->name, "UltraSPARC-III");
37432 -
37433 - cpufreq_us3_driver = driver;
37434 - ret = cpufreq_register_driver(driver);
37435 - if (ret)
37436 - goto err_out;
37437 -
37438 - return 0;
37439 -
37440 -err_out:
37441 - if (driver) {
37442 - kfree(driver);
37443 - cpufreq_us3_driver = NULL;
37444 - }
37445 - kfree(us3_freq_table);
37446 - us3_freq_table = NULL;
37447 - return ret;
37448 - }
37449 + impl == PANTHER_IMPL))
37450 + return cpufreq_register_driver(&cpufreq_us3_driver);
37451
37452 return -ENODEV;
37453 }
37454
37455 static void __exit us3_freq_exit(void)
37456 {
37457 - if (cpufreq_us3_driver) {
37458 - cpufreq_unregister_driver(cpufreq_us3_driver);
37459 - kfree(cpufreq_us3_driver);
37460 - cpufreq_us3_driver = NULL;
37461 - kfree(us3_freq_table);
37462 - us3_freq_table = NULL;
37463 - }
37464 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37465 }
37466
37467 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37468 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37469 index f897d51..15da295 100644
37470 --- a/drivers/cpufreq/speedstep-centrino.c
37471 +++ b/drivers/cpufreq/speedstep-centrino.c
37472 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37473 !cpu_has(cpu, X86_FEATURE_EST))
37474 return -ENODEV;
37475
37476 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37477 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37478 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37479 + pax_open_kernel();
37480 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37481 + pax_close_kernel();
37482 + }
37483
37484 if (policy->cpu != 0)
37485 return -ENODEV;
37486 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37487 index d75040d..4738ca5 100644
37488 --- a/drivers/cpuidle/cpuidle.c
37489 +++ b/drivers/cpuidle/cpuidle.c
37490 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
37491
37492 static void poll_idle_init(struct cpuidle_driver *drv)
37493 {
37494 - struct cpuidle_state *state = &drv->states[0];
37495 + cpuidle_state_no_const *state = &drv->states[0];
37496
37497 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37498 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37499 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37500 index ea2f8e7..70ac501 100644
37501 --- a/drivers/cpuidle/governor.c
37502 +++ b/drivers/cpuidle/governor.c
37503 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37504 mutex_lock(&cpuidle_lock);
37505 if (__cpuidle_find_governor(gov->name) == NULL) {
37506 ret = 0;
37507 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37508 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37509 if (!cpuidle_curr_governor ||
37510 cpuidle_curr_governor->rating < gov->rating)
37511 cpuidle_switch_governor(gov);
37512 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37513 new_gov = cpuidle_replace_governor(gov->rating);
37514 cpuidle_switch_governor(new_gov);
37515 }
37516 - list_del(&gov->governor_list);
37517 + pax_list_del((struct list_head *)&gov->governor_list);
37518 mutex_unlock(&cpuidle_lock);
37519 }
37520
37521 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37522 index 8739cc0..dc859d0 100644
37523 --- a/drivers/cpuidle/sysfs.c
37524 +++ b/drivers/cpuidle/sysfs.c
37525 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37526 NULL
37527 };
37528
37529 -static struct attribute_group cpuidle_attr_group = {
37530 +static attribute_group_no_const cpuidle_attr_group = {
37531 .attrs = cpuidle_default_attrs,
37532 .name = "cpuidle",
37533 };
37534 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37535 index 12fea3e..1e28f47 100644
37536 --- a/drivers/crypto/hifn_795x.c
37537 +++ b/drivers/crypto/hifn_795x.c
37538 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37539 MODULE_PARM_DESC(hifn_pll_ref,
37540 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37541
37542 -static atomic_t hifn_dev_number;
37543 +static atomic_unchecked_t hifn_dev_number;
37544
37545 #define ACRYPTO_OP_DECRYPT 0
37546 #define ACRYPTO_OP_ENCRYPT 1
37547 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37548 goto err_out_disable_pci_device;
37549
37550 snprintf(name, sizeof(name), "hifn%d",
37551 - atomic_inc_return(&hifn_dev_number)-1);
37552 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37553
37554 err = pci_request_regions(pdev, name);
37555 if (err)
37556 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37557 index c99c00d..990a4b2 100644
37558 --- a/drivers/devfreq/devfreq.c
37559 +++ b/drivers/devfreq/devfreq.c
37560 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37561 goto err_out;
37562 }
37563
37564 - list_add(&governor->node, &devfreq_governor_list);
37565 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37566
37567 list_for_each_entry(devfreq, &devfreq_list, node) {
37568 int ret = 0;
37569 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37570 }
37571 }
37572
37573 - list_del(&governor->node);
37574 + pax_list_del((struct list_head *)&governor->node);
37575 err_out:
37576 mutex_unlock(&devfreq_list_lock);
37577
37578 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
37579 index 1069e88..dfcd642 100644
37580 --- a/drivers/dma/sh/shdmac.c
37581 +++ b/drivers/dma/sh/shdmac.c
37582 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37583 return ret;
37584 }
37585
37586 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37587 +static struct notifier_block sh_dmae_nmi_notifier = {
37588 .notifier_call = sh_dmae_nmi_handler,
37589
37590 /* Run before NMI debug handler and KGDB */
37591 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37592 index 211021d..201d47f 100644
37593 --- a/drivers/edac/edac_device.c
37594 +++ b/drivers/edac/edac_device.c
37595 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37596 */
37597 int edac_device_alloc_index(void)
37598 {
37599 - static atomic_t device_indexes = ATOMIC_INIT(0);
37600 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37601
37602 - return atomic_inc_return(&device_indexes) - 1;
37603 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37604 }
37605 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37606
37607 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37608 index 9f7e0e60..348c875 100644
37609 --- a/drivers/edac/edac_mc_sysfs.c
37610 +++ b/drivers/edac/edac_mc_sysfs.c
37611 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
37612 struct dev_ch_attribute {
37613 struct device_attribute attr;
37614 int channel;
37615 -};
37616 +} __do_const;
37617
37618 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37619 struct dev_ch_attribute dev_attr_legacy_##_name = \
37620 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37621 }
37622
37623 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37624 + pax_open_kernel();
37625 if (mci->get_sdram_scrub_rate) {
37626 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37627 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37628 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37629 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37630 }
37631 if (mci->set_sdram_scrub_rate) {
37632 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37633 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37634 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37635 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37636 }
37637 + pax_close_kernel();
37638 err = device_create_file(&mci->dev,
37639 &dev_attr_sdram_scrub_rate);
37640 if (err) {
37641 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37642 index dd370f9..0281629 100644
37643 --- a/drivers/edac/edac_pci.c
37644 +++ b/drivers/edac/edac_pci.c
37645 @@ -29,7 +29,7 @@
37646
37647 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37648 static LIST_HEAD(edac_pci_list);
37649 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37650 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37651
37652 /*
37653 * edac_pci_alloc_ctl_info
37654 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37655 */
37656 int edac_pci_alloc_index(void)
37657 {
37658 - return atomic_inc_return(&pci_indexes) - 1;
37659 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37660 }
37661 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37662
37663 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37664 index e8658e4..22746d6 100644
37665 --- a/drivers/edac/edac_pci_sysfs.c
37666 +++ b/drivers/edac/edac_pci_sysfs.c
37667 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37668 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37669 static int edac_pci_poll_msec = 1000; /* one second workq period */
37670
37671 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37672 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37673 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37674 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37675
37676 static struct kobject *edac_pci_top_main_kobj;
37677 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37678 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37679 void *value;
37680 ssize_t(*show) (void *, char *);
37681 ssize_t(*store) (void *, const char *, size_t);
37682 -};
37683 +} __do_const;
37684
37685 /* Set of show/store abstract level functions for PCI Parity object */
37686 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37687 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37688 edac_printk(KERN_CRIT, EDAC_PCI,
37689 "Signaled System Error on %s\n",
37690 pci_name(dev));
37691 - atomic_inc(&pci_nonparity_count);
37692 + atomic_inc_unchecked(&pci_nonparity_count);
37693 }
37694
37695 if (status & (PCI_STATUS_PARITY)) {
37696 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37697 "Master Data Parity Error on %s\n",
37698 pci_name(dev));
37699
37700 - atomic_inc(&pci_parity_count);
37701 + atomic_inc_unchecked(&pci_parity_count);
37702 }
37703
37704 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37705 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37706 "Detected Parity Error on %s\n",
37707 pci_name(dev));
37708
37709 - atomic_inc(&pci_parity_count);
37710 + atomic_inc_unchecked(&pci_parity_count);
37711 }
37712 }
37713
37714 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37715 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37716 "Signaled System Error on %s\n",
37717 pci_name(dev));
37718 - atomic_inc(&pci_nonparity_count);
37719 + atomic_inc_unchecked(&pci_nonparity_count);
37720 }
37721
37722 if (status & (PCI_STATUS_PARITY)) {
37723 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37724 "Master Data Parity Error on "
37725 "%s\n", pci_name(dev));
37726
37727 - atomic_inc(&pci_parity_count);
37728 + atomic_inc_unchecked(&pci_parity_count);
37729 }
37730
37731 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37732 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37733 "Detected Parity Error on %s\n",
37734 pci_name(dev));
37735
37736 - atomic_inc(&pci_parity_count);
37737 + atomic_inc_unchecked(&pci_parity_count);
37738 }
37739 }
37740 }
37741 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37742 if (!check_pci_errors)
37743 return;
37744
37745 - before_count = atomic_read(&pci_parity_count);
37746 + before_count = atomic_read_unchecked(&pci_parity_count);
37747
37748 /* scan all PCI devices looking for a Parity Error on devices and
37749 * bridges.
37750 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37751 /* Only if operator has selected panic on PCI Error */
37752 if (edac_pci_get_panic_on_pe()) {
37753 /* If the count is different 'after' from 'before' */
37754 - if (before_count != atomic_read(&pci_parity_count))
37755 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37756 panic("EDAC: PCI Parity Error");
37757 }
37758 }
37759 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37760 index 51b7e3a..aa8a3e8 100644
37761 --- a/drivers/edac/mce_amd.h
37762 +++ b/drivers/edac/mce_amd.h
37763 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37764 bool (*mc0_mce)(u16, u8);
37765 bool (*mc1_mce)(u16, u8);
37766 bool (*mc2_mce)(u16, u8);
37767 -};
37768 +} __no_const;
37769
37770 void amd_report_gart_errors(bool);
37771 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37772 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37773 index 57ea7f4..af06b76 100644
37774 --- a/drivers/firewire/core-card.c
37775 +++ b/drivers/firewire/core-card.c
37776 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37777 const struct fw_card_driver *driver,
37778 struct device *device)
37779 {
37780 - static atomic_t index = ATOMIC_INIT(-1);
37781 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37782
37783 - card->index = atomic_inc_return(&index);
37784 + card->index = atomic_inc_return_unchecked(&index);
37785 card->driver = driver;
37786 card->device = device;
37787 card->current_tlabel = 0;
37788 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37789
37790 void fw_core_remove_card(struct fw_card *card)
37791 {
37792 - struct fw_card_driver dummy_driver = dummy_driver_template;
37793 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37794
37795 card->driver->update_phy_reg(card, 4,
37796 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37797 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37798 index de4aa40..49ab1f2 100644
37799 --- a/drivers/firewire/core-device.c
37800 +++ b/drivers/firewire/core-device.c
37801 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37802 struct config_rom_attribute {
37803 struct device_attribute attr;
37804 u32 key;
37805 -};
37806 +} __do_const;
37807
37808 static ssize_t show_immediate(struct device *dev,
37809 struct device_attribute *dattr, char *buf)
37810 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37811 index e5af0e3..d318058 100644
37812 --- a/drivers/firewire/core-transaction.c
37813 +++ b/drivers/firewire/core-transaction.c
37814 @@ -38,6 +38,7 @@
37815 #include <linux/timer.h>
37816 #include <linux/types.h>
37817 #include <linux/workqueue.h>
37818 +#include <linux/sched.h>
37819
37820 #include <asm/byteorder.h>
37821
37822 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37823 index 515a42c..5ecf3ba 100644
37824 --- a/drivers/firewire/core.h
37825 +++ b/drivers/firewire/core.h
37826 @@ -111,6 +111,7 @@ struct fw_card_driver {
37827
37828 int (*stop_iso)(struct fw_iso_context *ctx);
37829 };
37830 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37831
37832 void fw_card_initialize(struct fw_card *card,
37833 const struct fw_card_driver *driver, struct device *device);
37834 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37835 index 94a58a0..f5eba42 100644
37836 --- a/drivers/firmware/dmi-id.c
37837 +++ b/drivers/firmware/dmi-id.c
37838 @@ -16,7 +16,7 @@
37839 struct dmi_device_attribute{
37840 struct device_attribute dev_attr;
37841 int field;
37842 -};
37843 +} __do_const;
37844 #define to_dmi_dev_attr(_dev_attr) \
37845 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37846
37847 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37848 index fa0affb..aa448eb 100644
37849 --- a/drivers/firmware/dmi_scan.c
37850 +++ b/drivers/firmware/dmi_scan.c
37851 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37852 if (buf == NULL)
37853 return -1;
37854
37855 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37856 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37857
37858 iounmap(buf);
37859 return 0;
37860 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37861 index 5145fa3..0d3babd 100644
37862 --- a/drivers/firmware/efi/efi.c
37863 +++ b/drivers/firmware/efi/efi.c
37864 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37865 };
37866
37867 static struct efivars generic_efivars;
37868 -static struct efivar_operations generic_ops;
37869 +static efivar_operations_no_const generic_ops __read_only;
37870
37871 static int generic_ops_register(void)
37872 {
37873 - generic_ops.get_variable = efi.get_variable;
37874 - generic_ops.set_variable = efi.set_variable;
37875 - generic_ops.get_next_variable = efi.get_next_variable;
37876 - generic_ops.query_variable_store = efi_query_variable_store;
37877 + pax_open_kernel();
37878 + *(void **)&generic_ops.get_variable = efi.get_variable;
37879 + *(void **)&generic_ops.set_variable = efi.set_variable;
37880 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37881 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37882 + pax_close_kernel();
37883
37884 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37885 }
37886 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37887 index 8a7432a..28fb839 100644
37888 --- a/drivers/firmware/efi/efivars.c
37889 +++ b/drivers/firmware/efi/efivars.c
37890 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37891 static int
37892 create_efivars_bin_attributes(void)
37893 {
37894 - struct bin_attribute *attr;
37895 + bin_attribute_no_const *attr;
37896 int error;
37897
37898 /* new_var */
37899 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37900 index 2a90ba6..07f3733 100644
37901 --- a/drivers/firmware/google/memconsole.c
37902 +++ b/drivers/firmware/google/memconsole.c
37903 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37904 if (!found_memconsole())
37905 return -ENODEV;
37906
37907 - memconsole_bin_attr.size = memconsole_length;
37908 + pax_open_kernel();
37909 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37910 + pax_close_kernel();
37911
37912 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37913
37914 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37915 index 814addb..0937d7f 100644
37916 --- a/drivers/gpio/gpio-ich.c
37917 +++ b/drivers/gpio/gpio-ich.c
37918 @@ -71,7 +71,7 @@ struct ichx_desc {
37919 /* Some chipsets have quirks, let these use their own request/get */
37920 int (*request)(struct gpio_chip *chip, unsigned offset);
37921 int (*get)(struct gpio_chip *chip, unsigned offset);
37922 -};
37923 +} __do_const;
37924
37925 static struct {
37926 spinlock_t lock;
37927 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37928 index 9902732..64b62dd 100644
37929 --- a/drivers/gpio/gpio-vr41xx.c
37930 +++ b/drivers/gpio/gpio-vr41xx.c
37931 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37932 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37933 maskl, pendl, maskh, pendh);
37934
37935 - atomic_inc(&irq_err_count);
37936 + atomic_inc_unchecked(&irq_err_count);
37937
37938 return -EINVAL;
37939 }
37940 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37941 index c722c3b..2ec6040 100644
37942 --- a/drivers/gpu/drm/drm_crtc_helper.c
37943 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37944 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37945 struct drm_crtc *tmp;
37946 int crtc_mask = 1;
37947
37948 - WARN(!crtc, "checking null crtc?\n");
37949 + BUG_ON(!crtc);
37950
37951 dev = crtc->dev;
37952
37953 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37954 index fe58d08..07bc38e 100644
37955 --- a/drivers/gpu/drm/drm_drv.c
37956 +++ b/drivers/gpu/drm/drm_drv.c
37957 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
37958 atomic_set(&dev->vma_count, 0);
37959
37960 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37961 - atomic_set(&dev->counts[i], 0);
37962 + atomic_set_unchecked(&dev->counts[i], 0);
37963
37964 dev->sigdata.lock = NULL;
37965
37966 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
37967 /**
37968 * Copy and IOCTL return string to user space
37969 */
37970 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37971 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37972 {
37973 int len;
37974
37975 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
37976 struct drm_file *file_priv = filp->private_data;
37977 struct drm_device *dev;
37978 const struct drm_ioctl_desc *ioctl = NULL;
37979 - drm_ioctl_t *func;
37980 + drm_ioctl_no_const_t func;
37981 unsigned int nr = DRM_IOCTL_NR(cmd);
37982 int retcode = -EINVAL;
37983 char stack_kdata[128];
37984 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
37985 return -ENODEV;
37986
37987 atomic_inc(&dev->ioctl_count);
37988 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37989 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37990 ++file_priv->ioctl_count;
37991
37992 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37993 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37994 index 3f84277..c627c54 100644
37995 --- a/drivers/gpu/drm/drm_fops.c
37996 +++ b/drivers/gpu/drm/drm_fops.c
37997 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
37998 if (drm_device_is_unplugged(dev))
37999 return -ENODEV;
38000
38001 - if (!dev->open_count++)
38002 + if (local_inc_return(&dev->open_count) == 1)
38003 need_setup = 1;
38004 mutex_lock(&dev->struct_mutex);
38005 old_imapping = inode->i_mapping;
38006 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38007 retcode = drm_open_helper(inode, filp, dev);
38008 if (retcode)
38009 goto err_undo;
38010 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38011 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38012 if (need_setup) {
38013 retcode = drm_setup(dev);
38014 if (retcode)
38015 @@ -128,7 +128,7 @@ err_undo:
38016 iput(container_of(dev->dev_mapping, struct inode, i_data));
38017 dev->dev_mapping = old_mapping;
38018 mutex_unlock(&dev->struct_mutex);
38019 - dev->open_count--;
38020 + local_dec(&dev->open_count);
38021 return retcode;
38022 }
38023 EXPORT_SYMBOL(drm_open);
38024 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38025
38026 mutex_lock(&drm_global_mutex);
38027
38028 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38029 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38030
38031 if (dev->driver->preclose)
38032 dev->driver->preclose(dev, file_priv);
38033 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38034 * Begin inline drm_release
38035 */
38036
38037 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38038 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38039 task_pid_nr(current),
38040 (long)old_encode_dev(file_priv->minor->device),
38041 - dev->open_count);
38042 + local_read(&dev->open_count));
38043
38044 /* Release any auth tokens that might point to this file_priv,
38045 (do that under the drm_global_mutex) */
38046 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38047 * End inline drm_release
38048 */
38049
38050 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38051 - if (!--dev->open_count) {
38052 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38053 + if (local_dec_and_test(&dev->open_count)) {
38054 if (atomic_read(&dev->ioctl_count)) {
38055 DRM_ERROR("Device busy: %d\n",
38056 atomic_read(&dev->ioctl_count));
38057 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38058 index f731116..629842c 100644
38059 --- a/drivers/gpu/drm/drm_global.c
38060 +++ b/drivers/gpu/drm/drm_global.c
38061 @@ -36,7 +36,7 @@
38062 struct drm_global_item {
38063 struct mutex mutex;
38064 void *object;
38065 - int refcount;
38066 + atomic_t refcount;
38067 };
38068
38069 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38070 @@ -49,7 +49,7 @@ void drm_global_init(void)
38071 struct drm_global_item *item = &glob[i];
38072 mutex_init(&item->mutex);
38073 item->object = NULL;
38074 - item->refcount = 0;
38075 + atomic_set(&item->refcount, 0);
38076 }
38077 }
38078
38079 @@ -59,7 +59,7 @@ void drm_global_release(void)
38080 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38081 struct drm_global_item *item = &glob[i];
38082 BUG_ON(item->object != NULL);
38083 - BUG_ON(item->refcount != 0);
38084 + BUG_ON(atomic_read(&item->refcount) != 0);
38085 }
38086 }
38087
38088 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38089 void *object;
38090
38091 mutex_lock(&item->mutex);
38092 - if (item->refcount == 0) {
38093 + if (atomic_read(&item->refcount) == 0) {
38094 item->object = kzalloc(ref->size, GFP_KERNEL);
38095 if (unlikely(item->object == NULL)) {
38096 ret = -ENOMEM;
38097 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38098 goto out_err;
38099
38100 }
38101 - ++item->refcount;
38102 + atomic_inc(&item->refcount);
38103 ref->object = item->object;
38104 object = item->object;
38105 mutex_unlock(&item->mutex);
38106 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38107 struct drm_global_item *item = &glob[ref->global_type];
38108
38109 mutex_lock(&item->mutex);
38110 - BUG_ON(item->refcount == 0);
38111 + BUG_ON(atomic_read(&item->refcount) == 0);
38112 BUG_ON(ref->object != item->object);
38113 - if (--item->refcount == 0) {
38114 + if (atomic_dec_and_test(&item->refcount)) {
38115 ref->release(ref);
38116 item->object = NULL;
38117 }
38118 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38119 index 5329832..b503f49 100644
38120 --- a/drivers/gpu/drm/drm_info.c
38121 +++ b/drivers/gpu/drm/drm_info.c
38122 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38123 struct drm_local_map *map;
38124 struct drm_map_list *r_list;
38125
38126 - /* Hardcoded from _DRM_FRAME_BUFFER,
38127 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38128 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38129 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38130 + static const char * const types[] = {
38131 + [_DRM_FRAME_BUFFER] = "FB",
38132 + [_DRM_REGISTERS] = "REG",
38133 + [_DRM_SHM] = "SHM",
38134 + [_DRM_AGP] = "AGP",
38135 + [_DRM_SCATTER_GATHER] = "SG",
38136 + [_DRM_CONSISTENT] = "PCI",
38137 + [_DRM_GEM] = "GEM" };
38138 const char *type;
38139 int i;
38140
38141 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38142 map = r_list->map;
38143 if (!map)
38144 continue;
38145 - if (map->type < 0 || map->type > 5)
38146 + if (map->type >= ARRAY_SIZE(types))
38147 type = "??";
38148 else
38149 type = types[map->type];
38150 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38151 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38152 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38153 vma->vm_flags & VM_IO ? 'i' : '-',
38154 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38155 + 0);
38156 +#else
38157 vma->vm_pgoff);
38158 +#endif
38159
38160 #if defined(__i386__)
38161 pgprot = pgprot_val(vma->vm_page_prot);
38162 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38163 index 2f4c434..dd12cd2 100644
38164 --- a/drivers/gpu/drm/drm_ioc32.c
38165 +++ b/drivers/gpu/drm/drm_ioc32.c
38166 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38167 request = compat_alloc_user_space(nbytes);
38168 if (!access_ok(VERIFY_WRITE, request, nbytes))
38169 return -EFAULT;
38170 - list = (struct drm_buf_desc *) (request + 1);
38171 + list = (struct drm_buf_desc __user *) (request + 1);
38172
38173 if (__put_user(count, &request->count)
38174 || __put_user(list, &request->list))
38175 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38176 request = compat_alloc_user_space(nbytes);
38177 if (!access_ok(VERIFY_WRITE, request, nbytes))
38178 return -EFAULT;
38179 - list = (struct drm_buf_pub *) (request + 1);
38180 + list = (struct drm_buf_pub __user *) (request + 1);
38181
38182 if (__put_user(count, &request->count)
38183 || __put_user(list, &request->list))
38184 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38185 return 0;
38186 }
38187
38188 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38189 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38190 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38191 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38192 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38193 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38194 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 {
38196 unsigned int nr = DRM_IOCTL_NR(cmd);
38197 - drm_ioctl_compat_t *fn;
38198 int ret;
38199
38200 /* Assume that ioctls without an explicit compat routine will just
38201 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38202 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38203 return drm_ioctl(filp, cmd, arg);
38204
38205 - fn = drm_compat_ioctls[nr];
38206 -
38207 - if (fn != NULL)
38208 - ret = (*fn) (filp, cmd, arg);
38209 + if (drm_compat_ioctls[nr] != NULL)
38210 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38211 else
38212 ret = drm_ioctl(filp, cmd, arg);
38213
38214 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38215 index d752c96..fe08455 100644
38216 --- a/drivers/gpu/drm/drm_lock.c
38217 +++ b/drivers/gpu/drm/drm_lock.c
38218 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38219 if (drm_lock_take(&master->lock, lock->context)) {
38220 master->lock.file_priv = file_priv;
38221 master->lock.lock_time = jiffies;
38222 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38223 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38224 break; /* Got lock */
38225 }
38226
38227 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38228 return -EINVAL;
38229 }
38230
38231 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38232 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38233
38234 if (drm_lock_free(&master->lock, lock->context)) {
38235 /* FIXME: Should really bail out here. */
38236 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38237 index 39d8645..59e06fa 100644
38238 --- a/drivers/gpu/drm/drm_stub.c
38239 +++ b/drivers/gpu/drm/drm_stub.c
38240 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38241
38242 drm_device_set_unplugged(dev);
38243
38244 - if (dev->open_count == 0) {
38245 + if (local_read(&dev->open_count) == 0) {
38246 drm_put_dev(dev);
38247 }
38248 mutex_unlock(&drm_global_mutex);
38249 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38250 index 2290b3b..22056a1 100644
38251 --- a/drivers/gpu/drm/drm_sysfs.c
38252 +++ b/drivers/gpu/drm/drm_sysfs.c
38253 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38254 int drm_sysfs_device_add(struct drm_minor *minor)
38255 {
38256 int err;
38257 - char *minor_str;
38258 + const char *minor_str;
38259
38260 minor->kdev.parent = minor->dev->dev;
38261
38262 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38263 index ab1892eb..d7009ca 100644
38264 --- a/drivers/gpu/drm/i810/i810_dma.c
38265 +++ b/drivers/gpu/drm/i810/i810_dma.c
38266 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38267 dma->buflist[vertex->idx],
38268 vertex->discard, vertex->used);
38269
38270 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38271 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38272 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38273 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38274 sarea_priv->last_enqueue = dev_priv->counter - 1;
38275 sarea_priv->last_dispatch = (int)hw_status[5];
38276
38277 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38278 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38279 mc->last_render);
38280
38281 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38282 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38283 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38284 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38285 sarea_priv->last_enqueue = dev_priv->counter - 1;
38286 sarea_priv->last_dispatch = (int)hw_status[5];
38287
38288 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38289 index d4d16ed..8fb0b51 100644
38290 --- a/drivers/gpu/drm/i810/i810_drv.h
38291 +++ b/drivers/gpu/drm/i810/i810_drv.h
38292 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38293 int page_flipping;
38294
38295 wait_queue_head_t irq_queue;
38296 - atomic_t irq_received;
38297 - atomic_t irq_emitted;
38298 + atomic_unchecked_t irq_received;
38299 + atomic_unchecked_t irq_emitted;
38300
38301 int front_offset;
38302 } drm_i810_private_t;
38303 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38304 index a6f4cb5..6b2beb2 100644
38305 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38306 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38307 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38308 I915_READ(GTIMR));
38309 }
38310 seq_printf(m, "Interrupts received: %d\n",
38311 - atomic_read(&dev_priv->irq_received));
38312 + atomic_read_unchecked(&dev_priv->irq_received));
38313 for_each_ring(ring, dev_priv, i) {
38314 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38315 seq_printf(m,
38316 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38317 index d5c784d..06e5c36 100644
38318 --- a/drivers/gpu/drm/i915/i915_dma.c
38319 +++ b/drivers/gpu/drm/i915/i915_dma.c
38320 @@ -1263,7 +1263,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38321 bool can_switch;
38322
38323 spin_lock(&dev->count_lock);
38324 - can_switch = (dev->open_count == 0);
38325 + can_switch = (local_read(&dev->open_count) == 0);
38326 spin_unlock(&dev->count_lock);
38327 return can_switch;
38328 }
38329 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38330 index ab0f2c0..53c1bda 100644
38331 --- a/drivers/gpu/drm/i915/i915_drv.h
38332 +++ b/drivers/gpu/drm/i915/i915_drv.h
38333 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38334 drm_dma_handle_t *status_page_dmah;
38335 struct resource mch_res;
38336
38337 - atomic_t irq_received;
38338 + atomic_unchecked_t irq_received;
38339
38340 /* protects the irq masks */
38341 spinlock_t irq_lock;
38342 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38343 index bf34577..3fd2ffa 100644
38344 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38345 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38346 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38347
38348 static int
38349 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38350 - int count)
38351 + unsigned int count)
38352 {
38353 - int i;
38354 + unsigned int i;
38355 int relocs_total = 0;
38356 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38357
38358 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38359 index 3c59584..500f2e9 100644
38360 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38361 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38362 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38363 (unsigned long)request);
38364 }
38365
38366 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38367 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38368 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38369 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38370 [DRM_I915_GETPARAM] = compat_i915_getparam,
38371 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38372 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38373 {
38374 unsigned int nr = DRM_IOCTL_NR(cmd);
38375 - drm_ioctl_compat_t *fn = NULL;
38376 int ret;
38377
38378 if (nr < DRM_COMMAND_BASE)
38379 return drm_compat_ioctl(filp, cmd, arg);
38380
38381 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38382 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38383 -
38384 - if (fn != NULL)
38385 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38386 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38387 ret = (*fn) (filp, cmd, arg);
38388 - else
38389 + } else
38390 ret = drm_ioctl(filp, cmd, arg);
38391
38392 return ret;
38393 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38394 index 4b91228..590c643 100644
38395 --- a/drivers/gpu/drm/i915/i915_irq.c
38396 +++ b/drivers/gpu/drm/i915/i915_irq.c
38397 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38398 int pipe;
38399 u32 pipe_stats[I915_MAX_PIPES];
38400
38401 - atomic_inc(&dev_priv->irq_received);
38402 + atomic_inc_unchecked(&dev_priv->irq_received);
38403
38404 while (true) {
38405 iir = I915_READ(VLV_IIR);
38406 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38407 irqreturn_t ret = IRQ_NONE;
38408 bool err_int_reenable = false;
38409
38410 - atomic_inc(&dev_priv->irq_received);
38411 + atomic_inc_unchecked(&dev_priv->irq_received);
38412
38413 /* We get interrupts on unclaimed registers, so check for this before we
38414 * do any I915_{READ,WRITE}. */
38415 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38416 {
38417 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38418
38419 - atomic_set(&dev_priv->irq_received, 0);
38420 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38421
38422 I915_WRITE(HWSTAM, 0xeffe);
38423
38424 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38425 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38426 int pipe;
38427
38428 - atomic_set(&dev_priv->irq_received, 0);
38429 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38430
38431 /* VLV magic */
38432 I915_WRITE(VLV_IMR, 0);
38433 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38434 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38435 int pipe;
38436
38437 - atomic_set(&dev_priv->irq_received, 0);
38438 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38439
38440 for_each_pipe(pipe)
38441 I915_WRITE(PIPESTAT(pipe), 0);
38442 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38443 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38444 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38445
38446 - atomic_inc(&dev_priv->irq_received);
38447 + atomic_inc_unchecked(&dev_priv->irq_received);
38448
38449 iir = I915_READ16(IIR);
38450 if (iir == 0)
38451 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38452 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38453 int pipe;
38454
38455 - atomic_set(&dev_priv->irq_received, 0);
38456 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38457
38458 if (I915_HAS_HOTPLUG(dev)) {
38459 I915_WRITE(PORT_HOTPLUG_EN, 0);
38460 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38461 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38462 int pipe, ret = IRQ_NONE;
38463
38464 - atomic_inc(&dev_priv->irq_received);
38465 + atomic_inc_unchecked(&dev_priv->irq_received);
38466
38467 iir = I915_READ(IIR);
38468 do {
38469 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38470 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38471 int pipe;
38472
38473 - atomic_set(&dev_priv->irq_received, 0);
38474 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38475
38476 I915_WRITE(PORT_HOTPLUG_EN, 0);
38477 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38478 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38479 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38480 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38481
38482 - atomic_inc(&dev_priv->irq_received);
38483 + atomic_inc_unchecked(&dev_priv->irq_received);
38484
38485 iir = I915_READ(IIR);
38486
38487 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38488 index d78d33f..01d7c58 100644
38489 --- a/drivers/gpu/drm/i915/intel_display.c
38490 +++ b/drivers/gpu/drm/i915/intel_display.c
38491 @@ -9972,13 +9972,13 @@ struct intel_quirk {
38492 int subsystem_vendor;
38493 int subsystem_device;
38494 void (*hook)(struct drm_device *dev);
38495 -};
38496 +} __do_const;
38497
38498 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38499 struct intel_dmi_quirk {
38500 void (*hook)(struct drm_device *dev);
38501 const struct dmi_system_id (*dmi_id_list)[];
38502 -};
38503 +} __do_const;
38504
38505 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38506 {
38507 @@ -9986,18 +9986,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38508 return 1;
38509 }
38510
38511 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38512 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38513 {
38514 - .dmi_id_list = &(const struct dmi_system_id[]) {
38515 - {
38516 - .callback = intel_dmi_reverse_brightness,
38517 - .ident = "NCR Corporation",
38518 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38519 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38520 - },
38521 - },
38522 - { } /* terminating entry */
38523 + .callback = intel_dmi_reverse_brightness,
38524 + .ident = "NCR Corporation",
38525 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38526 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38527 },
38528 + },
38529 + { } /* terminating entry */
38530 +};
38531 +
38532 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38533 + {
38534 + .dmi_id_list = &intel_dmi_quirks_table,
38535 .hook = quirk_invert_brightness,
38536 },
38537 };
38538 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38539 index ca4bc54..ee598a2 100644
38540 --- a/drivers/gpu/drm/mga/mga_drv.h
38541 +++ b/drivers/gpu/drm/mga/mga_drv.h
38542 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38543 u32 clear_cmd;
38544 u32 maccess;
38545
38546 - atomic_t vbl_received; /**< Number of vblanks received. */
38547 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38548 wait_queue_head_t fence_queue;
38549 - atomic_t last_fence_retired;
38550 + atomic_unchecked_t last_fence_retired;
38551 u32 next_fence_to_post;
38552
38553 unsigned int fb_cpp;
38554 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38555 index 709e90d..89a1c0d 100644
38556 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38557 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38558 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38559 return 0;
38560 }
38561
38562 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38563 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38564 [DRM_MGA_INIT] = compat_mga_init,
38565 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38566 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38567 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38568 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38569 {
38570 unsigned int nr = DRM_IOCTL_NR(cmd);
38571 - drm_ioctl_compat_t *fn = NULL;
38572 int ret;
38573
38574 if (nr < DRM_COMMAND_BASE)
38575 return drm_compat_ioctl(filp, cmd, arg);
38576
38577 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38578 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38579 -
38580 - if (fn != NULL)
38581 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38582 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38583 ret = (*fn) (filp, cmd, arg);
38584 - else
38585 + } else
38586 ret = drm_ioctl(filp, cmd, arg);
38587
38588 return ret;
38589 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38590 index 598c281..60d590e 100644
38591 --- a/drivers/gpu/drm/mga/mga_irq.c
38592 +++ b/drivers/gpu/drm/mga/mga_irq.c
38593 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38594 if (crtc != 0)
38595 return 0;
38596
38597 - return atomic_read(&dev_priv->vbl_received);
38598 + return atomic_read_unchecked(&dev_priv->vbl_received);
38599 }
38600
38601
38602 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38603 /* VBLANK interrupt */
38604 if (status & MGA_VLINEPEN) {
38605 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38606 - atomic_inc(&dev_priv->vbl_received);
38607 + atomic_inc_unchecked(&dev_priv->vbl_received);
38608 drm_handle_vblank(dev, 0);
38609 handled = 1;
38610 }
38611 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38612 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38613 MGA_WRITE(MGA_PRIMEND, prim_end);
38614
38615 - atomic_inc(&dev_priv->last_fence_retired);
38616 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38617 DRM_WAKEUP(&dev_priv->fence_queue);
38618 handled = 1;
38619 }
38620 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38621 * using fences.
38622 */
38623 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38624 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38625 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38626 - *sequence) <= (1 << 23)));
38627
38628 *sequence = cur_fence;
38629 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38630 index 3e72876..d1c15ad 100644
38631 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38632 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38633 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38634 struct bit_table {
38635 const char id;
38636 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38637 -};
38638 +} __no_const;
38639
38640 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38641
38642 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38643 index 994fd6e..6e12565 100644
38644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38645 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38646 @@ -94,7 +94,6 @@ struct nouveau_drm {
38647 struct drm_global_reference mem_global_ref;
38648 struct ttm_bo_global_ref bo_global_ref;
38649 struct ttm_bo_device bdev;
38650 - atomic_t validate_sequence;
38651 int (*move)(struct nouveau_channel *,
38652 struct ttm_buffer_object *,
38653 struct ttm_mem_reg *, struct ttm_mem_reg *);
38654 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38655 index c1a7e5a..38b8539 100644
38656 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38657 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38658 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38659 unsigned long arg)
38660 {
38661 unsigned int nr = DRM_IOCTL_NR(cmd);
38662 - drm_ioctl_compat_t *fn = NULL;
38663 + drm_ioctl_compat_t fn = NULL;
38664 int ret;
38665
38666 if (nr < DRM_COMMAND_BASE)
38667 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38668 index 81638d7..2e45854 100644
38669 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38670 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38671 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38672 bool can_switch;
38673
38674 spin_lock(&dev->count_lock);
38675 - can_switch = (dev->open_count == 0);
38676 + can_switch = (local_read(&dev->open_count) == 0);
38677 spin_unlock(&dev->count_lock);
38678 return can_switch;
38679 }
38680 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
38681 index eb89653..613cf71 100644
38682 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
38683 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
38684 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
38685 int ret;
38686
38687 mutex_lock(&qdev->async_io_mutex);
38688 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38689 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38690 if (qdev->last_sent_io_cmd > irq_num) {
38691 if (intr)
38692 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38693 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38694 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38695 else
38696 ret = wait_event_timeout(qdev->io_cmd_event,
38697 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38698 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38699 /* 0 is timeout, just bail the "hw" has gone away */
38700 if (ret <= 0)
38701 goto out;
38702 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38703 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38704 }
38705 outb(val, addr);
38706 qdev->last_sent_io_cmd = irq_num + 1;
38707 if (intr)
38708 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38709 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38710 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38711 else
38712 ret = wait_event_timeout(qdev->io_cmd_event,
38713 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38714 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38715 out:
38716 if (ret > 0)
38717 ret = 0;
38718 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
38719 index c3c2bbd..bc3c0fb 100644
38720 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
38721 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
38722 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
38723 struct drm_info_node *node = (struct drm_info_node *) m->private;
38724 struct qxl_device *qdev = node->minor->dev->dev_private;
38725
38726 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
38727 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
38728 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
38729 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
38730 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
38731 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
38732 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
38733 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
38734 seq_printf(m, "%d\n", qdev->irq_received_error);
38735 return 0;
38736 }
38737 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
38738 index f7c9add..fb971d2 100644
38739 --- a/drivers/gpu/drm/qxl/qxl_drv.h
38740 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
38741 @@ -290,10 +290,10 @@ struct qxl_device {
38742 unsigned int last_sent_io_cmd;
38743
38744 /* interrupt handling */
38745 - atomic_t irq_received;
38746 - atomic_t irq_received_display;
38747 - atomic_t irq_received_cursor;
38748 - atomic_t irq_received_io_cmd;
38749 + atomic_unchecked_t irq_received;
38750 + atomic_unchecked_t irq_received_display;
38751 + atomic_unchecked_t irq_received_cursor;
38752 + atomic_unchecked_t irq_received_io_cmd;
38753 unsigned irq_received_error;
38754 wait_queue_head_t display_event;
38755 wait_queue_head_t cursor_event;
38756 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
38757 index 21393dc..329f3a9 100644
38758 --- a/drivers/gpu/drm/qxl/qxl_irq.c
38759 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
38760 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
38761
38762 pending = xchg(&qdev->ram_header->int_pending, 0);
38763
38764 - atomic_inc(&qdev->irq_received);
38765 + atomic_inc_unchecked(&qdev->irq_received);
38766
38767 if (pending & QXL_INTERRUPT_DISPLAY) {
38768 - atomic_inc(&qdev->irq_received_display);
38769 + atomic_inc_unchecked(&qdev->irq_received_display);
38770 wake_up_all(&qdev->display_event);
38771 qxl_queue_garbage_collect(qdev, false);
38772 }
38773 if (pending & QXL_INTERRUPT_CURSOR) {
38774 - atomic_inc(&qdev->irq_received_cursor);
38775 + atomic_inc_unchecked(&qdev->irq_received_cursor);
38776 wake_up_all(&qdev->cursor_event);
38777 }
38778 if (pending & QXL_INTERRUPT_IO_CMD) {
38779 - atomic_inc(&qdev->irq_received_io_cmd);
38780 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
38781 wake_up_all(&qdev->io_cmd_event);
38782 }
38783 if (pending & QXL_INTERRUPT_ERROR) {
38784 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
38785 init_waitqueue_head(&qdev->io_cmd_event);
38786 INIT_WORK(&qdev->client_monitors_config_work,
38787 qxl_client_monitors_config_work_func);
38788 - atomic_set(&qdev->irq_received, 0);
38789 - atomic_set(&qdev->irq_received_display, 0);
38790 - atomic_set(&qdev->irq_received_cursor, 0);
38791 - atomic_set(&qdev->irq_received_io_cmd, 0);
38792 + atomic_set_unchecked(&qdev->irq_received, 0);
38793 + atomic_set_unchecked(&qdev->irq_received_display, 0);
38794 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
38795 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
38796 qdev->irq_received_error = 0;
38797 ret = drm_irq_install(qdev->ddev);
38798 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
38799 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38800 index 037786d..2a95e33 100644
38801 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38802 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38803 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38804 }
38805 }
38806
38807 -static struct vm_operations_struct qxl_ttm_vm_ops;
38808 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38809 static const struct vm_operations_struct *ttm_vm_ops;
38810
38811 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38812 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38813 return r;
38814 if (unlikely(ttm_vm_ops == NULL)) {
38815 ttm_vm_ops = vma->vm_ops;
38816 + pax_open_kernel();
38817 qxl_ttm_vm_ops = *ttm_vm_ops;
38818 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38819 + pax_close_kernel();
38820 }
38821 vma->vm_ops = &qxl_ttm_vm_ops;
38822 return 0;
38823 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38824 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38825 {
38826 #if defined(CONFIG_DEBUG_FS)
38827 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38828 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38829 - unsigned i;
38830 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38831 + {
38832 + .name = "qxl_mem_mm",
38833 + .show = &qxl_mm_dump_table,
38834 + },
38835 + {
38836 + .name = "qxl_surf_mm",
38837 + .show = &qxl_mm_dump_table,
38838 + }
38839 + };
38840
38841 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38842 - if (i == 0)
38843 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38844 - else
38845 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38846 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38847 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38848 - qxl_mem_types_list[i].driver_features = 0;
38849 - if (i == 0)
38850 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38851 - else
38852 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38853 + pax_open_kernel();
38854 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38855 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38856 + pax_close_kernel();
38857
38858 - }
38859 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38860 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38861 #else
38862 return 0;
38863 #endif
38864 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38865 index c451257..0ad2134 100644
38866 --- a/drivers/gpu/drm/r128/r128_cce.c
38867 +++ b/drivers/gpu/drm/r128/r128_cce.c
38868 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38869
38870 /* GH: Simple idle check.
38871 */
38872 - atomic_set(&dev_priv->idle_count, 0);
38873 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38874
38875 /* We don't support anything other than bus-mastering ring mode,
38876 * but the ring can be in either AGP or PCI space for the ring
38877 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38878 index 56eb5e3..c4ec43d 100644
38879 --- a/drivers/gpu/drm/r128/r128_drv.h
38880 +++ b/drivers/gpu/drm/r128/r128_drv.h
38881 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38882 int is_pci;
38883 unsigned long cce_buffers_offset;
38884
38885 - atomic_t idle_count;
38886 + atomic_unchecked_t idle_count;
38887
38888 int page_flipping;
38889 int current_page;
38890 u32 crtc_offset;
38891 u32 crtc_offset_cntl;
38892
38893 - atomic_t vbl_received;
38894 + atomic_unchecked_t vbl_received;
38895
38896 u32 color_fmt;
38897 unsigned int front_offset;
38898 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38899 index a954c54..9cc595c 100644
38900 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38901 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38902 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38903 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38904 }
38905
38906 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38907 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38908 [DRM_R128_INIT] = compat_r128_init,
38909 [DRM_R128_DEPTH] = compat_r128_depth,
38910 [DRM_R128_STIPPLE] = compat_r128_stipple,
38911 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38912 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38913 {
38914 unsigned int nr = DRM_IOCTL_NR(cmd);
38915 - drm_ioctl_compat_t *fn = NULL;
38916 int ret;
38917
38918 if (nr < DRM_COMMAND_BASE)
38919 return drm_compat_ioctl(filp, cmd, arg);
38920
38921 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38922 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38923 -
38924 - if (fn != NULL)
38925 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38926 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38927 ret = (*fn) (filp, cmd, arg);
38928 - else
38929 + } else
38930 ret = drm_ioctl(filp, cmd, arg);
38931
38932 return ret;
38933 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38934 index 2ea4f09..d391371 100644
38935 --- a/drivers/gpu/drm/r128/r128_irq.c
38936 +++ b/drivers/gpu/drm/r128/r128_irq.c
38937 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38938 if (crtc != 0)
38939 return 0;
38940
38941 - return atomic_read(&dev_priv->vbl_received);
38942 + return atomic_read_unchecked(&dev_priv->vbl_received);
38943 }
38944
38945 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38946 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38947 /* VBLANK interrupt */
38948 if (status & R128_CRTC_VBLANK_INT) {
38949 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38950 - atomic_inc(&dev_priv->vbl_received);
38951 + atomic_inc_unchecked(&dev_priv->vbl_received);
38952 drm_handle_vblank(dev, 0);
38953 return IRQ_HANDLED;
38954 }
38955 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38956 index 01dd9ae..6352f04 100644
38957 --- a/drivers/gpu/drm/r128/r128_state.c
38958 +++ b/drivers/gpu/drm/r128/r128_state.c
38959 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38960
38961 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38962 {
38963 - if (atomic_read(&dev_priv->idle_count) == 0)
38964 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38965 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38966 else
38967 - atomic_set(&dev_priv->idle_count, 0);
38968 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38969 }
38970
38971 #endif
38972 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38973 index af85299..ed9ac8d 100644
38974 --- a/drivers/gpu/drm/radeon/mkregtable.c
38975 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38976 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38977 regex_t mask_rex;
38978 regmatch_t match[4];
38979 char buf[1024];
38980 - size_t end;
38981 + long end;
38982 int len;
38983 int done = 0;
38984 int r;
38985 unsigned o;
38986 struct offset *offset;
38987 char last_reg_s[10];
38988 - int last_reg;
38989 + unsigned long last_reg;
38990
38991 if (regcomp
38992 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38993 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38994 index 841d0e0..9eaa268 100644
38995 --- a/drivers/gpu/drm/radeon/radeon_device.c
38996 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38997 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38998 bool can_switch;
38999
39000 spin_lock(&dev->count_lock);
39001 - can_switch = (dev->open_count == 0);
39002 + can_switch = (local_read(&dev->open_count) == 0);
39003 spin_unlock(&dev->count_lock);
39004 return can_switch;
39005 }
39006 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39007 index b369d42..8dd04eb 100644
39008 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39009 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39010 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39011
39012 /* SW interrupt */
39013 wait_queue_head_t swi_queue;
39014 - atomic_t swi_emitted;
39015 + atomic_unchecked_t swi_emitted;
39016 int vblank_crtc;
39017 uint32_t irq_enable_reg;
39018 uint32_t r500_disp_irq_reg;
39019 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39020 index c180df8..5fd8186 100644
39021 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39022 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39023 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39024 request = compat_alloc_user_space(sizeof(*request));
39025 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39026 || __put_user(req32.param, &request->param)
39027 - || __put_user((void __user *)(unsigned long)req32.value,
39028 + || __put_user((unsigned long)req32.value,
39029 &request->value))
39030 return -EFAULT;
39031
39032 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39033 #define compat_radeon_cp_setparam NULL
39034 #endif /* X86_64 || IA64 */
39035
39036 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39037 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39038 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39039 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39040 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39041 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39042 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39043 {
39044 unsigned int nr = DRM_IOCTL_NR(cmd);
39045 - drm_ioctl_compat_t *fn = NULL;
39046 int ret;
39047
39048 if (nr < DRM_COMMAND_BASE)
39049 return drm_compat_ioctl(filp, cmd, arg);
39050
39051 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39052 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39053 -
39054 - if (fn != NULL)
39055 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39056 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39057 ret = (*fn) (filp, cmd, arg);
39058 - else
39059 + } else
39060 ret = drm_ioctl(filp, cmd, arg);
39061
39062 return ret;
39063 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39064 index 8d68e97..9dcfed8 100644
39065 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39066 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39067 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39068 unsigned int ret;
39069 RING_LOCALS;
39070
39071 - atomic_inc(&dev_priv->swi_emitted);
39072 - ret = atomic_read(&dev_priv->swi_emitted);
39073 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39074 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39075
39076 BEGIN_RING(4);
39077 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39078 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39079 drm_radeon_private_t *dev_priv =
39080 (drm_radeon_private_t *) dev->dev_private;
39081
39082 - atomic_set(&dev_priv->swi_emitted, 0);
39083 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39084 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39085
39086 dev->max_vblank_count = 0x001fffff;
39087 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39088 index 4d20910..6726b6d 100644
39089 --- a/drivers/gpu/drm/radeon/radeon_state.c
39090 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39091 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39092 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39093 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39094
39095 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39096 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39097 sarea_priv->nbox * sizeof(depth_boxes[0])))
39098 return -EFAULT;
39099
39100 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39101 {
39102 drm_radeon_private_t *dev_priv = dev->dev_private;
39103 drm_radeon_getparam_t *param = data;
39104 - int value;
39105 + int value = 0;
39106
39107 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39108
39109 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39110 index 71245d6..94c556d 100644
39111 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39112 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39113 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39114 man->size = size >> PAGE_SHIFT;
39115 }
39116
39117 -static struct vm_operations_struct radeon_ttm_vm_ops;
39118 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39119 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39120
39121 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39122 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39123 }
39124 if (unlikely(ttm_vm_ops == NULL)) {
39125 ttm_vm_ops = vma->vm_ops;
39126 + pax_open_kernel();
39127 radeon_ttm_vm_ops = *ttm_vm_ops;
39128 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39129 + pax_close_kernel();
39130 }
39131 vma->vm_ops = &radeon_ttm_vm_ops;
39132 return 0;
39133 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39134 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39135 {
39136 #if defined(CONFIG_DEBUG_FS)
39137 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39138 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39139 - unsigned i;
39140 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39141 + {
39142 + .name = "radeon_vram_mm",
39143 + .show = &radeon_mm_dump_table,
39144 + },
39145 + {
39146 + .name = "radeon_gtt_mm",
39147 + .show = &radeon_mm_dump_table,
39148 + },
39149 + {
39150 + .name = "ttm_page_pool",
39151 + .show = &ttm_page_alloc_debugfs,
39152 + },
39153 + {
39154 + .name = "ttm_dma_page_pool",
39155 + .show = &ttm_dma_page_alloc_debugfs,
39156 + },
39157 + };
39158 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39159
39160 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39161 - if (i == 0)
39162 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39163 - else
39164 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39165 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39166 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39167 - radeon_mem_types_list[i].driver_features = 0;
39168 - if (i == 0)
39169 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39170 - else
39171 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39172 -
39173 - }
39174 - /* Add ttm page pool to debugfs */
39175 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39176 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39177 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39178 - radeon_mem_types_list[i].driver_features = 0;
39179 - radeon_mem_types_list[i++].data = NULL;
39180 + pax_open_kernel();
39181 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39182 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39183 + pax_close_kernel();
39184 #ifdef CONFIG_SWIOTLB
39185 - if (swiotlb_nr_tbl()) {
39186 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39187 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39188 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39189 - radeon_mem_types_list[i].driver_features = 0;
39190 - radeon_mem_types_list[i++].data = NULL;
39191 - }
39192 + if (swiotlb_nr_tbl())
39193 + i++;
39194 #endif
39195 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39196
39197 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39198 index 1447d79..40b2a5b 100644
39199 --- a/drivers/gpu/drm/radeon/rs690.c
39200 +++ b/drivers/gpu/drm/radeon/rs690.c
39201 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39202 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39203 rdev->pm.sideport_bandwidth.full)
39204 max_bandwidth = rdev->pm.sideport_bandwidth;
39205 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39206 + read_delay_latency.full = dfixed_const(800 * 1000);
39207 read_delay_latency.full = dfixed_div(read_delay_latency,
39208 rdev->pm.igp_sideport_mclk);
39209 + a.full = dfixed_const(370);
39210 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39211 } else {
39212 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39213 rdev->pm.k8_bandwidth.full)
39214 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39215 index dbc2def..0a9f710 100644
39216 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39217 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39218 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39219 zone->glob = glob;
39220 glob->zone_kernel = zone;
39221 ret = kobject_init_and_add(
39222 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39223 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39224 if (unlikely(ret != 0)) {
39225 kobject_put(&zone->kobj);
39226 return ret;
39227 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39228 zone->glob = glob;
39229 glob->zone_dma32 = zone;
39230 ret = kobject_init_and_add(
39231 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39232 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39233 if (unlikely(ret != 0)) {
39234 kobject_put(&zone->kobj);
39235 return ret;
39236 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39237 index 863bef9..cba15cf 100644
39238 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39239 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39240 @@ -391,9 +391,9 @@ out:
39241 static unsigned long
39242 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39243 {
39244 - static atomic_t start_pool = ATOMIC_INIT(0);
39245 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39246 unsigned i;
39247 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39248 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39249 struct ttm_page_pool *pool;
39250 int shrink_pages = sc->nr_to_scan;
39251 unsigned long freed = 0;
39252 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39253 index 97e9d61..bf23c461 100644
39254 --- a/drivers/gpu/drm/udl/udl_fb.c
39255 +++ b/drivers/gpu/drm/udl/udl_fb.c
39256 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39257 fb_deferred_io_cleanup(info);
39258 kfree(info->fbdefio);
39259 info->fbdefio = NULL;
39260 - info->fbops->fb_mmap = udl_fb_mmap;
39261 }
39262
39263 pr_warn("released /dev/fb%d user=%d count=%d\n",
39264 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39265 index a811ef2..ff99b05 100644
39266 --- a/drivers/gpu/drm/via/via_drv.h
39267 +++ b/drivers/gpu/drm/via/via_drv.h
39268 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39269 typedef uint32_t maskarray_t[5];
39270
39271 typedef struct drm_via_irq {
39272 - atomic_t irq_received;
39273 + atomic_unchecked_t irq_received;
39274 uint32_t pending_mask;
39275 uint32_t enable_mask;
39276 wait_queue_head_t irq_queue;
39277 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39278 struct timeval last_vblank;
39279 int last_vblank_valid;
39280 unsigned usec_per_vblank;
39281 - atomic_t vbl_received;
39282 + atomic_unchecked_t vbl_received;
39283 drm_via_state_t hc_state;
39284 char pci_buf[VIA_PCI_BUF_SIZE];
39285 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39286 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39287 index ac98964..5dbf512 100644
39288 --- a/drivers/gpu/drm/via/via_irq.c
39289 +++ b/drivers/gpu/drm/via/via_irq.c
39290 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39291 if (crtc != 0)
39292 return 0;
39293
39294 - return atomic_read(&dev_priv->vbl_received);
39295 + return atomic_read_unchecked(&dev_priv->vbl_received);
39296 }
39297
39298 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39299 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39300
39301 status = VIA_READ(VIA_REG_INTERRUPT);
39302 if (status & VIA_IRQ_VBLANK_PENDING) {
39303 - atomic_inc(&dev_priv->vbl_received);
39304 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39305 + atomic_inc_unchecked(&dev_priv->vbl_received);
39306 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39307 do_gettimeofday(&cur_vblank);
39308 if (dev_priv->last_vblank_valid) {
39309 dev_priv->usec_per_vblank =
39310 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39311 dev_priv->last_vblank = cur_vblank;
39312 dev_priv->last_vblank_valid = 1;
39313 }
39314 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39315 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39316 DRM_DEBUG("US per vblank is: %u\n",
39317 dev_priv->usec_per_vblank);
39318 }
39319 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39320
39321 for (i = 0; i < dev_priv->num_irqs; ++i) {
39322 if (status & cur_irq->pending_mask) {
39323 - atomic_inc(&cur_irq->irq_received);
39324 + atomic_inc_unchecked(&cur_irq->irq_received);
39325 DRM_WAKEUP(&cur_irq->irq_queue);
39326 handled = 1;
39327 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39328 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39329 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39330 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39331 masks[irq][4]));
39332 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39333 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39334 } else {
39335 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39336 (((cur_irq_sequence =
39337 - atomic_read(&cur_irq->irq_received)) -
39338 + atomic_read_unchecked(&cur_irq->irq_received)) -
39339 *sequence) <= (1 << 23)));
39340 }
39341 *sequence = cur_irq_sequence;
39342 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39343 }
39344
39345 for (i = 0; i < dev_priv->num_irqs; ++i) {
39346 - atomic_set(&cur_irq->irq_received, 0);
39347 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39348 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39349 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39350 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39351 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39352 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39353 case VIA_IRQ_RELATIVE:
39354 irqwait->request.sequence +=
39355 - atomic_read(&cur_irq->irq_received);
39356 + atomic_read_unchecked(&cur_irq->irq_received);
39357 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39358 case VIA_IRQ_ABSOLUTE:
39359 break;
39360 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39361 index 150ec64..f5165f2 100644
39362 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39363 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39364 @@ -290,7 +290,7 @@ struct vmw_private {
39365 * Fencing and IRQs.
39366 */
39367
39368 - atomic_t marker_seq;
39369 + atomic_unchecked_t marker_seq;
39370 wait_queue_head_t fence_queue;
39371 wait_queue_head_t fifo_queue;
39372 int fence_queue_waiters; /* Protected by hw_mutex */
39373 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39374 index 3eb1486..0a47ee9 100644
39375 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39376 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39377 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39378 (unsigned int) min,
39379 (unsigned int) fifo->capabilities);
39380
39381 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39382 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39383 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39384 vmw_marker_queue_init(&fifo->marker_queue);
39385 return vmw_fifo_send_fence(dev_priv, &dummy);
39386 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39387 if (reserveable)
39388 iowrite32(bytes, fifo_mem +
39389 SVGA_FIFO_RESERVED);
39390 - return fifo_mem + (next_cmd >> 2);
39391 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39392 } else {
39393 need_bounce = true;
39394 }
39395 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39396
39397 fm = vmw_fifo_reserve(dev_priv, bytes);
39398 if (unlikely(fm == NULL)) {
39399 - *seqno = atomic_read(&dev_priv->marker_seq);
39400 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39401 ret = -ENOMEM;
39402 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39403 false, 3*HZ);
39404 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39405 }
39406
39407 do {
39408 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39409 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39410 } while (*seqno == 0);
39411
39412 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39413 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39414 index c509d40..3b640c3 100644
39415 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39416 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39417 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39418 int ret;
39419
39420 num_clips = arg->num_clips;
39421 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39422 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39423
39424 if (unlikely(num_clips == 0))
39425 return 0;
39426 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39427 int ret;
39428
39429 num_clips = arg->num_clips;
39430 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39431 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39432
39433 if (unlikely(num_clips == 0))
39434 return 0;
39435 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39436 index 4640adb..e1384ed 100644
39437 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39438 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39439 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39440 * emitted. Then the fence is stale and signaled.
39441 */
39442
39443 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39444 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39445 > VMW_FENCE_WRAP);
39446
39447 return ret;
39448 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39449
39450 if (fifo_idle)
39451 down_read(&fifo_state->rwsem);
39452 - signal_seq = atomic_read(&dev_priv->marker_seq);
39453 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39454 ret = 0;
39455
39456 for (;;) {
39457 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39458 index 8a8725c2..afed796 100644
39459 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39460 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39461 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39462 while (!vmw_lag_lt(queue, us)) {
39463 spin_lock(&queue->lock);
39464 if (list_empty(&queue->head))
39465 - seqno = atomic_read(&dev_priv->marker_seq);
39466 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39467 else {
39468 marker = list_first_entry(&queue->head,
39469 struct vmw_marker, head);
39470 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39471 index b1a05ad..1c9d899 100644
39472 --- a/drivers/gpu/host1x/drm/dc.c
39473 +++ b/drivers/gpu/host1x/drm/dc.c
39474 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39475 }
39476
39477 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39478 - dc->debugfs_files[i].data = dc;
39479 + *(void **)&dc->debugfs_files[i].data = dc;
39480
39481 err = drm_debugfs_create_files(dc->debugfs_files,
39482 ARRAY_SIZE(debugfs_files),
39483 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
39484 index ec0ae2d..dc0780b 100644
39485 --- a/drivers/gpu/vga/vga_switcheroo.c
39486 +++ b/drivers/gpu/vga/vga_switcheroo.c
39487 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
39488
39489 /* this version is for the case where the power switch is separate
39490 to the device being powered down. */
39491 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
39492 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
39493 {
39494 /* copy over all the bus versions */
39495 if (dev->bus && dev->bus->pm) {
39496 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
39497 return ret;
39498 }
39499
39500 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
39501 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
39502 {
39503 /* copy over all the bus versions */
39504 if (dev->bus && dev->bus->pm) {
39505 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39506 index e80da62..bbcba01 100644
39507 --- a/drivers/hid/hid-core.c
39508 +++ b/drivers/hid/hid-core.c
39509 @@ -2417,7 +2417,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39510
39511 int hid_add_device(struct hid_device *hdev)
39512 {
39513 - static atomic_t id = ATOMIC_INIT(0);
39514 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39515 int ret;
39516
39517 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39518 @@ -2451,7 +2451,7 @@ int hid_add_device(struct hid_device *hdev)
39519 /* XXX hack, any other cleaner solution after the driver core
39520 * is converted to allow more than 20 bytes as the device name? */
39521 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39522 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39523 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39524
39525 hid_debug_register(hdev, dev_name(&hdev->dev));
39526 ret = device_add(&hdev->dev);
39527 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39528 index c13fb5b..55a3802 100644
39529 --- a/drivers/hid/hid-wiimote-debug.c
39530 +++ b/drivers/hid/hid-wiimote-debug.c
39531 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39532 else if (size == 0)
39533 return -EIO;
39534
39535 - if (copy_to_user(u, buf, size))
39536 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39537 return -EFAULT;
39538
39539 *off += size;
39540 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39541 index 93b00d7..0a71596 100644
39542 --- a/drivers/hid/uhid.c
39543 +++ b/drivers/hid/uhid.c
39544 @@ -47,7 +47,7 @@ struct uhid_device {
39545 struct mutex report_lock;
39546 wait_queue_head_t report_wait;
39547 atomic_t report_done;
39548 - atomic_t report_id;
39549 + atomic_unchecked_t report_id;
39550 struct uhid_event report_buf;
39551 };
39552
39553 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39554
39555 spin_lock_irqsave(&uhid->qlock, flags);
39556 ev->type = UHID_FEATURE;
39557 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39558 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39559 ev->u.feature.rnum = rnum;
39560 ev->u.feature.rtype = report_type;
39561
39562 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39563 spin_lock_irqsave(&uhid->qlock, flags);
39564
39565 /* id for old report; drop it silently */
39566 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39567 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39568 goto unlock;
39569 if (atomic_read(&uhid->report_done))
39570 goto unlock;
39571 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39572 index 6de6c98..18319e9 100644
39573 --- a/drivers/hv/channel.c
39574 +++ b/drivers/hv/channel.c
39575 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39576 int ret = 0;
39577 int t;
39578
39579 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39580 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39581 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39582 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39583
39584 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39585 if (ret)
39586 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39587 index 88f4096..e50452e 100644
39588 --- a/drivers/hv/hv.c
39589 +++ b/drivers/hv/hv.c
39590 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39591 u64 output_address = (output) ? virt_to_phys(output) : 0;
39592 u32 output_address_hi = output_address >> 32;
39593 u32 output_address_lo = output_address & 0xFFFFFFFF;
39594 - void *hypercall_page = hv_context.hypercall_page;
39595 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39596
39597 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39598 "=a"(hv_status_lo) : "d" (control_hi),
39599 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39600 index 7e17a54..a50a33d 100644
39601 --- a/drivers/hv/hv_balloon.c
39602 +++ b/drivers/hv/hv_balloon.c
39603 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39604
39605 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39606 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39607 -static atomic_t trans_id = ATOMIC_INIT(0);
39608 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39609
39610 static int dm_ring_size = (5 * PAGE_SIZE);
39611
39612 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
39613 pr_info("Memory hot add failed\n");
39614
39615 dm->state = DM_INITIALIZED;
39616 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39617 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39618 vmbus_sendpacket(dm->dev->channel, &resp,
39619 sizeof(struct dm_hot_add_response),
39620 (unsigned long)NULL,
39621 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39622 memset(&status, 0, sizeof(struct dm_status));
39623 status.hdr.type = DM_STATUS_REPORT;
39624 status.hdr.size = sizeof(struct dm_status);
39625 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39626 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39627
39628 /*
39629 * The host expects the guest to report free memory.
39630 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39631 * send the status. This can happen if we were interrupted
39632 * after we picked our transaction ID.
39633 */
39634 - if (status.hdr.trans_id != atomic_read(&trans_id))
39635 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39636 return;
39637
39638 vmbus_sendpacket(dm->dev->channel, &status,
39639 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
39640 */
39641
39642 do {
39643 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39644 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39645 ret = vmbus_sendpacket(dm_device.dev->channel,
39646 bl_resp,
39647 bl_resp->hdr.size,
39648 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39649
39650 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39651 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39652 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39653 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39654 resp.hdr.size = sizeof(struct dm_unballoon_response);
39655
39656 vmbus_sendpacket(dm_device.dev->channel, &resp,
39657 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39658 memset(&version_req, 0, sizeof(struct dm_version_request));
39659 version_req.hdr.type = DM_VERSION_REQUEST;
39660 version_req.hdr.size = sizeof(struct dm_version_request);
39661 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39662 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39663 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39664 version_req.is_last_attempt = 1;
39665
39666 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39667 memset(&version_req, 0, sizeof(struct dm_version_request));
39668 version_req.hdr.type = DM_VERSION_REQUEST;
39669 version_req.hdr.size = sizeof(struct dm_version_request);
39670 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39671 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39672 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39673 version_req.is_last_attempt = 0;
39674
39675 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39676 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39677 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39678 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39679 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39680 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39681
39682 cap_msg.caps.cap_bits.balloon = 1;
39683 cap_msg.caps.cap_bits.hot_add = 1;
39684 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39685 index d84918f..7f38f9f 100644
39686 --- a/drivers/hv/hyperv_vmbus.h
39687 +++ b/drivers/hv/hyperv_vmbus.h
39688 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39689 struct vmbus_connection {
39690 enum vmbus_connect_state conn_state;
39691
39692 - atomic_t next_gpadl_handle;
39693 + atomic_unchecked_t next_gpadl_handle;
39694
39695 /*
39696 * Represents channel interrupts. Each bit position represents a
39697 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39698 index f9fe46f..356b119 100644
39699 --- a/drivers/hv/vmbus_drv.c
39700 +++ b/drivers/hv/vmbus_drv.c
39701 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39702 {
39703 int ret = 0;
39704
39705 - static atomic_t device_num = ATOMIC_INIT(0);
39706 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39707
39708 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39709 - atomic_inc_return(&device_num));
39710 + atomic_inc_return_unchecked(&device_num));
39711
39712 child_device_obj->device.bus = &hv_bus;
39713 child_device_obj->device.parent = &hv_acpi_dev->dev;
39714 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39715 index a9e3d01..9dd246e 100644
39716 --- a/drivers/hwmon/acpi_power_meter.c
39717 +++ b/drivers/hwmon/acpi_power_meter.c
39718 @@ -117,7 +117,7 @@ struct sensor_template {
39719 struct device_attribute *devattr,
39720 const char *buf, size_t count);
39721 int index;
39722 -};
39723 +} __do_const;
39724
39725 /* Averaging interval */
39726 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39727 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39728 struct sensor_template *attrs)
39729 {
39730 struct device *dev = &resource->acpi_dev->dev;
39731 - struct sensor_device_attribute *sensors =
39732 + sensor_device_attribute_no_const *sensors =
39733 &resource->sensors[resource->num_sensors];
39734 int res = 0;
39735
39736 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39737 index 3288f13..71cfb4e 100644
39738 --- a/drivers/hwmon/applesmc.c
39739 +++ b/drivers/hwmon/applesmc.c
39740 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39741 {
39742 struct applesmc_node_group *grp;
39743 struct applesmc_dev_attr *node;
39744 - struct attribute *attr;
39745 + attribute_no_const *attr;
39746 int ret, i;
39747
39748 for (grp = groups; grp->format; grp++) {
39749 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39750 index b25c643..a13460d 100644
39751 --- a/drivers/hwmon/asus_atk0110.c
39752 +++ b/drivers/hwmon/asus_atk0110.c
39753 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39754 struct atk_sensor_data {
39755 struct list_head list;
39756 struct atk_data *data;
39757 - struct device_attribute label_attr;
39758 - struct device_attribute input_attr;
39759 - struct device_attribute limit1_attr;
39760 - struct device_attribute limit2_attr;
39761 + device_attribute_no_const label_attr;
39762 + device_attribute_no_const input_attr;
39763 + device_attribute_no_const limit1_attr;
39764 + device_attribute_no_const limit2_attr;
39765 char label_attr_name[ATTR_NAME_SIZE];
39766 char input_attr_name[ATTR_NAME_SIZE];
39767 char limit1_attr_name[ATTR_NAME_SIZE];
39768 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39769 static struct device_attribute atk_name_attr =
39770 __ATTR(name, 0444, atk_name_show, NULL);
39771
39772 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39773 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39774 sysfs_show_func show)
39775 {
39776 sysfs_attr_init(&attr->attr);
39777 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39778 index 78be661..4dd032f 100644
39779 --- a/drivers/hwmon/coretemp.c
39780 +++ b/drivers/hwmon/coretemp.c
39781 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39782 return NOTIFY_OK;
39783 }
39784
39785 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39786 +static struct notifier_block coretemp_cpu_notifier = {
39787 .notifier_call = coretemp_cpu_callback,
39788 };
39789
39790 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39791 index 632f1dc..57e6a58 100644
39792 --- a/drivers/hwmon/ibmaem.c
39793 +++ b/drivers/hwmon/ibmaem.c
39794 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39795 struct aem_rw_sensor_template *rw)
39796 {
39797 struct device *dev = &data->pdev->dev;
39798 - struct sensor_device_attribute *sensors = data->sensors;
39799 + sensor_device_attribute_no_const *sensors = data->sensors;
39800 int err;
39801
39802 /* Set up read-only sensors */
39803 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39804 index 708081b..fe2d4ab 100644
39805 --- a/drivers/hwmon/iio_hwmon.c
39806 +++ b/drivers/hwmon/iio_hwmon.c
39807 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39808 {
39809 struct device *dev = &pdev->dev;
39810 struct iio_hwmon_state *st;
39811 - struct sensor_device_attribute *a;
39812 + sensor_device_attribute_no_const *a;
39813 int ret, i;
39814 int in_i = 1, temp_i = 1, curr_i = 1;
39815 enum iio_chan_type type;
39816 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
39817 index 6eb03ce..bea7e3e 100644
39818 --- a/drivers/hwmon/nct6775.c
39819 +++ b/drivers/hwmon/nct6775.c
39820 @@ -936,10 +936,10 @@ static struct attribute_group *
39821 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
39822 int repeat)
39823 {
39824 - struct attribute_group *group;
39825 + attribute_group_no_const *group;
39826 struct sensor_device_attr_u *su;
39827 - struct sensor_device_attribute *a;
39828 - struct sensor_device_attribute_2 *a2;
39829 + sensor_device_attribute_no_const *a;
39830 + sensor_device_attribute_2_no_const *a2;
39831 struct attribute **attrs;
39832 struct sensor_device_template **t;
39833 int err, i, j, count;
39834 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39835 index 9319fcf..189ff45 100644
39836 --- a/drivers/hwmon/pmbus/pmbus_core.c
39837 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39838 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39839 return 0;
39840 }
39841
39842 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39843 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39844 const char *name,
39845 umode_t mode,
39846 ssize_t (*show)(struct device *dev,
39847 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39848 dev_attr->store = store;
39849 }
39850
39851 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39852 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39853 const char *name,
39854 umode_t mode,
39855 ssize_t (*show)(struct device *dev,
39856 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39857 u16 reg, u8 mask)
39858 {
39859 struct pmbus_boolean *boolean;
39860 - struct sensor_device_attribute *a;
39861 + sensor_device_attribute_no_const *a;
39862
39863 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39864 if (!boolean)
39865 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39866 bool update, bool readonly)
39867 {
39868 struct pmbus_sensor *sensor;
39869 - struct device_attribute *a;
39870 + device_attribute_no_const *a;
39871
39872 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39873 if (!sensor)
39874 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39875 const char *lstring, int index)
39876 {
39877 struct pmbus_label *label;
39878 - struct device_attribute *a;
39879 + device_attribute_no_const *a;
39880
39881 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39882 if (!label)
39883 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39884 index 97cd45a..ac54d8b 100644
39885 --- a/drivers/hwmon/sht15.c
39886 +++ b/drivers/hwmon/sht15.c
39887 @@ -169,7 +169,7 @@ struct sht15_data {
39888 int supply_uv;
39889 bool supply_uv_valid;
39890 struct work_struct update_supply_work;
39891 - atomic_t interrupt_handled;
39892 + atomic_unchecked_t interrupt_handled;
39893 };
39894
39895 /**
39896 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39897 ret = gpio_direction_input(data->pdata->gpio_data);
39898 if (ret)
39899 return ret;
39900 - atomic_set(&data->interrupt_handled, 0);
39901 + atomic_set_unchecked(&data->interrupt_handled, 0);
39902
39903 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39904 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39905 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39906 /* Only relevant if the interrupt hasn't occurred. */
39907 - if (!atomic_read(&data->interrupt_handled))
39908 + if (!atomic_read_unchecked(&data->interrupt_handled))
39909 schedule_work(&data->read_work);
39910 }
39911 ret = wait_event_timeout(data->wait_queue,
39912 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39913
39914 /* First disable the interrupt */
39915 disable_irq_nosync(irq);
39916 - atomic_inc(&data->interrupt_handled);
39917 + atomic_inc_unchecked(&data->interrupt_handled);
39918 /* Then schedule a reading work struct */
39919 if (data->state != SHT15_READING_NOTHING)
39920 schedule_work(&data->read_work);
39921 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39922 * If not, then start the interrupt again - care here as could
39923 * have gone low in meantime so verify it hasn't!
39924 */
39925 - atomic_set(&data->interrupt_handled, 0);
39926 + atomic_set_unchecked(&data->interrupt_handled, 0);
39927 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39928 /* If still not occurred or another handler was scheduled */
39929 if (gpio_get_value(data->pdata->gpio_data)
39930 - || atomic_read(&data->interrupt_handled))
39931 + || atomic_read_unchecked(&data->interrupt_handled))
39932 return;
39933 }
39934
39935 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39936 index 38944e9..ae9e5ed 100644
39937 --- a/drivers/hwmon/via-cputemp.c
39938 +++ b/drivers/hwmon/via-cputemp.c
39939 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39940 return NOTIFY_OK;
39941 }
39942
39943 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39944 +static struct notifier_block via_cputemp_cpu_notifier = {
39945 .notifier_call = via_cputemp_cpu_callback,
39946 };
39947
39948 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39949 index 07f01ac..d79ad3d 100644
39950 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39951 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39952 @@ -43,7 +43,7 @@
39953 extern struct i2c_adapter amd756_smbus;
39954
39955 static struct i2c_adapter *s4882_adapter;
39956 -static struct i2c_algorithm *s4882_algo;
39957 +static i2c_algorithm_no_const *s4882_algo;
39958
39959 /* Wrapper access functions for multiplexed SMBus */
39960 static DEFINE_MUTEX(amd756_lock);
39961 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
39962 index dae3ddf..26e21d1 100644
39963 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
39964 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
39965 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
39966 /* usb layer */
39967
39968 /* Send command to device, and get response. */
39969 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
39970 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
39971 {
39972 int ret = 0;
39973 int actual;
39974 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39975 index 2ca268d..c6acbdf 100644
39976 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39977 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39978 @@ -41,7 +41,7 @@
39979 extern struct i2c_adapter *nforce2_smbus;
39980
39981 static struct i2c_adapter *s4985_adapter;
39982 -static struct i2c_algorithm *s4985_algo;
39983 +static i2c_algorithm_no_const *s4985_algo;
39984
39985 /* Wrapper access functions for multiplexed SMBus */
39986 static DEFINE_MUTEX(nforce2_lock);
39987 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39988 index c3ccdea..5b3dc1a 100644
39989 --- a/drivers/i2c/i2c-dev.c
39990 +++ b/drivers/i2c/i2c-dev.c
39991 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39992 break;
39993 }
39994
39995 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39996 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39997 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39998 if (IS_ERR(rdwr_pa[i].buf)) {
39999 res = PTR_ERR(rdwr_pa[i].buf);
40000 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40001 index 0b510ba..4fbb5085 100644
40002 --- a/drivers/ide/ide-cd.c
40003 +++ b/drivers/ide/ide-cd.c
40004 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40005 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40006 if ((unsigned long)buf & alignment
40007 || blk_rq_bytes(rq) & q->dma_pad_mask
40008 - || object_is_on_stack(buf))
40009 + || object_starts_on_stack(buf))
40010 drive->dma = 0;
40011 }
40012 }
40013 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40014 index f95c697..0a1b05c 100644
40015 --- a/drivers/iio/industrialio-core.c
40016 +++ b/drivers/iio/industrialio-core.c
40017 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40018 }
40019
40020 static
40021 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40022 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40023 const char *postfix,
40024 struct iio_chan_spec const *chan,
40025 ssize_t (*readfunc)(struct device *dev,
40026 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40027 index 784b97c..c9ceadf 100644
40028 --- a/drivers/infiniband/core/cm.c
40029 +++ b/drivers/infiniband/core/cm.c
40030 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40031
40032 struct cm_counter_group {
40033 struct kobject obj;
40034 - atomic_long_t counter[CM_ATTR_COUNT];
40035 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40036 };
40037
40038 struct cm_counter_attribute {
40039 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40040 struct ib_mad_send_buf *msg = NULL;
40041 int ret;
40042
40043 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40044 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40045 counter[CM_REQ_COUNTER]);
40046
40047 /* Quick state check to discard duplicate REQs. */
40048 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40049 if (!cm_id_priv)
40050 return;
40051
40052 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40053 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40054 counter[CM_REP_COUNTER]);
40055 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40056 if (ret)
40057 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40058 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40059 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40060 spin_unlock_irq(&cm_id_priv->lock);
40061 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40062 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40063 counter[CM_RTU_COUNTER]);
40064 goto out;
40065 }
40066 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40067 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40068 dreq_msg->local_comm_id);
40069 if (!cm_id_priv) {
40070 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40071 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40072 counter[CM_DREQ_COUNTER]);
40073 cm_issue_drep(work->port, work->mad_recv_wc);
40074 return -EINVAL;
40075 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40076 case IB_CM_MRA_REP_RCVD:
40077 break;
40078 case IB_CM_TIMEWAIT:
40079 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40080 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40081 counter[CM_DREQ_COUNTER]);
40082 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40083 goto unlock;
40084 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40085 cm_free_msg(msg);
40086 goto deref;
40087 case IB_CM_DREQ_RCVD:
40088 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40089 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40090 counter[CM_DREQ_COUNTER]);
40091 goto unlock;
40092 default:
40093 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40094 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40095 cm_id_priv->msg, timeout)) {
40096 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40097 - atomic_long_inc(&work->port->
40098 + atomic_long_inc_unchecked(&work->port->
40099 counter_group[CM_RECV_DUPLICATES].
40100 counter[CM_MRA_COUNTER]);
40101 goto out;
40102 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40103 break;
40104 case IB_CM_MRA_REQ_RCVD:
40105 case IB_CM_MRA_REP_RCVD:
40106 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40107 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40108 counter[CM_MRA_COUNTER]);
40109 /* fall through */
40110 default:
40111 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40112 case IB_CM_LAP_IDLE:
40113 break;
40114 case IB_CM_MRA_LAP_SENT:
40115 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40116 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40117 counter[CM_LAP_COUNTER]);
40118 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40119 goto unlock;
40120 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40121 cm_free_msg(msg);
40122 goto deref;
40123 case IB_CM_LAP_RCVD:
40124 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40125 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40126 counter[CM_LAP_COUNTER]);
40127 goto unlock;
40128 default:
40129 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40130 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40131 if (cur_cm_id_priv) {
40132 spin_unlock_irq(&cm.lock);
40133 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40134 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40135 counter[CM_SIDR_REQ_COUNTER]);
40136 goto out; /* Duplicate message. */
40137 }
40138 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40139 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40140 msg->retries = 1;
40141
40142 - atomic_long_add(1 + msg->retries,
40143 + atomic_long_add_unchecked(1 + msg->retries,
40144 &port->counter_group[CM_XMIT].counter[attr_index]);
40145 if (msg->retries)
40146 - atomic_long_add(msg->retries,
40147 + atomic_long_add_unchecked(msg->retries,
40148 &port->counter_group[CM_XMIT_RETRIES].
40149 counter[attr_index]);
40150
40151 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40152 }
40153
40154 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40155 - atomic_long_inc(&port->counter_group[CM_RECV].
40156 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40157 counter[attr_id - CM_ATTR_ID_OFFSET]);
40158
40159 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40160 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40161 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40162
40163 return sprintf(buf, "%ld\n",
40164 - atomic_long_read(&group->counter[cm_attr->index]));
40165 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40166 }
40167
40168 static const struct sysfs_ops cm_counter_ops = {
40169 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40170 index 9f5ad7c..588cd84 100644
40171 --- a/drivers/infiniband/core/fmr_pool.c
40172 +++ b/drivers/infiniband/core/fmr_pool.c
40173 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40174
40175 struct task_struct *thread;
40176
40177 - atomic_t req_ser;
40178 - atomic_t flush_ser;
40179 + atomic_unchecked_t req_ser;
40180 + atomic_unchecked_t flush_ser;
40181
40182 wait_queue_head_t force_wait;
40183 };
40184 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40185 struct ib_fmr_pool *pool = pool_ptr;
40186
40187 do {
40188 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40189 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40190 ib_fmr_batch_release(pool);
40191
40192 - atomic_inc(&pool->flush_ser);
40193 + atomic_inc_unchecked(&pool->flush_ser);
40194 wake_up_interruptible(&pool->force_wait);
40195
40196 if (pool->flush_function)
40197 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40198 }
40199
40200 set_current_state(TASK_INTERRUPTIBLE);
40201 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40202 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40203 !kthread_should_stop())
40204 schedule();
40205 __set_current_state(TASK_RUNNING);
40206 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40207 pool->dirty_watermark = params->dirty_watermark;
40208 pool->dirty_len = 0;
40209 spin_lock_init(&pool->pool_lock);
40210 - atomic_set(&pool->req_ser, 0);
40211 - atomic_set(&pool->flush_ser, 0);
40212 + atomic_set_unchecked(&pool->req_ser, 0);
40213 + atomic_set_unchecked(&pool->flush_ser, 0);
40214 init_waitqueue_head(&pool->force_wait);
40215
40216 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40217 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40218 }
40219 spin_unlock_irq(&pool->pool_lock);
40220
40221 - serial = atomic_inc_return(&pool->req_ser);
40222 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40223 wake_up_process(pool->thread);
40224
40225 if (wait_event_interruptible(pool->force_wait,
40226 - atomic_read(&pool->flush_ser) - serial >= 0))
40227 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40228 return -EINTR;
40229
40230 return 0;
40231 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40232 } else {
40233 list_add_tail(&fmr->list, &pool->dirty_list);
40234 if (++pool->dirty_len >= pool->dirty_watermark) {
40235 - atomic_inc(&pool->req_ser);
40236 + atomic_inc_unchecked(&pool->req_ser);
40237 wake_up_process(pool->thread);
40238 }
40239 }
40240 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40241 index 4cb8eb2..146bf60 100644
40242 --- a/drivers/infiniband/hw/cxgb4/mem.c
40243 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40244 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40245 int err;
40246 struct fw_ri_tpte tpt;
40247 u32 stag_idx;
40248 - static atomic_t key;
40249 + static atomic_unchecked_t key;
40250
40251 if (c4iw_fatal_error(rdev))
40252 return -EIO;
40253 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40254 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40255 rdev->stats.stag.max = rdev->stats.stag.cur;
40256 mutex_unlock(&rdev->stats.lock);
40257 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40258 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40259 }
40260 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40261 __func__, stag_state, type, pdid, stag_idx);
40262 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40263 index 79b3dbc..96e5fcc 100644
40264 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40265 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40266 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40267 struct ib_atomic_eth *ateth;
40268 struct ipath_ack_entry *e;
40269 u64 vaddr;
40270 - atomic64_t *maddr;
40271 + atomic64_unchecked_t *maddr;
40272 u64 sdata;
40273 u32 rkey;
40274 u8 next;
40275 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40276 IB_ACCESS_REMOTE_ATOMIC)))
40277 goto nack_acc_unlck;
40278 /* Perform atomic OP and save result. */
40279 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40280 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40281 sdata = be64_to_cpu(ateth->swap_data);
40282 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40283 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40284 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40285 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40286 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40287 be64_to_cpu(ateth->compare_data),
40288 sdata);
40289 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40290 index 1f95bba..9530f87 100644
40291 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40292 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40293 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40294 unsigned long flags;
40295 struct ib_wc wc;
40296 u64 sdata;
40297 - atomic64_t *maddr;
40298 + atomic64_unchecked_t *maddr;
40299 enum ib_wc_status send_status;
40300
40301 /*
40302 @@ -382,11 +382,11 @@ again:
40303 IB_ACCESS_REMOTE_ATOMIC)))
40304 goto acc_err;
40305 /* Perform atomic OP and save result. */
40306 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40307 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40308 sdata = wqe->wr.wr.atomic.compare_add;
40309 *(u64 *) sqp->s_sge.sge.vaddr =
40310 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40311 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40312 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40313 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40314 sdata, wqe->wr.wr.atomic.swap);
40315 goto send_comp;
40316 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40317 index f2a3f48..673ec79 100644
40318 --- a/drivers/infiniband/hw/mlx4/mad.c
40319 +++ b/drivers/infiniband/hw/mlx4/mad.c
40320 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40321
40322 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40323 {
40324 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40325 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40326 cpu_to_be64(0xff00000000000000LL);
40327 }
40328
40329 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40330 index 25b2cdf..099ff97 100644
40331 --- a/drivers/infiniband/hw/mlx4/mcg.c
40332 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40333 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40334 {
40335 char name[20];
40336
40337 - atomic_set(&ctx->tid, 0);
40338 + atomic_set_unchecked(&ctx->tid, 0);
40339 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40340 ctx->mcg_wq = create_singlethread_workqueue(name);
40341 if (!ctx->mcg_wq)
40342 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40343 index 036b663..c9a8c73 100644
40344 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40345 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40346 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40347 struct list_head mcg_mgid0_list;
40348 struct workqueue_struct *mcg_wq;
40349 struct mlx4_ib_demux_pv_ctx **tun;
40350 - atomic_t tid;
40351 + atomic_unchecked_t tid;
40352 int flushing; /* flushing the work queue */
40353 };
40354
40355 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40356 index 9d3e5c1..6f166df 100644
40357 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40358 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40359 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40360 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40361 }
40362
40363 -int mthca_QUERY_FW(struct mthca_dev *dev)
40364 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40365 {
40366 struct mthca_mailbox *mailbox;
40367 u32 *outbox;
40368 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40369 CMD_TIME_CLASS_B);
40370 }
40371
40372 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40373 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40374 int num_mtt)
40375 {
40376 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
40377 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
40378 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
40379 }
40380
40381 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40382 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40383 int eq_num)
40384 {
40385 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
40386 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
40387 CMD_TIME_CLASS_B);
40388 }
40389
40390 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40391 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40392 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
40393 void *in_mad, void *response_mad)
40394 {
40395 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
40396 index 87897b9..7e79542 100644
40397 --- a/drivers/infiniband/hw/mthca/mthca_main.c
40398 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
40399 @@ -692,7 +692,7 @@ err_close:
40400 return err;
40401 }
40402
40403 -static int mthca_setup_hca(struct mthca_dev *dev)
40404 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
40405 {
40406 int err;
40407
40408 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40409 index ed9a989..6aa5dc2 100644
40410 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40411 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40412 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
40413 * through the bitmaps)
40414 */
40415
40416 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40417 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40418 {
40419 int o;
40420 int m;
40421 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40422 return key;
40423 }
40424
40425 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40426 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40427 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40428 {
40429 struct mthca_mailbox *mailbox;
40430 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
40431 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
40432 }
40433
40434 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40435 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40436 u64 *buffer_list, int buffer_size_shift,
40437 int list_len, u64 iova, u64 total_size,
40438 u32 access, struct mthca_mr *mr)
40439 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
40440 index 5b71d43..35a9e14 100644
40441 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
40442 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
40443 @@ -763,7 +763,7 @@ unlock:
40444 return 0;
40445 }
40446
40447 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40448 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40449 {
40450 struct mthca_dev *dev = to_mdev(ibcq->device);
40451 struct mthca_cq *cq = to_mcq(ibcq);
40452 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40453 index 4291410..d2ab1fb 100644
40454 --- a/drivers/infiniband/hw/nes/nes.c
40455 +++ b/drivers/infiniband/hw/nes/nes.c
40456 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40457 LIST_HEAD(nes_adapter_list);
40458 static LIST_HEAD(nes_dev_list);
40459
40460 -atomic_t qps_destroyed;
40461 +atomic_unchecked_t qps_destroyed;
40462
40463 static unsigned int ee_flsh_adapter;
40464 static unsigned int sysfs_nonidx_addr;
40465 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40466 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40467 struct nes_adapter *nesadapter = nesdev->nesadapter;
40468
40469 - atomic_inc(&qps_destroyed);
40470 + atomic_inc_unchecked(&qps_destroyed);
40471
40472 /* Free the control structures */
40473
40474 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40475 index 33cc589..3bd6538 100644
40476 --- a/drivers/infiniband/hw/nes/nes.h
40477 +++ b/drivers/infiniband/hw/nes/nes.h
40478 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40479 extern unsigned int wqm_quanta;
40480 extern struct list_head nes_adapter_list;
40481
40482 -extern atomic_t cm_connects;
40483 -extern atomic_t cm_accepts;
40484 -extern atomic_t cm_disconnects;
40485 -extern atomic_t cm_closes;
40486 -extern atomic_t cm_connecteds;
40487 -extern atomic_t cm_connect_reqs;
40488 -extern atomic_t cm_rejects;
40489 -extern atomic_t mod_qp_timouts;
40490 -extern atomic_t qps_created;
40491 -extern atomic_t qps_destroyed;
40492 -extern atomic_t sw_qps_destroyed;
40493 +extern atomic_unchecked_t cm_connects;
40494 +extern atomic_unchecked_t cm_accepts;
40495 +extern atomic_unchecked_t cm_disconnects;
40496 +extern atomic_unchecked_t cm_closes;
40497 +extern atomic_unchecked_t cm_connecteds;
40498 +extern atomic_unchecked_t cm_connect_reqs;
40499 +extern atomic_unchecked_t cm_rejects;
40500 +extern atomic_unchecked_t mod_qp_timouts;
40501 +extern atomic_unchecked_t qps_created;
40502 +extern atomic_unchecked_t qps_destroyed;
40503 +extern atomic_unchecked_t sw_qps_destroyed;
40504 extern u32 mh_detected;
40505 extern u32 mh_pauses_sent;
40506 extern u32 cm_packets_sent;
40507 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40508 extern u32 cm_packets_received;
40509 extern u32 cm_packets_dropped;
40510 extern u32 cm_packets_retrans;
40511 -extern atomic_t cm_listens_created;
40512 -extern atomic_t cm_listens_destroyed;
40513 +extern atomic_unchecked_t cm_listens_created;
40514 +extern atomic_unchecked_t cm_listens_destroyed;
40515 extern u32 cm_backlog_drops;
40516 -extern atomic_t cm_loopbacks;
40517 -extern atomic_t cm_nodes_created;
40518 -extern atomic_t cm_nodes_destroyed;
40519 -extern atomic_t cm_accel_dropped_pkts;
40520 -extern atomic_t cm_resets_recvd;
40521 -extern atomic_t pau_qps_created;
40522 -extern atomic_t pau_qps_destroyed;
40523 +extern atomic_unchecked_t cm_loopbacks;
40524 +extern atomic_unchecked_t cm_nodes_created;
40525 +extern atomic_unchecked_t cm_nodes_destroyed;
40526 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40527 +extern atomic_unchecked_t cm_resets_recvd;
40528 +extern atomic_unchecked_t pau_qps_created;
40529 +extern atomic_unchecked_t pau_qps_destroyed;
40530
40531 extern u32 int_mod_timer_init;
40532 extern u32 int_mod_cq_depth_256;
40533 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40534 index 6b29249..57081dd 100644
40535 --- a/drivers/infiniband/hw/nes/nes_cm.c
40536 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40537 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40538 u32 cm_packets_retrans;
40539 u32 cm_packets_created;
40540 u32 cm_packets_received;
40541 -atomic_t cm_listens_created;
40542 -atomic_t cm_listens_destroyed;
40543 +atomic_unchecked_t cm_listens_created;
40544 +atomic_unchecked_t cm_listens_destroyed;
40545 u32 cm_backlog_drops;
40546 -atomic_t cm_loopbacks;
40547 -atomic_t cm_nodes_created;
40548 -atomic_t cm_nodes_destroyed;
40549 -atomic_t cm_accel_dropped_pkts;
40550 -atomic_t cm_resets_recvd;
40551 +atomic_unchecked_t cm_loopbacks;
40552 +atomic_unchecked_t cm_nodes_created;
40553 +atomic_unchecked_t cm_nodes_destroyed;
40554 +atomic_unchecked_t cm_accel_dropped_pkts;
40555 +atomic_unchecked_t cm_resets_recvd;
40556
40557 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40558 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40559 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40560
40561 static struct nes_cm_core *g_cm_core;
40562
40563 -atomic_t cm_connects;
40564 -atomic_t cm_accepts;
40565 -atomic_t cm_disconnects;
40566 -atomic_t cm_closes;
40567 -atomic_t cm_connecteds;
40568 -atomic_t cm_connect_reqs;
40569 -atomic_t cm_rejects;
40570 +atomic_unchecked_t cm_connects;
40571 +atomic_unchecked_t cm_accepts;
40572 +atomic_unchecked_t cm_disconnects;
40573 +atomic_unchecked_t cm_closes;
40574 +atomic_unchecked_t cm_connecteds;
40575 +atomic_unchecked_t cm_connect_reqs;
40576 +atomic_unchecked_t cm_rejects;
40577
40578 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40579 {
40580 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40581 kfree(listener);
40582 listener = NULL;
40583 ret = 0;
40584 - atomic_inc(&cm_listens_destroyed);
40585 + atomic_inc_unchecked(&cm_listens_destroyed);
40586 } else {
40587 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40588 }
40589 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40590 cm_node->rem_mac);
40591
40592 add_hte_node(cm_core, cm_node);
40593 - atomic_inc(&cm_nodes_created);
40594 + atomic_inc_unchecked(&cm_nodes_created);
40595
40596 return cm_node;
40597 }
40598 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40599 }
40600
40601 atomic_dec(&cm_core->node_cnt);
40602 - atomic_inc(&cm_nodes_destroyed);
40603 + atomic_inc_unchecked(&cm_nodes_destroyed);
40604 nesqp = cm_node->nesqp;
40605 if (nesqp) {
40606 nesqp->cm_node = NULL;
40607 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40608
40609 static void drop_packet(struct sk_buff *skb)
40610 {
40611 - atomic_inc(&cm_accel_dropped_pkts);
40612 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40613 dev_kfree_skb_any(skb);
40614 }
40615
40616 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40617 {
40618
40619 int reset = 0; /* whether to send reset in case of err.. */
40620 - atomic_inc(&cm_resets_recvd);
40621 + atomic_inc_unchecked(&cm_resets_recvd);
40622 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40623 " refcnt=%d\n", cm_node, cm_node->state,
40624 atomic_read(&cm_node->ref_count));
40625 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40626 rem_ref_cm_node(cm_node->cm_core, cm_node);
40627 return NULL;
40628 }
40629 - atomic_inc(&cm_loopbacks);
40630 + atomic_inc_unchecked(&cm_loopbacks);
40631 loopbackremotenode->loopbackpartner = cm_node;
40632 loopbackremotenode->tcp_cntxt.rcv_wscale =
40633 NES_CM_DEFAULT_RCV_WND_SCALE;
40634 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40635 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40636 else {
40637 rem_ref_cm_node(cm_core, cm_node);
40638 - atomic_inc(&cm_accel_dropped_pkts);
40639 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40640 dev_kfree_skb_any(skb);
40641 }
40642 break;
40643 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40644
40645 if ((cm_id) && (cm_id->event_handler)) {
40646 if (issue_disconn) {
40647 - atomic_inc(&cm_disconnects);
40648 + atomic_inc_unchecked(&cm_disconnects);
40649 cm_event.event = IW_CM_EVENT_DISCONNECT;
40650 cm_event.status = disconn_status;
40651 cm_event.local_addr = cm_id->local_addr;
40652 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40653 }
40654
40655 if (issue_close) {
40656 - atomic_inc(&cm_closes);
40657 + atomic_inc_unchecked(&cm_closes);
40658 nes_disconnect(nesqp, 1);
40659
40660 cm_id->provider_data = nesqp;
40661 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40662
40663 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40664 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40665 - atomic_inc(&cm_accepts);
40666 + atomic_inc_unchecked(&cm_accepts);
40667
40668 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40669 netdev_refcnt_read(nesvnic->netdev));
40670 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40671 struct nes_cm_core *cm_core;
40672 u8 *start_buff;
40673
40674 - atomic_inc(&cm_rejects);
40675 + atomic_inc_unchecked(&cm_rejects);
40676 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40677 loopback = cm_node->loopbackpartner;
40678 cm_core = cm_node->cm_core;
40679 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40680 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
40681 ntohs(laddr->sin_port));
40682
40683 - atomic_inc(&cm_connects);
40684 + atomic_inc_unchecked(&cm_connects);
40685 nesqp->active_conn = 1;
40686
40687 /* cache the cm_id in the qp */
40688 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40689 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40690 return err;
40691 }
40692 - atomic_inc(&cm_listens_created);
40693 + atomic_inc_unchecked(&cm_listens_created);
40694 }
40695
40696 cm_id->add_ref(cm_id);
40697 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40698
40699 if (nesqp->destroyed)
40700 return;
40701 - atomic_inc(&cm_connecteds);
40702 + atomic_inc_unchecked(&cm_connecteds);
40703 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40704 " local port 0x%04X. jiffies = %lu.\n",
40705 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
40706 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40707
40708 cm_id->add_ref(cm_id);
40709 ret = cm_id->event_handler(cm_id, &cm_event);
40710 - atomic_inc(&cm_closes);
40711 + atomic_inc_unchecked(&cm_closes);
40712 cm_event.event = IW_CM_EVENT_CLOSE;
40713 cm_event.status = 0;
40714 cm_event.provider_data = cm_id->provider_data;
40715 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40716 return;
40717 cm_id = cm_node->cm_id;
40718
40719 - atomic_inc(&cm_connect_reqs);
40720 + atomic_inc_unchecked(&cm_connect_reqs);
40721 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40722 cm_node, cm_id, jiffies);
40723
40724 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40725 return;
40726 cm_id = cm_node->cm_id;
40727
40728 - atomic_inc(&cm_connect_reqs);
40729 + atomic_inc_unchecked(&cm_connect_reqs);
40730 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40731 cm_node, cm_id, jiffies);
40732
40733 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40734 index 4166452..fc952c3 100644
40735 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40736 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40737 @@ -40,8 +40,8 @@
40738 #include "nes.h"
40739 #include "nes_mgt.h"
40740
40741 -atomic_t pau_qps_created;
40742 -atomic_t pau_qps_destroyed;
40743 +atomic_unchecked_t pau_qps_created;
40744 +atomic_unchecked_t pau_qps_destroyed;
40745
40746 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40747 {
40748 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40749 {
40750 struct sk_buff *skb;
40751 unsigned long flags;
40752 - atomic_inc(&pau_qps_destroyed);
40753 + atomic_inc_unchecked(&pau_qps_destroyed);
40754
40755 /* Free packets that have not yet been forwarded */
40756 /* Lock is acquired by skb_dequeue when removing the skb */
40757 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40758 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40759 skb_queue_head_init(&nesqp->pau_list);
40760 spin_lock_init(&nesqp->pau_lock);
40761 - atomic_inc(&pau_qps_created);
40762 + atomic_inc_unchecked(&pau_qps_created);
40763 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40764 }
40765
40766 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40767 index 49eb511..a774366 100644
40768 --- a/drivers/infiniband/hw/nes/nes_nic.c
40769 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40770 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40771 target_stat_values[++index] = mh_detected;
40772 target_stat_values[++index] = mh_pauses_sent;
40773 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40774 - target_stat_values[++index] = atomic_read(&cm_connects);
40775 - target_stat_values[++index] = atomic_read(&cm_accepts);
40776 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40777 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40778 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40779 - target_stat_values[++index] = atomic_read(&cm_rejects);
40780 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40781 - target_stat_values[++index] = atomic_read(&qps_created);
40782 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40783 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40784 - target_stat_values[++index] = atomic_read(&cm_closes);
40785 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40786 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40787 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40788 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40789 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40790 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40791 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40792 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40793 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40794 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40795 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40796 target_stat_values[++index] = cm_packets_sent;
40797 target_stat_values[++index] = cm_packets_bounced;
40798 target_stat_values[++index] = cm_packets_created;
40799 target_stat_values[++index] = cm_packets_received;
40800 target_stat_values[++index] = cm_packets_dropped;
40801 target_stat_values[++index] = cm_packets_retrans;
40802 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40803 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40804 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40805 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40806 target_stat_values[++index] = cm_backlog_drops;
40807 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40808 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40809 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40810 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40811 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40812 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40813 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40814 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40815 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40816 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40817 target_stat_values[++index] = nesadapter->free_4kpbl;
40818 target_stat_values[++index] = nesadapter->free_256pbl;
40819 target_stat_values[++index] = int_mod_timer_init;
40820 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40821 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40822 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40823 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40824 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40825 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40826 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40827 }
40828
40829 /**
40830 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40831 index 5b53ca5..443da3c 100644
40832 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40833 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40834 @@ -46,9 +46,9 @@
40835
40836 #include <rdma/ib_umem.h>
40837
40838 -atomic_t mod_qp_timouts;
40839 -atomic_t qps_created;
40840 -atomic_t sw_qps_destroyed;
40841 +atomic_unchecked_t mod_qp_timouts;
40842 +atomic_unchecked_t qps_created;
40843 +atomic_unchecked_t sw_qps_destroyed;
40844
40845 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40846
40847 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40848 if (init_attr->create_flags)
40849 return ERR_PTR(-EINVAL);
40850
40851 - atomic_inc(&qps_created);
40852 + atomic_inc_unchecked(&qps_created);
40853 switch (init_attr->qp_type) {
40854 case IB_QPT_RC:
40855 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40856 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40857 struct iw_cm_event cm_event;
40858 int ret = 0;
40859
40860 - atomic_inc(&sw_qps_destroyed);
40861 + atomic_inc_unchecked(&sw_qps_destroyed);
40862 nesqp->destroyed = 1;
40863
40864 /* Blow away the connection if it exists. */
40865 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40866 index 1946101..09766d2 100644
40867 --- a/drivers/infiniband/hw/qib/qib.h
40868 +++ b/drivers/infiniband/hw/qib/qib.h
40869 @@ -52,6 +52,7 @@
40870 #include <linux/kref.h>
40871 #include <linux/sched.h>
40872 #include <linux/kthread.h>
40873 +#include <linux/slab.h>
40874
40875 #include "qib_common.h"
40876 #include "qib_verbs.h"
40877 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40878 index 922a7fe..bb035db 100644
40879 --- a/drivers/input/gameport/gameport.c
40880 +++ b/drivers/input/gameport/gameport.c
40881 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40882 */
40883 static void gameport_init_port(struct gameport *gameport)
40884 {
40885 - static atomic_t gameport_no = ATOMIC_INIT(0);
40886 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40887
40888 __module_get(THIS_MODULE);
40889
40890 mutex_init(&gameport->drv_mutex);
40891 device_initialize(&gameport->dev);
40892 dev_set_name(&gameport->dev, "gameport%lu",
40893 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40894 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40895 gameport->dev.bus = &gameport_bus;
40896 gameport->dev.release = gameport_release_port;
40897 if (gameport->parent)
40898 diff --git a/drivers/input/input.c b/drivers/input/input.c
40899 index e75d015..57d1c28 100644
40900 --- a/drivers/input/input.c
40901 +++ b/drivers/input/input.c
40902 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
40903 */
40904 struct input_dev *input_allocate_device(void)
40905 {
40906 - static atomic_t input_no = ATOMIC_INIT(0);
40907 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40908 struct input_dev *dev;
40909
40910 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
40911 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
40912 INIT_LIST_HEAD(&dev->node);
40913
40914 dev_set_name(&dev->dev, "input%ld",
40915 - (unsigned long) atomic_inc_return(&input_no) - 1);
40916 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40917
40918 __module_get(THIS_MODULE);
40919 }
40920 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40921 index 04c69af..5f92d00 100644
40922 --- a/drivers/input/joystick/sidewinder.c
40923 +++ b/drivers/input/joystick/sidewinder.c
40924 @@ -30,6 +30,7 @@
40925 #include <linux/kernel.h>
40926 #include <linux/module.h>
40927 #include <linux/slab.h>
40928 +#include <linux/sched.h>
40929 #include <linux/init.h>
40930 #include <linux/input.h>
40931 #include <linux/gameport.h>
40932 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40933 index 75e3b10..fb390fd 100644
40934 --- a/drivers/input/joystick/xpad.c
40935 +++ b/drivers/input/joystick/xpad.c
40936 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40937
40938 static int xpad_led_probe(struct usb_xpad *xpad)
40939 {
40940 - static atomic_t led_seq = ATOMIC_INIT(0);
40941 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40942 long led_no;
40943 struct xpad_led *led;
40944 struct led_classdev *led_cdev;
40945 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40946 if (!led)
40947 return -ENOMEM;
40948
40949 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40950 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40951
40952 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40953 led->xpad = xpad;
40954 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40955 index e204f26..8459f15 100644
40956 --- a/drivers/input/misc/ims-pcu.c
40957 +++ b/drivers/input/misc/ims-pcu.c
40958 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40959
40960 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40961 {
40962 - static atomic_t device_no = ATOMIC_INIT(0);
40963 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40964
40965 const struct ims_pcu_device_info *info;
40966 u8 device_id;
40967 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40968 }
40969
40970 /* Device appears to be operable, complete initialization */
40971 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40972 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40973
40974 error = ims_pcu_setup_backlight(pcu);
40975 if (error)
40976 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40977 index 2f0b39d..7370f13 100644
40978 --- a/drivers/input/mouse/psmouse.h
40979 +++ b/drivers/input/mouse/psmouse.h
40980 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40981 ssize_t (*set)(struct psmouse *psmouse, void *data,
40982 const char *buf, size_t count);
40983 bool protect;
40984 -};
40985 +} __do_const;
40986 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40987
40988 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40989 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40990 index 4c842c3..590b0bf 100644
40991 --- a/drivers/input/mousedev.c
40992 +++ b/drivers/input/mousedev.c
40993 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40994
40995 spin_unlock_irq(&client->packet_lock);
40996
40997 - if (copy_to_user(buffer, data, count))
40998 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40999 return -EFAULT;
41000
41001 return count;
41002 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41003 index 2b56855..5a55837 100644
41004 --- a/drivers/input/serio/serio.c
41005 +++ b/drivers/input/serio/serio.c
41006 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41007 */
41008 static void serio_init_port(struct serio *serio)
41009 {
41010 - static atomic_t serio_no = ATOMIC_INIT(0);
41011 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41012
41013 __module_get(THIS_MODULE);
41014
41015 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41016 mutex_init(&serio->drv_mutex);
41017 device_initialize(&serio->dev);
41018 dev_set_name(&serio->dev, "serio%ld",
41019 - (long)atomic_inc_return(&serio_no) - 1);
41020 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41021 serio->dev.bus = &serio_bus;
41022 serio->dev.release = serio_release_port;
41023 serio->dev.groups = serio_device_attr_groups;
41024 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41025 index 59df2e7..8f1cafb 100644
41026 --- a/drivers/input/serio/serio_raw.c
41027 +++ b/drivers/input/serio/serio_raw.c
41028 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41029
41030 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41031 {
41032 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41033 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41034 struct serio_raw *serio_raw;
41035 int err;
41036
41037 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41038 }
41039
41040 snprintf(serio_raw->name, sizeof(serio_raw->name),
41041 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41042 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41043 kref_init(&serio_raw->kref);
41044 INIT_LIST_HEAD(&serio_raw->client_list);
41045 init_waitqueue_head(&serio_raw->wait);
41046 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41047 index fbe9ca7..dbee61d 100644
41048 --- a/drivers/iommu/iommu.c
41049 +++ b/drivers/iommu/iommu.c
41050 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41051 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41052 {
41053 bus_register_notifier(bus, &iommu_bus_nb);
41054 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41055 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41056 }
41057
41058 /**
41059 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41060 index 39f81ae..2660096 100644
41061 --- a/drivers/iommu/irq_remapping.c
41062 +++ b/drivers/iommu/irq_remapping.c
41063 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41064 void panic_if_irq_remap(const char *msg)
41065 {
41066 if (irq_remapping_enabled)
41067 - panic(msg);
41068 + panic("%s", msg);
41069 }
41070
41071 static void ir_ack_apic_edge(struct irq_data *data)
41072 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41073
41074 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41075 {
41076 - chip->irq_print_chip = ir_print_prefix;
41077 - chip->irq_ack = ir_ack_apic_edge;
41078 - chip->irq_eoi = ir_ack_apic_level;
41079 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41080 + pax_open_kernel();
41081 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41082 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41083 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41084 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41085 + pax_close_kernel();
41086 }
41087
41088 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41089 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41090 index d0e9480..d2b6340 100644
41091 --- a/drivers/irqchip/irq-gic.c
41092 +++ b/drivers/irqchip/irq-gic.c
41093 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41094 * Supported arch specific GIC irq extension.
41095 * Default make them NULL.
41096 */
41097 -struct irq_chip gic_arch_extn = {
41098 +irq_chip_no_const gic_arch_extn = {
41099 .irq_eoi = NULL,
41100 .irq_mask = NULL,
41101 .irq_unmask = NULL,
41102 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41103 chained_irq_exit(chip, desc);
41104 }
41105
41106 -static struct irq_chip gic_chip = {
41107 +static irq_chip_no_const gic_chip __read_only = {
41108 .name = "GIC",
41109 .irq_mask = gic_mask_irq,
41110 .irq_unmask = gic_unmask_irq,
41111 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41112 index ac6f72b..81150f2 100644
41113 --- a/drivers/isdn/capi/capi.c
41114 +++ b/drivers/isdn/capi/capi.c
41115 @@ -81,8 +81,8 @@ struct capiminor {
41116
41117 struct capi20_appl *ap;
41118 u32 ncci;
41119 - atomic_t datahandle;
41120 - atomic_t msgid;
41121 + atomic_unchecked_t datahandle;
41122 + atomic_unchecked_t msgid;
41123
41124 struct tty_port port;
41125 int ttyinstop;
41126 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41127 capimsg_setu16(s, 2, mp->ap->applid);
41128 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41129 capimsg_setu8 (s, 5, CAPI_RESP);
41130 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41131 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41132 capimsg_setu32(s, 8, mp->ncci);
41133 capimsg_setu16(s, 12, datahandle);
41134 }
41135 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41136 mp->outbytes -= len;
41137 spin_unlock_bh(&mp->outlock);
41138
41139 - datahandle = atomic_inc_return(&mp->datahandle);
41140 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41141 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41142 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41143 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41144 capimsg_setu16(skb->data, 2, mp->ap->applid);
41145 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41146 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41147 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41148 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41149 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41150 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41151 capimsg_setu16(skb->data, 16, len); /* Data length */
41152 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41153 index 600c79b..3752bab 100644
41154 --- a/drivers/isdn/gigaset/interface.c
41155 +++ b/drivers/isdn/gigaset/interface.c
41156 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41157 }
41158 tty->driver_data = cs;
41159
41160 - ++cs->port.count;
41161 + atomic_inc(&cs->port.count);
41162
41163 - if (cs->port.count == 1) {
41164 + if (atomic_read(&cs->port.count) == 1) {
41165 tty_port_tty_set(&cs->port, tty);
41166 cs->port.low_latency = 1;
41167 }
41168 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41169
41170 if (!cs->connected)
41171 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41172 - else if (!cs->port.count)
41173 + else if (!atomic_read(&cs->port.count))
41174 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41175 - else if (!--cs->port.count)
41176 + else if (!atomic_dec_return(&cs->port.count))
41177 tty_port_tty_set(&cs->port, NULL);
41178
41179 mutex_unlock(&cs->mutex);
41180 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41181 index d0a41cb..f0cdb8c 100644
41182 --- a/drivers/isdn/gigaset/usb-gigaset.c
41183 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41184 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41185 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41186 memcpy(cs->hw.usb->bchars, buf, 6);
41187 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41188 - 0, 0, &buf, 6, 2000);
41189 + 0, 0, buf, 6, 2000);
41190 }
41191
41192 static void gigaset_freebcshw(struct bc_state *bcs)
41193 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41194 index 4d9b195..455075c 100644
41195 --- a/drivers/isdn/hardware/avm/b1.c
41196 +++ b/drivers/isdn/hardware/avm/b1.c
41197 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41198 }
41199 if (left) {
41200 if (t4file->user) {
41201 - if (copy_from_user(buf, dp, left))
41202 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41203 return -EFAULT;
41204 } else {
41205 memcpy(buf, dp, left);
41206 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41207 }
41208 if (left) {
41209 if (config->user) {
41210 - if (copy_from_user(buf, dp, left))
41211 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41212 return -EFAULT;
41213 } else {
41214 memcpy(buf, dp, left);
41215 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41216 index 9bb12ba..d4262f7 100644
41217 --- a/drivers/isdn/i4l/isdn_common.c
41218 +++ b/drivers/isdn/i4l/isdn_common.c
41219 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41220 } else
41221 return -EINVAL;
41222 case IIOCDBGVAR:
41223 + if (!capable(CAP_SYS_RAWIO))
41224 + return -EPERM;
41225 if (arg) {
41226 if (copy_to_user(argp, &dev, sizeof(ulong)))
41227 return -EFAULT;
41228 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41229 index 3c5f249..5fac4d0 100644
41230 --- a/drivers/isdn/i4l/isdn_tty.c
41231 +++ b/drivers/isdn/i4l/isdn_tty.c
41232 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41233
41234 #ifdef ISDN_DEBUG_MODEM_OPEN
41235 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41236 - port->count);
41237 + atomic_read(&port->count));
41238 #endif
41239 - port->count++;
41240 + atomic_inc(&port->count);
41241 port->tty = tty;
41242 /*
41243 * Start up serial port
41244 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41245 #endif
41246 return;
41247 }
41248 - if ((tty->count == 1) && (port->count != 1)) {
41249 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41250 /*
41251 * Uh, oh. tty->count is 1, which means that the tty
41252 * structure will be freed. Info->count should always
41253 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41254 * serial port won't be shutdown.
41255 */
41256 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41257 - "info->count is %d\n", port->count);
41258 - port->count = 1;
41259 + "info->count is %d\n", atomic_read(&port->count));
41260 + atomic_set(&port->count, 1);
41261 }
41262 - if (--port->count < 0) {
41263 + if (atomic_dec_return(&port->count) < 0) {
41264 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41265 - info->line, port->count);
41266 - port->count = 0;
41267 + info->line, atomic_read(&port->count));
41268 + atomic_set(&port->count, 0);
41269 }
41270 - if (port->count) {
41271 + if (atomic_read(&port->count)) {
41272 #ifdef ISDN_DEBUG_MODEM_OPEN
41273 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41274 #endif
41275 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41276 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41277 return;
41278 isdn_tty_shutdown(info);
41279 - port->count = 0;
41280 + atomic_set(&port->count, 0);
41281 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41282 port->tty = NULL;
41283 wake_up_interruptible(&port->open_wait);
41284 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41285 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41286 modem_info *info = &dev->mdm.info[i];
41287
41288 - if (info->port.count == 0)
41289 + if (atomic_read(&info->port.count) == 0)
41290 continue;
41291 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41292 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41293 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41294 index e74df7c..03a03ba 100644
41295 --- a/drivers/isdn/icn/icn.c
41296 +++ b/drivers/isdn/icn/icn.c
41297 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41298 if (count > len)
41299 count = len;
41300 if (user) {
41301 - if (copy_from_user(msg, buf, count))
41302 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41303 return -EFAULT;
41304 } else
41305 memcpy(msg, buf, count);
41306 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41307 index baf2686..02125e6 100644
41308 --- a/drivers/isdn/isdnloop/isdnloop.c
41309 +++ b/drivers/isdn/isdnloop/isdnloop.c
41310 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41311 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41312 return -ENOMEM;
41313 }
41314 - for (i = 0; i < 3; i++)
41315 - strcpy(card->s0num[i], sdef.num[i]);
41316 + for (i = 0; i < 3; i++) {
41317 + strlcpy(card->s0num[i], sdef.num[i],
41318 + sizeof(card->s0num[0]));
41319 + }
41320 break;
41321 case ISDN_PTYPE_1TR6:
41322 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41323 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41324 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41325 return -ENOMEM;
41326 }
41327 - strcpy(card->s0num[0], sdef.num[0]);
41328 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41329 card->s0num[1][0] = '\0';
41330 card->s0num[2][0] = '\0';
41331 break;
41332 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41333 index a4f05c5..1433bc5 100644
41334 --- a/drivers/isdn/mISDN/dsp_cmx.c
41335 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41336 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41337 static u16 dsp_count; /* last sample count */
41338 static int dsp_count_valid; /* if we have last sample count */
41339
41340 -void
41341 +void __intentional_overflow(-1)
41342 dsp_cmx_send(void *arg)
41343 {
41344 struct dsp_conf *conf;
41345 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41346 index d93e245..e7ece6b 100644
41347 --- a/drivers/leds/leds-clevo-mail.c
41348 +++ b/drivers/leds/leds-clevo-mail.c
41349 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41350 * detected as working, but in reality it is not) as low as
41351 * possible.
41352 */
41353 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41354 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41355 {
41356 .callback = clevo_mail_led_dmi_callback,
41357 .ident = "Clevo D410J",
41358 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41359 index 5b8f938..b73d657 100644
41360 --- a/drivers/leds/leds-ss4200.c
41361 +++ b/drivers/leds/leds-ss4200.c
41362 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41363 * detected as working, but in reality it is not) as low as
41364 * possible.
41365 */
41366 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41367 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41368 {
41369 .callback = ss4200_led_dmi_callback,
41370 .ident = "Intel SS4200-E",
41371 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41372 index 0bf1e4e..b4bf44e 100644
41373 --- a/drivers/lguest/core.c
41374 +++ b/drivers/lguest/core.c
41375 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41376 * The end address needs +1 because __get_vm_area allocates an
41377 * extra guard page, so we need space for that.
41378 */
41379 +
41380 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41381 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41382 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41383 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41384 +#else
41385 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41386 VM_ALLOC, switcher_addr, switcher_addr
41387 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41388 +#endif
41389 +
41390 if (!switcher_vma) {
41391 err = -ENOMEM;
41392 printk("lguest: could not map switcher pages high\n");
41393 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41394 * Now the Switcher is mapped at the right address, we can't fail!
41395 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41396 */
41397 - memcpy(switcher_vma->addr, start_switcher_text,
41398 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41399 end_switcher_text - start_switcher_text);
41400
41401 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41402 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41403 index bfb39bb..08a603b 100644
41404 --- a/drivers/lguest/page_tables.c
41405 +++ b/drivers/lguest/page_tables.c
41406 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41407 /*:*/
41408
41409 #ifdef CONFIG_X86_PAE
41410 -static void release_pmd(pmd_t *spmd)
41411 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41412 {
41413 /* If the entry's not present, there's nothing to release. */
41414 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41415 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41416 index 5169239..47cb4db 100644
41417 --- a/drivers/lguest/x86/core.c
41418 +++ b/drivers/lguest/x86/core.c
41419 @@ -59,7 +59,7 @@ static struct {
41420 /* Offset from where switcher.S was compiled to where we've copied it */
41421 static unsigned long switcher_offset(void)
41422 {
41423 - return switcher_addr - (unsigned long)start_switcher_text;
41424 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41425 }
41426
41427 /* This cpu's struct lguest_pages (after the Switcher text page) */
41428 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41429 * These copies are pretty cheap, so we do them unconditionally: */
41430 /* Save the current Host top-level page directory.
41431 */
41432 +
41433 +#ifdef CONFIG_PAX_PER_CPU_PGD
41434 + pages->state.host_cr3 = read_cr3();
41435 +#else
41436 pages->state.host_cr3 = __pa(current->mm->pgd);
41437 +#endif
41438 +
41439 /*
41440 * Set up the Guest's page tables to see this CPU's pages (and no
41441 * other CPU's pages).
41442 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41443 * compiled-in switcher code and the high-mapped copy we just made.
41444 */
41445 for (i = 0; i < IDT_ENTRIES; i++)
41446 - default_idt_entries[i] += switcher_offset();
41447 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41448
41449 /*
41450 * Set up the Switcher's per-cpu areas.
41451 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41452 * it will be undisturbed when we switch. To change %cs and jump we
41453 * need this structure to feed to Intel's "lcall" instruction.
41454 */
41455 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41456 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41457 lguest_entry.segment = LGUEST_CS;
41458
41459 /*
41460 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41461 index 40634b0..4f5855e 100644
41462 --- a/drivers/lguest/x86/switcher_32.S
41463 +++ b/drivers/lguest/x86/switcher_32.S
41464 @@ -87,6 +87,7 @@
41465 #include <asm/page.h>
41466 #include <asm/segment.h>
41467 #include <asm/lguest.h>
41468 +#include <asm/processor-flags.h>
41469
41470 // We mark the start of the code to copy
41471 // It's placed in .text tho it's never run here
41472 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41473 // Changes type when we load it: damn Intel!
41474 // For after we switch over our page tables
41475 // That entry will be read-only: we'd crash.
41476 +
41477 +#ifdef CONFIG_PAX_KERNEXEC
41478 + mov %cr0, %edx
41479 + xor $X86_CR0_WP, %edx
41480 + mov %edx, %cr0
41481 +#endif
41482 +
41483 movl $(GDT_ENTRY_TSS*8), %edx
41484 ltr %dx
41485
41486 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41487 // Let's clear it again for our return.
41488 // The GDT descriptor of the Host
41489 // Points to the table after two "size" bytes
41490 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41491 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41492 // Clear "used" from type field (byte 5, bit 2)
41493 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41494 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41495 +
41496 +#ifdef CONFIG_PAX_KERNEXEC
41497 + mov %cr0, %eax
41498 + xor $X86_CR0_WP, %eax
41499 + mov %eax, %cr0
41500 +#endif
41501
41502 // Once our page table's switched, the Guest is live!
41503 // The Host fades as we run this final step.
41504 @@ -295,13 +309,12 @@ deliver_to_host:
41505 // I consulted gcc, and it gave
41506 // These instructions, which I gladly credit:
41507 leal (%edx,%ebx,8), %eax
41508 - movzwl (%eax),%edx
41509 - movl 4(%eax), %eax
41510 - xorw %ax, %ax
41511 - orl %eax, %edx
41512 + movl 4(%eax), %edx
41513 + movw (%eax), %dx
41514 // Now the address of the handler's in %edx
41515 // We call it now: its "iret" drops us home.
41516 - jmp *%edx
41517 + ljmp $__KERNEL_CS, $1f
41518 +1: jmp *%edx
41519
41520 // Every interrupt can come to us here
41521 // But we must truly tell each apart.
41522 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41523 index 0003992..854bbce 100644
41524 --- a/drivers/md/bcache/closure.h
41525 +++ b/drivers/md/bcache/closure.h
41526 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41527 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41528 struct workqueue_struct *wq)
41529 {
41530 - BUG_ON(object_is_on_stack(cl));
41531 + BUG_ON(object_starts_on_stack(cl));
41532 closure_set_ip(cl);
41533 cl->fn = fn;
41534 cl->wq = wq;
41535 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41536 index 547c4c5..5be1de4 100644
41537 --- a/drivers/md/bcache/super.c
41538 +++ b/drivers/md/bcache/super.c
41539 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41540 err:
41541 closure_sync(&op.cl);
41542 /* XXX: test this, it's broken */
41543 - bch_cache_set_error(c, err);
41544 + bch_cache_set_error(c, "%s", err);
41545 }
41546
41547 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41548 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41549 index a7fd821..9dcf6c3 100644
41550 --- a/drivers/md/bitmap.c
41551 +++ b/drivers/md/bitmap.c
41552 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41553 chunk_kb ? "KB" : "B");
41554 if (bitmap->storage.file) {
41555 seq_printf(seq, ", file: ");
41556 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41557 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41558 }
41559
41560 seq_printf(seq, "\n");
41561 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41562 index afe0814..8cf3794 100644
41563 --- a/drivers/md/dm-ioctl.c
41564 +++ b/drivers/md/dm-ioctl.c
41565 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41566 cmd == DM_LIST_VERSIONS_CMD)
41567 return 0;
41568
41569 - if ((cmd == DM_DEV_CREATE_CMD)) {
41570 + if (cmd == DM_DEV_CREATE_CMD) {
41571 if (!*param->name) {
41572 DMWARN("name not supplied when creating device");
41573 return -EINVAL;
41574 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41575 index 9584443..9fc9ac9 100644
41576 --- a/drivers/md/dm-raid1.c
41577 +++ b/drivers/md/dm-raid1.c
41578 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41579
41580 struct mirror {
41581 struct mirror_set *ms;
41582 - atomic_t error_count;
41583 + atomic_unchecked_t error_count;
41584 unsigned long error_type;
41585 struct dm_dev *dev;
41586 sector_t offset;
41587 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41588 struct mirror *m;
41589
41590 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41591 - if (!atomic_read(&m->error_count))
41592 + if (!atomic_read_unchecked(&m->error_count))
41593 return m;
41594
41595 return NULL;
41596 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41597 * simple way to tell if a device has encountered
41598 * errors.
41599 */
41600 - atomic_inc(&m->error_count);
41601 + atomic_inc_unchecked(&m->error_count);
41602
41603 if (test_and_set_bit(error_type, &m->error_type))
41604 return;
41605 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41606 struct mirror *m = get_default_mirror(ms);
41607
41608 do {
41609 - if (likely(!atomic_read(&m->error_count)))
41610 + if (likely(!atomic_read_unchecked(&m->error_count)))
41611 return m;
41612
41613 if (m-- == ms->mirror)
41614 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41615 {
41616 struct mirror *default_mirror = get_default_mirror(m->ms);
41617
41618 - return !atomic_read(&default_mirror->error_count);
41619 + return !atomic_read_unchecked(&default_mirror->error_count);
41620 }
41621
41622 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41623 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41624 */
41625 if (likely(region_in_sync(ms, region, 1)))
41626 m = choose_mirror(ms, bio->bi_sector);
41627 - else if (m && atomic_read(&m->error_count))
41628 + else if (m && atomic_read_unchecked(&m->error_count))
41629 m = NULL;
41630
41631 if (likely(m))
41632 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
41633 }
41634
41635 ms->mirror[mirror].ms = ms;
41636 - atomic_set(&(ms->mirror[mirror].error_count), 0);
41637 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
41638 ms->mirror[mirror].error_type = 0;
41639 ms->mirror[mirror].offset = offset;
41640
41641 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
41642 */
41643 static char device_status_char(struct mirror *m)
41644 {
41645 - if (!atomic_read(&(m->error_count)))
41646 + if (!atomic_read_unchecked(&(m->error_count)))
41647 return 'A';
41648
41649 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
41650 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
41651 index 3d404c1..b62af0e 100644
41652 --- a/drivers/md/dm-stats.c
41653 +++ b/drivers/md/dm-stats.c
41654 @@ -382,7 +382,7 @@ do_sync_free:
41655 synchronize_rcu_expedited();
41656 dm_stat_free(&s->rcu_head);
41657 } else {
41658 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
41659 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
41660 call_rcu(&s->rcu_head, dm_stat_free);
41661 }
41662 return 0;
41663 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
41664 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
41665 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
41666 ));
41667 - ACCESS_ONCE(last->last_sector) = end_sector;
41668 - ACCESS_ONCE(last->last_rw) = bi_rw;
41669 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
41670 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
41671 }
41672
41673 rcu_read_lock();
41674 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
41675 index 73c1712..7347292 100644
41676 --- a/drivers/md/dm-stripe.c
41677 +++ b/drivers/md/dm-stripe.c
41678 @@ -21,7 +21,7 @@ struct stripe {
41679 struct dm_dev *dev;
41680 sector_t physical_start;
41681
41682 - atomic_t error_count;
41683 + atomic_unchecked_t error_count;
41684 };
41685
41686 struct stripe_c {
41687 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
41688 kfree(sc);
41689 return r;
41690 }
41691 - atomic_set(&(sc->stripe[i].error_count), 0);
41692 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
41693 }
41694
41695 ti->private = sc;
41696 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
41697 DMEMIT("%d ", sc->stripes);
41698 for (i = 0; i < sc->stripes; i++) {
41699 DMEMIT("%s ", sc->stripe[i].dev->name);
41700 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
41701 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
41702 'D' : 'A';
41703 }
41704 buffer[i] = '\0';
41705 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
41706 */
41707 for (i = 0; i < sc->stripes; i++)
41708 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
41709 - atomic_inc(&(sc->stripe[i].error_count));
41710 - if (atomic_read(&(sc->stripe[i].error_count)) <
41711 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
41712 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
41713 DM_IO_ERROR_THRESHOLD)
41714 schedule_work(&sc->trigger_event);
41715 }
41716 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
41717 index 8f87835..531854d 100644
41718 --- a/drivers/md/dm-table.c
41719 +++ b/drivers/md/dm-table.c
41720 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
41721 static int open_dev(struct dm_dev_internal *d, dev_t dev,
41722 struct mapped_device *md)
41723 {
41724 - static char *_claim_ptr = "I belong to device-mapper";
41725 + static char _claim_ptr[] = "I belong to device-mapper";
41726 struct block_device *bdev;
41727
41728 int r;
41729 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
41730 if (!dev_size)
41731 return 0;
41732
41733 - if ((start >= dev_size) || (start + len > dev_size)) {
41734 + if ((start >= dev_size) || (len > dev_size - start)) {
41735 DMWARN("%s: %s too small for target: "
41736 "start=%llu, len=%llu, dev_size=%llu",
41737 dm_device_name(ti->table->md), bdevname(bdev, b),
41738 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
41739 index 60bce43..9b997d0 100644
41740 --- a/drivers/md/dm-thin-metadata.c
41741 +++ b/drivers/md/dm-thin-metadata.c
41742 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41743 {
41744 pmd->info.tm = pmd->tm;
41745 pmd->info.levels = 2;
41746 - pmd->info.value_type.context = pmd->data_sm;
41747 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41748 pmd->info.value_type.size = sizeof(__le64);
41749 pmd->info.value_type.inc = data_block_inc;
41750 pmd->info.value_type.dec = data_block_dec;
41751 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41752
41753 pmd->bl_info.tm = pmd->tm;
41754 pmd->bl_info.levels = 1;
41755 - pmd->bl_info.value_type.context = pmd->data_sm;
41756 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41757 pmd->bl_info.value_type.size = sizeof(__le64);
41758 pmd->bl_info.value_type.inc = data_block_inc;
41759 pmd->bl_info.value_type.dec = data_block_dec;
41760 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
41761 index b3e26c7..1efca94 100644
41762 --- a/drivers/md/dm.c
41763 +++ b/drivers/md/dm.c
41764 @@ -179,9 +179,9 @@ struct mapped_device {
41765 /*
41766 * Event handling.
41767 */
41768 - atomic_t event_nr;
41769 + atomic_unchecked_t event_nr;
41770 wait_queue_head_t eventq;
41771 - atomic_t uevent_seq;
41772 + atomic_unchecked_t uevent_seq;
41773 struct list_head uevent_list;
41774 spinlock_t uevent_lock; /* Protect access to uevent_list */
41775
41776 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
41777 spin_lock_init(&md->deferred_lock);
41778 atomic_set(&md->holders, 1);
41779 atomic_set(&md->open_count, 0);
41780 - atomic_set(&md->event_nr, 0);
41781 - atomic_set(&md->uevent_seq, 0);
41782 + atomic_set_unchecked(&md->event_nr, 0);
41783 + atomic_set_unchecked(&md->uevent_seq, 0);
41784 INIT_LIST_HEAD(&md->uevent_list);
41785 spin_lock_init(&md->uevent_lock);
41786
41787 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
41788
41789 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
41790
41791 - atomic_inc(&md->event_nr);
41792 + atomic_inc_unchecked(&md->event_nr);
41793 wake_up(&md->eventq);
41794 }
41795
41796 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
41797
41798 uint32_t dm_next_uevent_seq(struct mapped_device *md)
41799 {
41800 - return atomic_add_return(1, &md->uevent_seq);
41801 + return atomic_add_return_unchecked(1, &md->uevent_seq);
41802 }
41803
41804 uint32_t dm_get_event_nr(struct mapped_device *md)
41805 {
41806 - return atomic_read(&md->event_nr);
41807 + return atomic_read_unchecked(&md->event_nr);
41808 }
41809
41810 int dm_wait_event(struct mapped_device *md, int event_nr)
41811 {
41812 return wait_event_interruptible(md->eventq,
41813 - (event_nr != atomic_read(&md->event_nr)));
41814 + (event_nr != atomic_read_unchecked(&md->event_nr)));
41815 }
41816
41817 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
41818 diff --git a/drivers/md/md.c b/drivers/md/md.c
41819 index 561a65f..f4e8c71 100644
41820 --- a/drivers/md/md.c
41821 +++ b/drivers/md/md.c
41822 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
41823 * start build, activate spare
41824 */
41825 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
41826 -static atomic_t md_event_count;
41827 +static atomic_unchecked_t md_event_count;
41828 void md_new_event(struct mddev *mddev)
41829 {
41830 - atomic_inc(&md_event_count);
41831 + atomic_inc_unchecked(&md_event_count);
41832 wake_up(&md_event_waiters);
41833 }
41834 EXPORT_SYMBOL_GPL(md_new_event);
41835 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
41836 */
41837 static void md_new_event_inintr(struct mddev *mddev)
41838 {
41839 - atomic_inc(&md_event_count);
41840 + atomic_inc_unchecked(&md_event_count);
41841 wake_up(&md_event_waiters);
41842 }
41843
41844 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
41845 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
41846 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
41847 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
41848 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41849 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41850
41851 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
41852 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
41853 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
41854 else
41855 sb->resync_offset = cpu_to_le64(0);
41856
41857 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
41858 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
41859
41860 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
41861 sb->size = cpu_to_le64(mddev->dev_sectors);
41862 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
41863 static ssize_t
41864 errors_show(struct md_rdev *rdev, char *page)
41865 {
41866 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
41867 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
41868 }
41869
41870 static ssize_t
41871 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
41872 char *e;
41873 unsigned long n = simple_strtoul(buf, &e, 10);
41874 if (*buf && (*e == 0 || *e == '\n')) {
41875 - atomic_set(&rdev->corrected_errors, n);
41876 + atomic_set_unchecked(&rdev->corrected_errors, n);
41877 return len;
41878 }
41879 return -EINVAL;
41880 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
41881 rdev->sb_loaded = 0;
41882 rdev->bb_page = NULL;
41883 atomic_set(&rdev->nr_pending, 0);
41884 - atomic_set(&rdev->read_errors, 0);
41885 - atomic_set(&rdev->corrected_errors, 0);
41886 + atomic_set_unchecked(&rdev->read_errors, 0);
41887 + atomic_set_unchecked(&rdev->corrected_errors, 0);
41888
41889 INIT_LIST_HEAD(&rdev->same_set);
41890 init_waitqueue_head(&rdev->blocked_wait);
41891 @@ -7042,7 +7042,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
41892
41893 spin_unlock(&pers_lock);
41894 seq_printf(seq, "\n");
41895 - seq->poll_event = atomic_read(&md_event_count);
41896 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41897 return 0;
41898 }
41899 if (v == (void*)2) {
41900 @@ -7145,7 +7145,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
41901 return error;
41902
41903 seq = file->private_data;
41904 - seq->poll_event = atomic_read(&md_event_count);
41905 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41906 return error;
41907 }
41908
41909 @@ -7159,7 +7159,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
41910 /* always allow read */
41911 mask = POLLIN | POLLRDNORM;
41912
41913 - if (seq->poll_event != atomic_read(&md_event_count))
41914 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
41915 mask |= POLLERR | POLLPRI;
41916 return mask;
41917 }
41918 @@ -7203,7 +7203,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
41919 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
41920 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
41921 (int)part_stat_read(&disk->part0, sectors[1]) -
41922 - atomic_read(&disk->sync_io);
41923 + atomic_read_unchecked(&disk->sync_io);
41924 /* sync IO will cause sync_io to increase before the disk_stats
41925 * as sync_io is counted when a request starts, and
41926 * disk_stats is counted when it completes.
41927 diff --git a/drivers/md/md.h b/drivers/md/md.h
41928 index 608050c..6e77db5d 100644
41929 --- a/drivers/md/md.h
41930 +++ b/drivers/md/md.h
41931 @@ -94,13 +94,13 @@ struct md_rdev {
41932 * only maintained for arrays that
41933 * support hot removal
41934 */
41935 - atomic_t read_errors; /* number of consecutive read errors that
41936 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
41937 * we have tried to ignore.
41938 */
41939 struct timespec last_read_error; /* monotonic time since our
41940 * last read error
41941 */
41942 - atomic_t corrected_errors; /* number of corrected read errors,
41943 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
41944 * for reporting to userspace and storing
41945 * in superblock.
41946 */
41947 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
41948
41949 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
41950 {
41951 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
41952 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
41953 }
41954
41955 struct md_personality
41956 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
41957 index 3e6d115..ffecdeb 100644
41958 --- a/drivers/md/persistent-data/dm-space-map.h
41959 +++ b/drivers/md/persistent-data/dm-space-map.h
41960 @@ -71,6 +71,7 @@ struct dm_space_map {
41961 dm_sm_threshold_fn fn,
41962 void *context);
41963 };
41964 +typedef struct dm_space_map __no_const dm_space_map_no_const;
41965
41966 /*----------------------------------------------------------------*/
41967
41968 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
41969 index aacf6bf..67d63f2 100644
41970 --- a/drivers/md/raid1.c
41971 +++ b/drivers/md/raid1.c
41972 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
41973 if (r1_sync_page_io(rdev, sect, s,
41974 bio->bi_io_vec[idx].bv_page,
41975 READ) != 0)
41976 - atomic_add(s, &rdev->corrected_errors);
41977 + atomic_add_unchecked(s, &rdev->corrected_errors);
41978 }
41979 sectors -= s;
41980 sect += s;
41981 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
41982 test_bit(In_sync, &rdev->flags)) {
41983 if (r1_sync_page_io(rdev, sect, s,
41984 conf->tmppage, READ)) {
41985 - atomic_add(s, &rdev->corrected_errors);
41986 + atomic_add_unchecked(s, &rdev->corrected_errors);
41987 printk(KERN_INFO
41988 "md/raid1:%s: read error corrected "
41989 "(%d sectors at %llu on %s)\n",
41990 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
41991 index 73dc8a3..bdd515a 100644
41992 --- a/drivers/md/raid10.c
41993 +++ b/drivers/md/raid10.c
41994 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
41995 /* The write handler will notice the lack of
41996 * R10BIO_Uptodate and record any errors etc
41997 */
41998 - atomic_add(r10_bio->sectors,
41999 + atomic_add_unchecked(r10_bio->sectors,
42000 &conf->mirrors[d].rdev->corrected_errors);
42001
42002 /* for reconstruct, we always reschedule after a read.
42003 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42004 {
42005 struct timespec cur_time_mon;
42006 unsigned long hours_since_last;
42007 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42008 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42009
42010 ktime_get_ts(&cur_time_mon);
42011
42012 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42013 * overflowing the shift of read_errors by hours_since_last.
42014 */
42015 if (hours_since_last >= 8 * sizeof(read_errors))
42016 - atomic_set(&rdev->read_errors, 0);
42017 + atomic_set_unchecked(&rdev->read_errors, 0);
42018 else
42019 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42020 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42021 }
42022
42023 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42024 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42025 return;
42026
42027 check_decay_read_errors(mddev, rdev);
42028 - atomic_inc(&rdev->read_errors);
42029 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42030 + atomic_inc_unchecked(&rdev->read_errors);
42031 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42032 char b[BDEVNAME_SIZE];
42033 bdevname(rdev->bdev, b);
42034
42035 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42036 "md/raid10:%s: %s: Raid device exceeded "
42037 "read_error threshold [cur %d:max %d]\n",
42038 mdname(mddev), b,
42039 - atomic_read(&rdev->read_errors), max_read_errors);
42040 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42041 printk(KERN_NOTICE
42042 "md/raid10:%s: %s: Failing raid device\n",
42043 mdname(mddev), b);
42044 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42045 sect +
42046 choose_data_offset(r10_bio, rdev)),
42047 bdevname(rdev->bdev, b));
42048 - atomic_add(s, &rdev->corrected_errors);
42049 + atomic_add_unchecked(s, &rdev->corrected_errors);
42050 }
42051
42052 rdev_dec_pending(rdev, mddev);
42053 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42054 index f8b9068..7a2b9fc 100644
42055 --- a/drivers/md/raid5.c
42056 +++ b/drivers/md/raid5.c
42057 @@ -1886,21 +1886,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42058 mdname(conf->mddev), STRIPE_SECTORS,
42059 (unsigned long long)s,
42060 bdevname(rdev->bdev, b));
42061 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42062 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42063 clear_bit(R5_ReadError, &sh->dev[i].flags);
42064 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42065 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42066 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42067
42068 - if (atomic_read(&rdev->read_errors))
42069 - atomic_set(&rdev->read_errors, 0);
42070 + if (atomic_read_unchecked(&rdev->read_errors))
42071 + atomic_set_unchecked(&rdev->read_errors, 0);
42072 } else {
42073 const char *bdn = bdevname(rdev->bdev, b);
42074 int retry = 0;
42075 int set_bad = 0;
42076
42077 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42078 - atomic_inc(&rdev->read_errors);
42079 + atomic_inc_unchecked(&rdev->read_errors);
42080 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42081 printk_ratelimited(
42082 KERN_WARNING
42083 @@ -1928,7 +1928,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42084 mdname(conf->mddev),
42085 (unsigned long long)s,
42086 bdn);
42087 - } else if (atomic_read(&rdev->read_errors)
42088 + } else if (atomic_read_unchecked(&rdev->read_errors)
42089 > conf->max_nr_stripes)
42090 printk(KERN_WARNING
42091 "md/raid:%s: Too many read errors, failing device %s.\n",
42092 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42093 index 401ef64..836e563 100644
42094 --- a/drivers/media/dvb-core/dvbdev.c
42095 +++ b/drivers/media/dvb-core/dvbdev.c
42096 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42097 const struct dvb_device *template, void *priv, int type)
42098 {
42099 struct dvb_device *dvbdev;
42100 - struct file_operations *dvbdevfops;
42101 + file_operations_no_const *dvbdevfops;
42102 struct device *clsdev;
42103 int minor;
42104 int id;
42105 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42106 index 9b6c3bb..baeb5c7 100644
42107 --- a/drivers/media/dvb-frontends/dib3000.h
42108 +++ b/drivers/media/dvb-frontends/dib3000.h
42109 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42110 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42111 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42112 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42113 -};
42114 +} __no_const;
42115
42116 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42117 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42118 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42119 index ecf21d9..b992428d 100644
42120 --- a/drivers/media/pci/cx88/cx88-video.c
42121 +++ b/drivers/media/pci/cx88/cx88-video.c
42122 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42123
42124 /* ------------------------------------------------------------------ */
42125
42126 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42127 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42128 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42129 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42130 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42131 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42132
42133 module_param_array(video_nr, int, NULL, 0444);
42134 module_param_array(vbi_nr, int, NULL, 0444);
42135 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42136 index c08ae3e..eb59af1 100644
42137 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42138 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42139 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42140 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42141
42142 /* ivtv instance counter */
42143 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42144 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42145
42146 /* Parameter declarations */
42147 static int cardtype[IVTV_MAX_CARDS];
42148 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42149 index dfd0a21..6bbb465 100644
42150 --- a/drivers/media/platform/omap/omap_vout.c
42151 +++ b/drivers/media/platform/omap/omap_vout.c
42152 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42153 OMAP_VIDEO2,
42154 };
42155
42156 -static struct videobuf_queue_ops video_vbq_ops;
42157 /* Variables configurable through module params*/
42158 static u32 video1_numbuffers = 3;
42159 static u32 video2_numbuffers = 3;
42160 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42161 {
42162 struct videobuf_queue *q;
42163 struct omap_vout_device *vout = NULL;
42164 + static struct videobuf_queue_ops video_vbq_ops = {
42165 + .buf_setup = omap_vout_buffer_setup,
42166 + .buf_prepare = omap_vout_buffer_prepare,
42167 + .buf_release = omap_vout_buffer_release,
42168 + .buf_queue = omap_vout_buffer_queue,
42169 + };
42170
42171 vout = video_drvdata(file);
42172 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42173 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42174 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42175
42176 q = &vout->vbq;
42177 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42178 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42179 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42180 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42181 spin_lock_init(&vout->vbq_lock);
42182
42183 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42184 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42185 index 04e6490..2df65bf 100644
42186 --- a/drivers/media/platform/s5p-tv/mixer.h
42187 +++ b/drivers/media/platform/s5p-tv/mixer.h
42188 @@ -156,7 +156,7 @@ struct mxr_layer {
42189 /** layer index (unique identifier) */
42190 int idx;
42191 /** callbacks for layer methods */
42192 - struct mxr_layer_ops ops;
42193 + struct mxr_layer_ops *ops;
42194 /** format array */
42195 const struct mxr_format **fmt_array;
42196 /** size of format array */
42197 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42198 index b93a21f..2535195 100644
42199 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42200 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42201 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42202 {
42203 struct mxr_layer *layer;
42204 int ret;
42205 - struct mxr_layer_ops ops = {
42206 + static struct mxr_layer_ops ops = {
42207 .release = mxr_graph_layer_release,
42208 .buffer_set = mxr_graph_buffer_set,
42209 .stream_set = mxr_graph_stream_set,
42210 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42211 index b713403..53cb5ad 100644
42212 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42213 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42214 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42215 layer->update_buf = next;
42216 }
42217
42218 - layer->ops.buffer_set(layer, layer->update_buf);
42219 + layer->ops->buffer_set(layer, layer->update_buf);
42220
42221 if (done && done != layer->shadow_buf)
42222 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42223 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42224 index 641b1f0..49cff30 100644
42225 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42226 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42227 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42228 layer->geo.src.height = layer->geo.src.full_height;
42229
42230 mxr_geometry_dump(mdev, &layer->geo);
42231 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42232 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42233 mxr_geometry_dump(mdev, &layer->geo);
42234 }
42235
42236 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42237 layer->geo.dst.full_width = mbus_fmt.width;
42238 layer->geo.dst.full_height = mbus_fmt.height;
42239 layer->geo.dst.field = mbus_fmt.field;
42240 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42241 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42242
42243 mxr_geometry_dump(mdev, &layer->geo);
42244 }
42245 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42246 /* set source size to highest accepted value */
42247 geo->src.full_width = max(geo->dst.full_width, pix->width);
42248 geo->src.full_height = max(geo->dst.full_height, pix->height);
42249 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42250 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42251 mxr_geometry_dump(mdev, &layer->geo);
42252 /* set cropping to total visible screen */
42253 geo->src.width = pix->width;
42254 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42255 geo->src.x_offset = 0;
42256 geo->src.y_offset = 0;
42257 /* assure consistency of geometry */
42258 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42259 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42260 mxr_geometry_dump(mdev, &layer->geo);
42261 /* set full size to lowest possible value */
42262 geo->src.full_width = 0;
42263 geo->src.full_height = 0;
42264 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42265 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42266 mxr_geometry_dump(mdev, &layer->geo);
42267
42268 /* returning results */
42269 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42270 target->width = s->r.width;
42271 target->height = s->r.height;
42272
42273 - layer->ops.fix_geometry(layer, stage, s->flags);
42274 + layer->ops->fix_geometry(layer, stage, s->flags);
42275
42276 /* retrieve update selection rectangle */
42277 res.left = target->x_offset;
42278 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42279 mxr_output_get(mdev);
42280
42281 mxr_layer_update_output(layer);
42282 - layer->ops.format_set(layer);
42283 + layer->ops->format_set(layer);
42284 /* enabling layer in hardware */
42285 spin_lock_irqsave(&layer->enq_slock, flags);
42286 layer->state = MXR_LAYER_STREAMING;
42287 spin_unlock_irqrestore(&layer->enq_slock, flags);
42288
42289 - layer->ops.stream_set(layer, MXR_ENABLE);
42290 + layer->ops->stream_set(layer, MXR_ENABLE);
42291 mxr_streamer_get(mdev);
42292
42293 return 0;
42294 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42295 spin_unlock_irqrestore(&layer->enq_slock, flags);
42296
42297 /* disabling layer in hardware */
42298 - layer->ops.stream_set(layer, MXR_DISABLE);
42299 + layer->ops->stream_set(layer, MXR_DISABLE);
42300 /* remove one streamer */
42301 mxr_streamer_put(mdev);
42302 /* allow changes in output configuration */
42303 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42304
42305 void mxr_layer_release(struct mxr_layer *layer)
42306 {
42307 - if (layer->ops.release)
42308 - layer->ops.release(layer);
42309 + if (layer->ops->release)
42310 + layer->ops->release(layer);
42311 }
42312
42313 void mxr_base_layer_release(struct mxr_layer *layer)
42314 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42315
42316 layer->mdev = mdev;
42317 layer->idx = idx;
42318 - layer->ops = *ops;
42319 + layer->ops = ops;
42320
42321 spin_lock_init(&layer->enq_slock);
42322 INIT_LIST_HEAD(&layer->enq_list);
42323 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42324 index 3d13a63..da31bf1 100644
42325 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42326 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42327 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42328 {
42329 struct mxr_layer *layer;
42330 int ret;
42331 - struct mxr_layer_ops ops = {
42332 + static struct mxr_layer_ops ops = {
42333 .release = mxr_vp_layer_release,
42334 .buffer_set = mxr_vp_buffer_set,
42335 .stream_set = mxr_vp_stream_set,
42336 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42337 index 545c04c..a14bded 100644
42338 --- a/drivers/media/radio/radio-cadet.c
42339 +++ b/drivers/media/radio/radio-cadet.c
42340 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42341 unsigned char readbuf[RDS_BUFFER];
42342 int i = 0;
42343
42344 + if (count > RDS_BUFFER)
42345 + return -EFAULT;
42346 mutex_lock(&dev->lock);
42347 if (dev->rdsstat == 0)
42348 cadet_start_rds(dev);
42349 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42350 while (i < count && dev->rdsin != dev->rdsout)
42351 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42352
42353 - if (i && copy_to_user(data, readbuf, i))
42354 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42355 i = -EFAULT;
42356 unlock:
42357 mutex_unlock(&dev->lock);
42358 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42359 index 5236035..c622c74 100644
42360 --- a/drivers/media/radio/radio-maxiradio.c
42361 +++ b/drivers/media/radio/radio-maxiradio.c
42362 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42363 /* TEA5757 pin mappings */
42364 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42365
42366 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42367 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42368
42369 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42370 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42371 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42372 index b914772..7ddbf9b 100644
42373 --- a/drivers/media/radio/radio-shark.c
42374 +++ b/drivers/media/radio/radio-shark.c
42375 @@ -79,7 +79,7 @@ struct shark_device {
42376 u32 last_val;
42377 };
42378
42379 -static atomic_t shark_instance = ATOMIC_INIT(0);
42380 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42381
42382 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42383 {
42384 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42385 index 9fb6697..f167415 100644
42386 --- a/drivers/media/radio/radio-shark2.c
42387 +++ b/drivers/media/radio/radio-shark2.c
42388 @@ -74,7 +74,7 @@ struct shark_device {
42389 u8 *transfer_buffer;
42390 };
42391
42392 -static atomic_t shark_instance = ATOMIC_INIT(0);
42393 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42394
42395 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42396 {
42397 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42398 index 9c9084c..a9e8dfb 100644
42399 --- a/drivers/media/radio/radio-si476x.c
42400 +++ b/drivers/media/radio/radio-si476x.c
42401 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42402 struct si476x_radio *radio;
42403 struct v4l2_ctrl *ctrl;
42404
42405 - static atomic_t instance = ATOMIC_INIT(0);
42406 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42407
42408 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42409 if (!radio)
42410 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42411 index 46da365..3ba4206 100644
42412 --- a/drivers/media/rc/rc-main.c
42413 +++ b/drivers/media/rc/rc-main.c
42414 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42415 int rc_register_device(struct rc_dev *dev)
42416 {
42417 static bool raw_init = false; /* raw decoders loaded? */
42418 - static atomic_t devno = ATOMIC_INIT(0);
42419 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42420 struct rc_map *rc_map;
42421 const char *path;
42422 int rc;
42423 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
42424 */
42425 mutex_lock(&dev->lock);
42426
42427 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42428 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42429 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42430 dev_set_drvdata(&dev->dev, dev);
42431 rc = device_add(&dev->dev);
42432 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42433 index 3940bb0..fb3952a 100644
42434 --- a/drivers/media/usb/dvb-usb/cxusb.c
42435 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42436 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42437
42438 struct dib0700_adapter_state {
42439 int (*set_param_save) (struct dvb_frontend *);
42440 -};
42441 +} __no_const;
42442
42443 static int dib7070_set_param_override(struct dvb_frontend *fe)
42444 {
42445 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42446 index 6e237b6..dc25556 100644
42447 --- a/drivers/media/usb/dvb-usb/dw2102.c
42448 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42449 @@ -118,7 +118,7 @@ struct su3000_state {
42450
42451 struct s6x0_state {
42452 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42453 -};
42454 +} __no_const;
42455
42456 /* debug */
42457 static int dvb_usb_dw2102_debug;
42458 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42459 index 8f7a6a4..59502dd 100644
42460 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42461 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42462 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42463 __u32 reserved;
42464 };
42465
42466 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42467 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42468 enum v4l2_memory memory)
42469 {
42470 void __user *up_pln;
42471 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42472 return 0;
42473 }
42474
42475 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42476 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42477 enum v4l2_memory memory)
42478 {
42479 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42480 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42481 put_user(kp->start_block, &up->start_block) ||
42482 put_user(kp->blocks, &up->blocks) ||
42483 put_user(tmp, &up->edid) ||
42484 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42485 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42486 return -EFAULT;
42487 return 0;
42488 }
42489 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42490 index 02d1b63..5fd6b16 100644
42491 --- a/drivers/media/v4l2-core/v4l2-device.c
42492 +++ b/drivers/media/v4l2-core/v4l2-device.c
42493 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42494 EXPORT_SYMBOL_GPL(v4l2_device_put);
42495
42496 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42497 - atomic_t *instance)
42498 + atomic_unchecked_t *instance)
42499 {
42500 - int num = atomic_inc_return(instance) - 1;
42501 + int num = atomic_inc_return_unchecked(instance) - 1;
42502 int len = strlen(basename);
42503
42504 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42505 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42506 index 68e6b5e..d8b923e 100644
42507 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42508 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42509 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42510 struct file *file, void *fh, void *p);
42511 } u;
42512 void (*debug)(const void *arg, bool write_only);
42513 -};
42514 +} __do_const;
42515 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42516
42517 /* This control needs a priority check */
42518 #define INFO_FL_PRIO (1 << 0)
42519 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42520 struct video_device *vfd = video_devdata(file);
42521 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42522 bool write_only = false;
42523 - struct v4l2_ioctl_info default_info;
42524 + v4l2_ioctl_info_no_const default_info;
42525 const struct v4l2_ioctl_info *info;
42526 void *fh = file->private_data;
42527 struct v4l2_fh *vfh = NULL;
42528 @@ -2194,7 +2195,7 @@ done:
42529 }
42530
42531 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42532 - void * __user *user_ptr, void ***kernel_ptr)
42533 + void __user **user_ptr, void ***kernel_ptr)
42534 {
42535 int ret = 0;
42536
42537 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42538 ret = -EINVAL;
42539 break;
42540 }
42541 - *user_ptr = (void __user *)buf->m.planes;
42542 + *user_ptr = (void __force_user *)buf->m.planes;
42543 *kernel_ptr = (void *)&buf->m.planes;
42544 *array_size = sizeof(struct v4l2_plane) * buf->length;
42545 ret = 1;
42546 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42547 ret = -EINVAL;
42548 break;
42549 }
42550 - *user_ptr = (void __user *)ctrls->controls;
42551 + *user_ptr = (void __force_user *)ctrls->controls;
42552 *kernel_ptr = (void *)&ctrls->controls;
42553 *array_size = sizeof(struct v4l2_ext_control)
42554 * ctrls->count;
42555 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42556 index 767ff4d..c69d259 100644
42557 --- a/drivers/message/fusion/mptbase.c
42558 +++ b/drivers/message/fusion/mptbase.c
42559 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42560 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42561 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42562
42563 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42564 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42565 +#else
42566 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42567 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42568 +#endif
42569 +
42570 /*
42571 * Rounding UP to nearest 4-kB boundary here...
42572 */
42573 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42574 ioc->facts.GlobalCredits);
42575
42576 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42577 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42578 + NULL, NULL);
42579 +#else
42580 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42581 +#endif
42582 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42583 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42584 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42585 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42586 index dd239bd..689c4f7 100644
42587 --- a/drivers/message/fusion/mptsas.c
42588 +++ b/drivers/message/fusion/mptsas.c
42589 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42590 return 0;
42591 }
42592
42593 +static inline void
42594 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42595 +{
42596 + if (phy_info->port_details) {
42597 + phy_info->port_details->rphy = rphy;
42598 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42599 + ioc->name, rphy));
42600 + }
42601 +
42602 + if (rphy) {
42603 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42604 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42605 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42606 + ioc->name, rphy, rphy->dev.release));
42607 + }
42608 +}
42609 +
42610 /* no mutex */
42611 static void
42612 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42613 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42614 return NULL;
42615 }
42616
42617 -static inline void
42618 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42619 -{
42620 - if (phy_info->port_details) {
42621 - phy_info->port_details->rphy = rphy;
42622 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42623 - ioc->name, rphy));
42624 - }
42625 -
42626 - if (rphy) {
42627 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42628 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42629 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42630 - ioc->name, rphy, rphy->dev.release));
42631 - }
42632 -}
42633 -
42634 static inline struct sas_port *
42635 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42636 {
42637 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42638 index 727819c..ad74694 100644
42639 --- a/drivers/message/fusion/mptscsih.c
42640 +++ b/drivers/message/fusion/mptscsih.c
42641 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42642
42643 h = shost_priv(SChost);
42644
42645 - if (h) {
42646 - if (h->info_kbuf == NULL)
42647 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42648 - return h->info_kbuf;
42649 - h->info_kbuf[0] = '\0';
42650 + if (!h)
42651 + return NULL;
42652
42653 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42654 - h->info_kbuf[size-1] = '\0';
42655 - }
42656 + if (h->info_kbuf == NULL)
42657 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42658 + return h->info_kbuf;
42659 + h->info_kbuf[0] = '\0';
42660 +
42661 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42662 + h->info_kbuf[size-1] = '\0';
42663
42664 return h->info_kbuf;
42665 }
42666 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
42667 index b7d87cd..3fb36da 100644
42668 --- a/drivers/message/i2o/i2o_proc.c
42669 +++ b/drivers/message/i2o/i2o_proc.c
42670 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
42671 "Array Controller Device"
42672 };
42673
42674 -static char *chtostr(char *tmp, u8 *chars, int n)
42675 -{
42676 - tmp[0] = 0;
42677 - return strncat(tmp, (char *)chars, n);
42678 -}
42679 -
42680 static int i2o_report_query_status(struct seq_file *seq, int block_status,
42681 char *group)
42682 {
42683 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
42684 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
42685 {
42686 struct i2o_controller *c = (struct i2o_controller *)seq->private;
42687 - static u32 work32[5];
42688 - static u8 *work8 = (u8 *) work32;
42689 - static u16 *work16 = (u16 *) work32;
42690 + u32 work32[5];
42691 + u8 *work8 = (u8 *) work32;
42692 + u16 *work16 = (u16 *) work32;
42693 int token;
42694 u32 hwcap;
42695
42696 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42697 } *result;
42698
42699 i2o_exec_execute_ddm_table ddm_table;
42700 - char tmp[28 + 1];
42701
42702 result = kmalloc(sizeof(*result), GFP_KERNEL);
42703 if (!result)
42704 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42705
42706 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
42707 seq_printf(seq, "%-#8x", ddm_table.module_id);
42708 - seq_printf(seq, "%-29s",
42709 - chtostr(tmp, ddm_table.module_name_version, 28));
42710 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
42711 seq_printf(seq, "%9d ", ddm_table.data_size);
42712 seq_printf(seq, "%8d", ddm_table.code_size);
42713
42714 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42715
42716 i2o_driver_result_table *result;
42717 i2o_driver_store_table *dst;
42718 - char tmp[28 + 1];
42719
42720 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
42721 if (result == NULL)
42722 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42723
42724 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
42725 seq_printf(seq, "%-#8x", dst->module_id);
42726 - seq_printf(seq, "%-29s",
42727 - chtostr(tmp, dst->module_name_version, 28));
42728 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
42729 + seq_printf(seq, "%-.28s", dst->module_name_version);
42730 + seq_printf(seq, "%-.8s", dst->date);
42731 seq_printf(seq, "%8d ", dst->module_size);
42732 seq_printf(seq, "%8d ", dst->mpb_size);
42733 seq_printf(seq, "0x%04x", dst->module_flags);
42734 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
42735 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42736 {
42737 struct i2o_device *d = (struct i2o_device *)seq->private;
42738 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42739 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42740 // == (allow) 512d bytes (max)
42741 - static u16 *work16 = (u16 *) work32;
42742 + u16 *work16 = (u16 *) work32;
42743 int token;
42744 - char tmp[16 + 1];
42745
42746 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
42747
42748 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42749 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
42750 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
42751 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
42752 - seq_printf(seq, "Vendor info : %s\n",
42753 - chtostr(tmp, (u8 *) (work32 + 2), 16));
42754 - seq_printf(seq, "Product info : %s\n",
42755 - chtostr(tmp, (u8 *) (work32 + 6), 16));
42756 - seq_printf(seq, "Description : %s\n",
42757 - chtostr(tmp, (u8 *) (work32 + 10), 16));
42758 - seq_printf(seq, "Product rev. : %s\n",
42759 - chtostr(tmp, (u8 *) (work32 + 14), 8));
42760 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
42761 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
42762 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
42763 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
42764
42765 seq_printf(seq, "Serial number : ");
42766 print_serial_number(seq, (u8 *) (work32 + 16),
42767 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42768 u8 pad[256]; // allow up to 256 byte (max) serial number
42769 } result;
42770
42771 - char tmp[24 + 1];
42772 -
42773 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
42774
42775 if (token < 0) {
42776 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42777 }
42778
42779 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
42780 - seq_printf(seq, "Module name : %s\n",
42781 - chtostr(tmp, result.module_name, 24));
42782 - seq_printf(seq, "Module revision : %s\n",
42783 - chtostr(tmp, result.module_rev, 8));
42784 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
42785 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
42786
42787 seq_printf(seq, "Serial number : ");
42788 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
42789 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42790 u8 instance_number[4];
42791 } result;
42792
42793 - char tmp[64 + 1];
42794 -
42795 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
42796
42797 if (token < 0) {
42798 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42799 return 0;
42800 }
42801
42802 - seq_printf(seq, "Device name : %s\n",
42803 - chtostr(tmp, result.device_name, 64));
42804 - seq_printf(seq, "Service name : %s\n",
42805 - chtostr(tmp, result.service_name, 64));
42806 - seq_printf(seq, "Physical name : %s\n",
42807 - chtostr(tmp, result.physical_location, 64));
42808 - seq_printf(seq, "Instance number : %s\n",
42809 - chtostr(tmp, result.instance_number, 4));
42810 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
42811 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
42812 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
42813 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
42814
42815 return 0;
42816 }
42817 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42818 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
42819 {
42820 struct i2o_device *d = (struct i2o_device *)seq->private;
42821 - static u32 work32[12];
42822 - static u16 *work16 = (u16 *) work32;
42823 - static u8 *work8 = (u8 *) work32;
42824 + u32 work32[12];
42825 + u16 *work16 = (u16 *) work32;
42826 + u8 *work8 = (u8 *) work32;
42827 int token;
42828
42829 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
42830 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
42831 index a8c08f3..155fe3d 100644
42832 --- a/drivers/message/i2o/iop.c
42833 +++ b/drivers/message/i2o/iop.c
42834 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
42835
42836 spin_lock_irqsave(&c->context_list_lock, flags);
42837
42838 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
42839 - atomic_inc(&c->context_list_counter);
42840 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
42841 + atomic_inc_unchecked(&c->context_list_counter);
42842
42843 - entry->context = atomic_read(&c->context_list_counter);
42844 + entry->context = atomic_read_unchecked(&c->context_list_counter);
42845
42846 list_add(&entry->list, &c->context_list);
42847
42848 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
42849
42850 #if BITS_PER_LONG == 64
42851 spin_lock_init(&c->context_list_lock);
42852 - atomic_set(&c->context_list_counter, 0);
42853 + atomic_set_unchecked(&c->context_list_counter, 0);
42854 INIT_LIST_HEAD(&c->context_list);
42855 #endif
42856
42857 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
42858 index fcbb2e9..2635e11 100644
42859 --- a/drivers/mfd/janz-cmodio.c
42860 +++ b/drivers/mfd/janz-cmodio.c
42861 @@ -13,6 +13,7 @@
42862
42863 #include <linux/kernel.h>
42864 #include <linux/module.h>
42865 +#include <linux/slab.h>
42866 #include <linux/init.h>
42867 #include <linux/pci.h>
42868 #include <linux/interrupt.h>
42869 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
42870 index de7fb80..7c1b931 100644
42871 --- a/drivers/mfd/max8925-i2c.c
42872 +++ b/drivers/mfd/max8925-i2c.c
42873 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
42874 const struct i2c_device_id *id)
42875 {
42876 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
42877 - static struct max8925_chip *chip;
42878 + struct max8925_chip *chip;
42879 struct device_node *node = client->dev.of_node;
42880
42881 if (node && !pdata) {
42882 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
42883 index d792772..cd73ba3 100644
42884 --- a/drivers/mfd/tps65910.c
42885 +++ b/drivers/mfd/tps65910.c
42886 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
42887 struct tps65910_platform_data *pdata)
42888 {
42889 int ret = 0;
42890 - static struct regmap_irq_chip *tps6591x_irqs_chip;
42891 + struct regmap_irq_chip *tps6591x_irqs_chip;
42892
42893 if (!irq) {
42894 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
42895 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
42896 index 9aa6d1e..1631bfc 100644
42897 --- a/drivers/mfd/twl4030-irq.c
42898 +++ b/drivers/mfd/twl4030-irq.c
42899 @@ -35,6 +35,7 @@
42900 #include <linux/of.h>
42901 #include <linux/irqdomain.h>
42902 #include <linux/i2c/twl.h>
42903 +#include <asm/pgtable.h>
42904
42905 #include "twl-core.h"
42906
42907 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
42908 * Install an irq handler for each of the SIH modules;
42909 * clone dummy irq_chip since PIH can't *do* anything
42910 */
42911 - twl4030_irq_chip = dummy_irq_chip;
42912 - twl4030_irq_chip.name = "twl4030";
42913 + pax_open_kernel();
42914 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
42915 + *(const char **)&twl4030_irq_chip.name = "twl4030";
42916
42917 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42918 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42919 + pax_close_kernel();
42920
42921 for (i = irq_base; i < irq_end; i++) {
42922 irq_set_chip_and_handler(i, &twl4030_irq_chip,
42923 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
42924 index 464419b..64bae8d 100644
42925 --- a/drivers/misc/c2port/core.c
42926 +++ b/drivers/misc/c2port/core.c
42927 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
42928 goto error_idr_alloc;
42929 c2dev->id = ret;
42930
42931 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
42932 + pax_open_kernel();
42933 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
42934 + pax_close_kernel();
42935
42936 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
42937 "c2port%d", c2dev->id);
42938 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
42939 index 36f5d52..32311c3 100644
42940 --- a/drivers/misc/kgdbts.c
42941 +++ b/drivers/misc/kgdbts.c
42942 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
42943 char before[BREAK_INSTR_SIZE];
42944 char after[BREAK_INSTR_SIZE];
42945
42946 - probe_kernel_read(before, (char *)kgdbts_break_test,
42947 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
42948 BREAK_INSTR_SIZE);
42949 init_simple_test();
42950 ts.tst = plant_and_detach_test;
42951 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
42952 /* Activate test with initial breakpoint */
42953 if (!is_early)
42954 kgdb_breakpoint();
42955 - probe_kernel_read(after, (char *)kgdbts_break_test,
42956 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
42957 BREAK_INSTR_SIZE);
42958 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
42959 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
42960 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
42961 index 036effe..b3a6336 100644
42962 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
42963 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
42964 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
42965 * the lid is closed. This leads to interrupts as soon as a little move
42966 * is done.
42967 */
42968 - atomic_inc(&lis3->count);
42969 + atomic_inc_unchecked(&lis3->count);
42970
42971 wake_up_interruptible(&lis3->misc_wait);
42972 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
42973 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
42974 if (lis3->pm_dev)
42975 pm_runtime_get_sync(lis3->pm_dev);
42976
42977 - atomic_set(&lis3->count, 0);
42978 + atomic_set_unchecked(&lis3->count, 0);
42979 return 0;
42980 }
42981
42982 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
42983 add_wait_queue(&lis3->misc_wait, &wait);
42984 while (true) {
42985 set_current_state(TASK_INTERRUPTIBLE);
42986 - data = atomic_xchg(&lis3->count, 0);
42987 + data = atomic_xchg_unchecked(&lis3->count, 0);
42988 if (data)
42989 break;
42990
42991 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
42992 struct lis3lv02d, miscdev);
42993
42994 poll_wait(file, &lis3->misc_wait, wait);
42995 - if (atomic_read(&lis3->count))
42996 + if (atomic_read_unchecked(&lis3->count))
42997 return POLLIN | POLLRDNORM;
42998 return 0;
42999 }
43000 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43001 index c439c82..1f20f57 100644
43002 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43003 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43004 @@ -297,7 +297,7 @@ struct lis3lv02d {
43005 struct input_polled_dev *idev; /* input device */
43006 struct platform_device *pdev; /* platform device */
43007 struct regulator_bulk_data regulators[2];
43008 - atomic_t count; /* interrupt count after last read */
43009 + atomic_unchecked_t count; /* interrupt count after last read */
43010 union axis_conversion ac; /* hw -> logical axis */
43011 int mapped_btns[3];
43012
43013 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43014 index 2f30bad..c4c13d0 100644
43015 --- a/drivers/misc/sgi-gru/gruhandles.c
43016 +++ b/drivers/misc/sgi-gru/gruhandles.c
43017 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43018 unsigned long nsec;
43019
43020 nsec = CLKS2NSEC(clks);
43021 - atomic_long_inc(&mcs_op_statistics[op].count);
43022 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43023 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43024 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43025 if (mcs_op_statistics[op].max < nsec)
43026 mcs_op_statistics[op].max = nsec;
43027 }
43028 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43029 index 4f76359..cdfcb2e 100644
43030 --- a/drivers/misc/sgi-gru/gruprocfs.c
43031 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43032 @@ -32,9 +32,9 @@
43033
43034 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43035
43036 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43037 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43038 {
43039 - unsigned long val = atomic_long_read(v);
43040 + unsigned long val = atomic_long_read_unchecked(v);
43041
43042 seq_printf(s, "%16lu %s\n", val, id);
43043 }
43044 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43045
43046 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43047 for (op = 0; op < mcsop_last; op++) {
43048 - count = atomic_long_read(&mcs_op_statistics[op].count);
43049 - total = atomic_long_read(&mcs_op_statistics[op].total);
43050 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43051 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43052 max = mcs_op_statistics[op].max;
43053 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43054 count ? total / count : 0, max);
43055 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43056 index 5c3ce24..4915ccb 100644
43057 --- a/drivers/misc/sgi-gru/grutables.h
43058 +++ b/drivers/misc/sgi-gru/grutables.h
43059 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43060 * GRU statistics.
43061 */
43062 struct gru_stats_s {
43063 - atomic_long_t vdata_alloc;
43064 - atomic_long_t vdata_free;
43065 - atomic_long_t gts_alloc;
43066 - atomic_long_t gts_free;
43067 - atomic_long_t gms_alloc;
43068 - atomic_long_t gms_free;
43069 - atomic_long_t gts_double_allocate;
43070 - atomic_long_t assign_context;
43071 - atomic_long_t assign_context_failed;
43072 - atomic_long_t free_context;
43073 - atomic_long_t load_user_context;
43074 - atomic_long_t load_kernel_context;
43075 - atomic_long_t lock_kernel_context;
43076 - atomic_long_t unlock_kernel_context;
43077 - atomic_long_t steal_user_context;
43078 - atomic_long_t steal_kernel_context;
43079 - atomic_long_t steal_context_failed;
43080 - atomic_long_t nopfn;
43081 - atomic_long_t asid_new;
43082 - atomic_long_t asid_next;
43083 - atomic_long_t asid_wrap;
43084 - atomic_long_t asid_reuse;
43085 - atomic_long_t intr;
43086 - atomic_long_t intr_cbr;
43087 - atomic_long_t intr_tfh;
43088 - atomic_long_t intr_spurious;
43089 - atomic_long_t intr_mm_lock_failed;
43090 - atomic_long_t call_os;
43091 - atomic_long_t call_os_wait_queue;
43092 - atomic_long_t user_flush_tlb;
43093 - atomic_long_t user_unload_context;
43094 - atomic_long_t user_exception;
43095 - atomic_long_t set_context_option;
43096 - atomic_long_t check_context_retarget_intr;
43097 - atomic_long_t check_context_unload;
43098 - atomic_long_t tlb_dropin;
43099 - atomic_long_t tlb_preload_page;
43100 - atomic_long_t tlb_dropin_fail_no_asid;
43101 - atomic_long_t tlb_dropin_fail_upm;
43102 - atomic_long_t tlb_dropin_fail_invalid;
43103 - atomic_long_t tlb_dropin_fail_range_active;
43104 - atomic_long_t tlb_dropin_fail_idle;
43105 - atomic_long_t tlb_dropin_fail_fmm;
43106 - atomic_long_t tlb_dropin_fail_no_exception;
43107 - atomic_long_t tfh_stale_on_fault;
43108 - atomic_long_t mmu_invalidate_range;
43109 - atomic_long_t mmu_invalidate_page;
43110 - atomic_long_t flush_tlb;
43111 - atomic_long_t flush_tlb_gru;
43112 - atomic_long_t flush_tlb_gru_tgh;
43113 - atomic_long_t flush_tlb_gru_zero_asid;
43114 + atomic_long_unchecked_t vdata_alloc;
43115 + atomic_long_unchecked_t vdata_free;
43116 + atomic_long_unchecked_t gts_alloc;
43117 + atomic_long_unchecked_t gts_free;
43118 + atomic_long_unchecked_t gms_alloc;
43119 + atomic_long_unchecked_t gms_free;
43120 + atomic_long_unchecked_t gts_double_allocate;
43121 + atomic_long_unchecked_t assign_context;
43122 + atomic_long_unchecked_t assign_context_failed;
43123 + atomic_long_unchecked_t free_context;
43124 + atomic_long_unchecked_t load_user_context;
43125 + atomic_long_unchecked_t load_kernel_context;
43126 + atomic_long_unchecked_t lock_kernel_context;
43127 + atomic_long_unchecked_t unlock_kernel_context;
43128 + atomic_long_unchecked_t steal_user_context;
43129 + atomic_long_unchecked_t steal_kernel_context;
43130 + atomic_long_unchecked_t steal_context_failed;
43131 + atomic_long_unchecked_t nopfn;
43132 + atomic_long_unchecked_t asid_new;
43133 + atomic_long_unchecked_t asid_next;
43134 + atomic_long_unchecked_t asid_wrap;
43135 + atomic_long_unchecked_t asid_reuse;
43136 + atomic_long_unchecked_t intr;
43137 + atomic_long_unchecked_t intr_cbr;
43138 + atomic_long_unchecked_t intr_tfh;
43139 + atomic_long_unchecked_t intr_spurious;
43140 + atomic_long_unchecked_t intr_mm_lock_failed;
43141 + atomic_long_unchecked_t call_os;
43142 + atomic_long_unchecked_t call_os_wait_queue;
43143 + atomic_long_unchecked_t user_flush_tlb;
43144 + atomic_long_unchecked_t user_unload_context;
43145 + atomic_long_unchecked_t user_exception;
43146 + atomic_long_unchecked_t set_context_option;
43147 + atomic_long_unchecked_t check_context_retarget_intr;
43148 + atomic_long_unchecked_t check_context_unload;
43149 + atomic_long_unchecked_t tlb_dropin;
43150 + atomic_long_unchecked_t tlb_preload_page;
43151 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43152 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43153 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43154 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43155 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43156 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43157 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43158 + atomic_long_unchecked_t tfh_stale_on_fault;
43159 + atomic_long_unchecked_t mmu_invalidate_range;
43160 + atomic_long_unchecked_t mmu_invalidate_page;
43161 + atomic_long_unchecked_t flush_tlb;
43162 + atomic_long_unchecked_t flush_tlb_gru;
43163 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43164 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43165
43166 - atomic_long_t copy_gpa;
43167 - atomic_long_t read_gpa;
43168 + atomic_long_unchecked_t copy_gpa;
43169 + atomic_long_unchecked_t read_gpa;
43170
43171 - atomic_long_t mesq_receive;
43172 - atomic_long_t mesq_receive_none;
43173 - atomic_long_t mesq_send;
43174 - atomic_long_t mesq_send_failed;
43175 - atomic_long_t mesq_noop;
43176 - atomic_long_t mesq_send_unexpected_error;
43177 - atomic_long_t mesq_send_lb_overflow;
43178 - atomic_long_t mesq_send_qlimit_reached;
43179 - atomic_long_t mesq_send_amo_nacked;
43180 - atomic_long_t mesq_send_put_nacked;
43181 - atomic_long_t mesq_page_overflow;
43182 - atomic_long_t mesq_qf_locked;
43183 - atomic_long_t mesq_qf_noop_not_full;
43184 - atomic_long_t mesq_qf_switch_head_failed;
43185 - atomic_long_t mesq_qf_unexpected_error;
43186 - atomic_long_t mesq_noop_unexpected_error;
43187 - atomic_long_t mesq_noop_lb_overflow;
43188 - atomic_long_t mesq_noop_qlimit_reached;
43189 - atomic_long_t mesq_noop_amo_nacked;
43190 - atomic_long_t mesq_noop_put_nacked;
43191 - atomic_long_t mesq_noop_page_overflow;
43192 + atomic_long_unchecked_t mesq_receive;
43193 + atomic_long_unchecked_t mesq_receive_none;
43194 + atomic_long_unchecked_t mesq_send;
43195 + atomic_long_unchecked_t mesq_send_failed;
43196 + atomic_long_unchecked_t mesq_noop;
43197 + atomic_long_unchecked_t mesq_send_unexpected_error;
43198 + atomic_long_unchecked_t mesq_send_lb_overflow;
43199 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43200 + atomic_long_unchecked_t mesq_send_amo_nacked;
43201 + atomic_long_unchecked_t mesq_send_put_nacked;
43202 + atomic_long_unchecked_t mesq_page_overflow;
43203 + atomic_long_unchecked_t mesq_qf_locked;
43204 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43205 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43206 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43207 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43208 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43209 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43210 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43211 + atomic_long_unchecked_t mesq_noop_put_nacked;
43212 + atomic_long_unchecked_t mesq_noop_page_overflow;
43213
43214 };
43215
43216 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43217 tghop_invalidate, mcsop_last};
43218
43219 struct mcs_op_statistic {
43220 - atomic_long_t count;
43221 - atomic_long_t total;
43222 + atomic_long_unchecked_t count;
43223 + atomic_long_unchecked_t total;
43224 unsigned long max;
43225 };
43226
43227 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43228
43229 #define STAT(id) do { \
43230 if (gru_options & OPT_STATS) \
43231 - atomic_long_inc(&gru_stats.id); \
43232 + atomic_long_inc_unchecked(&gru_stats.id); \
43233 } while (0)
43234
43235 #ifdef CONFIG_SGI_GRU_DEBUG
43236 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43237 index c862cd4..0d176fe 100644
43238 --- a/drivers/misc/sgi-xp/xp.h
43239 +++ b/drivers/misc/sgi-xp/xp.h
43240 @@ -288,7 +288,7 @@ struct xpc_interface {
43241 xpc_notify_func, void *);
43242 void (*received) (short, int, void *);
43243 enum xp_retval (*partid_to_nasids) (short, void *);
43244 -};
43245 +} __no_const;
43246
43247 extern struct xpc_interface xpc_interface;
43248
43249 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43250 index b94d5f7..7f494c5 100644
43251 --- a/drivers/misc/sgi-xp/xpc.h
43252 +++ b/drivers/misc/sgi-xp/xpc.h
43253 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43254 void (*received_payload) (struct xpc_channel *, void *);
43255 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43256 };
43257 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43258
43259 /* struct xpc_partition act_state values (for XPC HB) */
43260
43261 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43262 /* found in xpc_main.c */
43263 extern struct device *xpc_part;
43264 extern struct device *xpc_chan;
43265 -extern struct xpc_arch_operations xpc_arch_ops;
43266 +extern xpc_arch_operations_no_const xpc_arch_ops;
43267 extern int xpc_disengage_timelimit;
43268 extern int xpc_disengage_timedout;
43269 extern int xpc_activate_IRQ_rcvd;
43270 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43271 index 82dc574..8539ab2 100644
43272 --- a/drivers/misc/sgi-xp/xpc_main.c
43273 +++ b/drivers/misc/sgi-xp/xpc_main.c
43274 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43275 .notifier_call = xpc_system_die,
43276 };
43277
43278 -struct xpc_arch_operations xpc_arch_ops;
43279 +xpc_arch_operations_no_const xpc_arch_ops;
43280
43281 /*
43282 * Timer function to enforce the timelimit on the partition disengage.
43283 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43284
43285 if (((die_args->trapnr == X86_TRAP_MF) ||
43286 (die_args->trapnr == X86_TRAP_XF)) &&
43287 - !user_mode_vm(die_args->regs))
43288 + !user_mode(die_args->regs))
43289 xpc_die_deactivate();
43290
43291 break;
43292 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43293 index ef18348..1b53cf0 100644
43294 --- a/drivers/mmc/core/mmc_ops.c
43295 +++ b/drivers/mmc/core/mmc_ops.c
43296 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43297 void *data_buf;
43298 int is_on_stack;
43299
43300 - is_on_stack = object_is_on_stack(buf);
43301 + is_on_stack = object_starts_on_stack(buf);
43302 if (is_on_stack) {
43303 /*
43304 * dma onto stack is unsafe/nonportable, but callers to this
43305 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43306 index 81b2994..dce857e 100644
43307 --- a/drivers/mmc/host/dw_mmc.h
43308 +++ b/drivers/mmc/host/dw_mmc.h
43309 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43310 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43311 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43312 int (*parse_dt)(struct dw_mci *host);
43313 -};
43314 +} __do_const;
43315 #endif /* _DW_MMC_H_ */
43316 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43317 index c3785ed..1984c44 100644
43318 --- a/drivers/mmc/host/mmci.c
43319 +++ b/drivers/mmc/host/mmci.c
43320 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43321 }
43322
43323 if (variant->busy_detect) {
43324 - mmci_ops.card_busy = mmci_card_busy;
43325 + pax_open_kernel();
43326 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43327 + pax_close_kernel();
43328 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43329 }
43330
43331 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43332 index 6debda9..2ba7427 100644
43333 --- a/drivers/mmc/host/sdhci-s3c.c
43334 +++ b/drivers/mmc/host/sdhci-s3c.c
43335 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43336 * we can use overriding functions instead of default.
43337 */
43338 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43339 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43340 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43341 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43342 + pax_open_kernel();
43343 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43344 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43345 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43346 + pax_close_kernel();
43347 }
43348
43349 /* It supports additional host capabilities if needed */
43350 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43351 index 096993f..f02c23b 100644
43352 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43353 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43354 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43355 size_t totlen = 0, thislen;
43356 int ret = 0;
43357 size_t buflen = 0;
43358 - static char *buffer;
43359 + char *buffer;
43360
43361 if (!ECCBUF_SIZE) {
43362 /* We should fall back to a general writev implementation.
43363 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43364 index 2ed2bb3..2d0b82e 100644
43365 --- a/drivers/mtd/nand/denali.c
43366 +++ b/drivers/mtd/nand/denali.c
43367 @@ -24,6 +24,7 @@
43368 #include <linux/slab.h>
43369 #include <linux/mtd/mtd.h>
43370 #include <linux/module.h>
43371 +#include <linux/slab.h>
43372
43373 #include "denali.h"
43374
43375 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43376 index 51b9d6a..52af9a7 100644
43377 --- a/drivers/mtd/nftlmount.c
43378 +++ b/drivers/mtd/nftlmount.c
43379 @@ -24,6 +24,7 @@
43380 #include <asm/errno.h>
43381 #include <linux/delay.h>
43382 #include <linux/slab.h>
43383 +#include <linux/sched.h>
43384 #include <linux/mtd/mtd.h>
43385 #include <linux/mtd/nand.h>
43386 #include <linux/mtd/nftl.h>
43387 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43388 index 4b8e895..6b3c498 100644
43389 --- a/drivers/mtd/sm_ftl.c
43390 +++ b/drivers/mtd/sm_ftl.c
43391 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43392 #define SM_CIS_VENDOR_OFFSET 0x59
43393 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43394 {
43395 - struct attribute_group *attr_group;
43396 + attribute_group_no_const *attr_group;
43397 struct attribute **attributes;
43398 struct sm_sysfs_attribute *vendor_attribute;
43399
43400 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43401 index e883bfe..e51a1ec 100644
43402 --- a/drivers/net/bonding/bond_main.c
43403 +++ b/drivers/net/bonding/bond_main.c
43404 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
43405 return tx_queues;
43406 }
43407
43408 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43409 +static struct rtnl_link_ops bond_link_ops = {
43410 .kind = "bond",
43411 .priv_size = sizeof(struct bonding),
43412 .setup = bond_setup,
43413 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
43414
43415 bond_destroy_debugfs();
43416
43417 - rtnl_link_unregister(&bond_link_ops);
43418 unregister_pernet_subsys(&bond_net_ops);
43419 + rtnl_link_unregister(&bond_link_ops);
43420
43421 #ifdef CONFIG_NET_POLL_CONTROLLER
43422 /*
43423 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43424 index f92f001..0b2f9bf 100644
43425 --- a/drivers/net/ethernet/8390/ax88796.c
43426 +++ b/drivers/net/ethernet/8390/ax88796.c
43427 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43428 if (ax->plat->reg_offsets)
43429 ei_local->reg_offset = ax->plat->reg_offsets;
43430 else {
43431 + resource_size_t _mem_size = mem_size;
43432 + do_div(_mem_size, 0x18);
43433 ei_local->reg_offset = ax->reg_offsets;
43434 for (ret = 0; ret < 0x18; ret++)
43435 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43436 + ax->reg_offsets[ret] = _mem_size * ret;
43437 }
43438
43439 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43440 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43441 index da8fcaa..f4b5d3b 100644
43442 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43443 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43444 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43445 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43446 {
43447 /* RX_MODE controlling object */
43448 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43449 + bnx2x_init_rx_mode_obj(bp);
43450
43451 /* multicast configuration controlling object */
43452 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43453 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43454 index 9fbeee5..5e3e37a 100644
43455 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43456 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43457 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43458 return rc;
43459 }
43460
43461 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43462 - struct bnx2x_rx_mode_obj *o)
43463 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43464 {
43465 if (CHIP_IS_E1x(bp)) {
43466 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43467 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43468 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43469 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43470 } else {
43471 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43472 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43473 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43474 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43475 }
43476 }
43477
43478 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43479 index 658f4e3..15074a6 100644
43480 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43481 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43482 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43483
43484 /********************* RX MODE ****************/
43485
43486 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43487 - struct bnx2x_rx_mode_obj *o);
43488 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43489
43490 /**
43491 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43492 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43493 index 7025780..e55a71c 100644
43494 --- a/drivers/net/ethernet/broadcom/tg3.h
43495 +++ b/drivers/net/ethernet/broadcom/tg3.h
43496 @@ -147,6 +147,7 @@
43497 #define CHIPREV_ID_5750_A0 0x4000
43498 #define CHIPREV_ID_5750_A1 0x4001
43499 #define CHIPREV_ID_5750_A3 0x4003
43500 +#define CHIPREV_ID_5750_C1 0x4201
43501 #define CHIPREV_ID_5750_C2 0x4202
43502 #define CHIPREV_ID_5752_A0_HW 0x5000
43503 #define CHIPREV_ID_5752_A0 0x6000
43504 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43505 index 8cffcdf..aadf043 100644
43506 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43507 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43508 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43509 */
43510 struct l2t_skb_cb {
43511 arp_failure_handler_func arp_failure_handler;
43512 -};
43513 +} __no_const;
43514
43515 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43516
43517 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43518 index c73cabd..cd278b1 100644
43519 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43520 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43521 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43522
43523 int i;
43524 struct adapter *ap = netdev2adap(dev);
43525 - static const unsigned int *reg_ranges;
43526 + const unsigned int *reg_ranges;
43527 int arr_size = 0, buf_size = 0;
43528
43529 if (is_t4(ap->chip)) {
43530 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43531 index 263b92c..f05134b 100644
43532 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43533 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43534 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43535 for (i=0; i<ETH_ALEN; i++) {
43536 tmp.addr[i] = dev->dev_addr[i];
43537 }
43538 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43539 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43540 break;
43541
43542 case DE4X5_SET_HWADDR: /* Set the hardware address */
43543 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43544 spin_lock_irqsave(&lp->lock, flags);
43545 memcpy(&statbuf, &lp->pktStats, ioc->len);
43546 spin_unlock_irqrestore(&lp->lock, flags);
43547 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43548 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43549 return -EFAULT;
43550 break;
43551 }
43552 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43553 index 2c38cc4..0323f6e 100644
43554 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43555 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43556 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43557
43558 if (wrapped)
43559 newacc += 65536;
43560 - ACCESS_ONCE(*acc) = newacc;
43561 + ACCESS_ONCE_RW(*acc) = newacc;
43562 }
43563
43564 static void populate_erx_stats(struct be_adapter *adapter,
43565 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43566 index 212f44b..fb69959 100644
43567 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43568 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43569 @@ -31,6 +31,8 @@
43570 #include <linux/netdevice.h>
43571 #include <linux/phy.h>
43572 #include <linux/platform_device.h>
43573 +#include <linux/interrupt.h>
43574 +#include <linux/irqreturn.h>
43575 #include <net/ip.h>
43576
43577 #include "ftgmac100.h"
43578 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43579 index 8be5b40..081bc1b 100644
43580 --- a/drivers/net/ethernet/faraday/ftmac100.c
43581 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43582 @@ -31,6 +31,8 @@
43583 #include <linux/module.h>
43584 #include <linux/netdevice.h>
43585 #include <linux/platform_device.h>
43586 +#include <linux/interrupt.h>
43587 +#include <linux/irqreturn.h>
43588
43589 #include "ftmac100.h"
43590
43591 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43592 index 5184e2a..acb28c3 100644
43593 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43594 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43595 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43596 }
43597
43598 /* update the base incval used to calculate frequency adjustment */
43599 - ACCESS_ONCE(adapter->base_incval) = incval;
43600 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43601 smp_mb();
43602
43603 /* need lock to prevent incorrect read while modifying cyclecounter */
43604 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43605 index fbe5363..266b4e3 100644
43606 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
43607 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43608 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43609 struct __vxge_hw_fifo *fifo;
43610 struct vxge_hw_fifo_config *config;
43611 u32 txdl_size, txdl_per_memblock;
43612 - struct vxge_hw_mempool_cbs fifo_mp_callback;
43613 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
43614 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
43615 + };
43616 +
43617 struct __vxge_hw_virtualpath *vpath;
43618
43619 if ((vp == NULL) || (attr == NULL)) {
43620 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43621 goto exit;
43622 }
43623
43624 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
43625 -
43626 fifo->mempool =
43627 __vxge_hw_mempool_create(vpath->hldev,
43628 fifo->config->memblock_size,
43629 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43630 index f09e787..f3916a8 100644
43631 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43632 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43633 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
43634
43635 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
43636 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
43637 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43638 + pax_open_kernel();
43639 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43640 + pax_close_kernel();
43641 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43642 } else {
43643 return -EIO;
43644 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43645 index 0248a4c..9648d96 100644
43646 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43647 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43648 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
43649 case QLCNIC_NON_PRIV_FUNC:
43650 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
43651 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43652 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43653 + pax_open_kernel();
43654 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43655 + pax_close_kernel();
43656 break;
43657 case QLCNIC_PRIV_FUNC:
43658 ahw->op_mode = QLCNIC_PRIV_FUNC;
43659 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
43660 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43661 + pax_open_kernel();
43662 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43663 + pax_close_kernel();
43664 break;
43665 case QLCNIC_MGMT_FUNC:
43666 ahw->op_mode = QLCNIC_MGMT_FUNC;
43667 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43668 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43669 + pax_open_kernel();
43670 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43671 + pax_close_kernel();
43672 break;
43673 default:
43674 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
43675 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43676 index 1551360..ed6510f 100644
43677 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43678 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43679 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
43680 struct qlcnic_dump_entry *entry;
43681 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
43682 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
43683 - static const struct qlcnic_dump_operations *fw_dump_ops;
43684 + const struct qlcnic_dump_operations *fw_dump_ops;
43685 struct device *dev = &adapter->pdev->dev;
43686 struct qlcnic_hardware_context *ahw;
43687 void *temp_buffer;
43688 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
43689 index 3397cee..101f8fa 100644
43690 --- a/drivers/net/ethernet/realtek/r8169.c
43691 +++ b/drivers/net/ethernet/realtek/r8169.c
43692 @@ -759,22 +759,22 @@ struct rtl8169_private {
43693 struct mdio_ops {
43694 void (*write)(struct rtl8169_private *, int, int);
43695 int (*read)(struct rtl8169_private *, int);
43696 - } mdio_ops;
43697 + } __no_const mdio_ops;
43698
43699 struct pll_power_ops {
43700 void (*down)(struct rtl8169_private *);
43701 void (*up)(struct rtl8169_private *);
43702 - } pll_power_ops;
43703 + } __no_const pll_power_ops;
43704
43705 struct jumbo_ops {
43706 void (*enable)(struct rtl8169_private *);
43707 void (*disable)(struct rtl8169_private *);
43708 - } jumbo_ops;
43709 + } __no_const jumbo_ops;
43710
43711 struct csi_ops {
43712 void (*write)(struct rtl8169_private *, int, int);
43713 u32 (*read)(struct rtl8169_private *, int);
43714 - } csi_ops;
43715 + } __no_const csi_ops;
43716
43717 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
43718 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
43719 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
43720 index 03acf57..e1251ff 100644
43721 --- a/drivers/net/ethernet/sfc/ptp.c
43722 +++ b/drivers/net/ethernet/sfc/ptp.c
43723 @@ -539,7 +539,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
43724 ptp->start.dma_addr);
43725
43726 /* Clear flag that signals MC ready */
43727 - ACCESS_ONCE(*start) = 0;
43728 + ACCESS_ONCE_RW(*start) = 0;
43729 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
43730 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
43731 EFX_BUG_ON_PARANOID(rc);
43732 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43733 index 50617c5..b13724c 100644
43734 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43735 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43736 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
43737
43738 writel(value, ioaddr + MMC_CNTRL);
43739
43740 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43741 - MMC_CNTRL, value);
43742 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43743 +// MMC_CNTRL, value);
43744 }
43745
43746 /* To mask all all interrupts.*/
43747 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
43748 index e6fe0d8..2b7d752 100644
43749 --- a/drivers/net/hyperv/hyperv_net.h
43750 +++ b/drivers/net/hyperv/hyperv_net.h
43751 @@ -101,7 +101,7 @@ struct rndis_device {
43752
43753 enum rndis_device_state state;
43754 bool link_state;
43755 - atomic_t new_req_id;
43756 + atomic_unchecked_t new_req_id;
43757
43758 spinlock_t request_lock;
43759 struct list_head req_list;
43760 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
43761 index 0775f0a..d4fb316 100644
43762 --- a/drivers/net/hyperv/rndis_filter.c
43763 +++ b/drivers/net/hyperv/rndis_filter.c
43764 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
43765 * template
43766 */
43767 set = &rndis_msg->msg.set_req;
43768 - set->req_id = atomic_inc_return(&dev->new_req_id);
43769 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43770
43771 /* Add to the request list */
43772 spin_lock_irqsave(&dev->request_lock, flags);
43773 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
43774
43775 /* Setup the rndis set */
43776 halt = &request->request_msg.msg.halt_req;
43777 - halt->req_id = atomic_inc_return(&dev->new_req_id);
43778 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43779
43780 /* Ignore return since this msg is optional. */
43781 rndis_filter_send_request(dev, request);
43782 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
43783 index bf0d55e..82bcfbd1 100644
43784 --- a/drivers/net/ieee802154/fakehard.c
43785 +++ b/drivers/net/ieee802154/fakehard.c
43786 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
43787 phy->transmit_power = 0xbf;
43788
43789 dev->netdev_ops = &fake_ops;
43790 - dev->ml_priv = &fake_mlme;
43791 + dev->ml_priv = (void *)&fake_mlme;
43792
43793 priv = netdev_priv(dev);
43794 priv->phy = phy;
43795 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
43796 index 9bf46bd..bfdaa84 100644
43797 --- a/drivers/net/macvlan.c
43798 +++ b/drivers/net/macvlan.c
43799 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
43800 int macvlan_link_register(struct rtnl_link_ops *ops)
43801 {
43802 /* common fields */
43803 - ops->priv_size = sizeof(struct macvlan_dev);
43804 - ops->validate = macvlan_validate;
43805 - ops->maxtype = IFLA_MACVLAN_MAX;
43806 - ops->policy = macvlan_policy;
43807 - ops->changelink = macvlan_changelink;
43808 - ops->get_size = macvlan_get_size;
43809 - ops->fill_info = macvlan_fill_info;
43810 + pax_open_kernel();
43811 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
43812 + *(void **)&ops->validate = macvlan_validate;
43813 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
43814 + *(const void **)&ops->policy = macvlan_policy;
43815 + *(void **)&ops->changelink = macvlan_changelink;
43816 + *(void **)&ops->get_size = macvlan_get_size;
43817 + *(void **)&ops->fill_info = macvlan_fill_info;
43818 + pax_close_kernel();
43819
43820 return rtnl_link_register(ops);
43821 };
43822 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
43823 return NOTIFY_DONE;
43824 }
43825
43826 -static struct notifier_block macvlan_notifier_block __read_mostly = {
43827 +static struct notifier_block macvlan_notifier_block = {
43828 .notifier_call = macvlan_device_event,
43829 };
43830
43831 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
43832 index 9dccb1e..19fd4c9 100644
43833 --- a/drivers/net/macvtap.c
43834 +++ b/drivers/net/macvtap.c
43835 @@ -1183,7 +1183,7 @@ static int macvtap_device_event(struct notifier_block *unused,
43836 return NOTIFY_DONE;
43837 }
43838
43839 -static struct notifier_block macvtap_notifier_block __read_mostly = {
43840 +static struct notifier_block macvtap_notifier_block = {
43841 .notifier_call = macvtap_device_event,
43842 };
43843
43844 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
43845 index daec9b0..6428fcb 100644
43846 --- a/drivers/net/phy/mdio-bitbang.c
43847 +++ b/drivers/net/phy/mdio-bitbang.c
43848 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
43849 struct mdiobb_ctrl *ctrl = bus->priv;
43850
43851 module_put(ctrl->ops->owner);
43852 + mdiobus_unregister(bus);
43853 mdiobus_free(bus);
43854 }
43855 EXPORT_SYMBOL(free_mdio_bitbang);
43856 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
43857 index 72ff14b..11d442d 100644
43858 --- a/drivers/net/ppp/ppp_generic.c
43859 +++ b/drivers/net/ppp/ppp_generic.c
43860 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43861 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
43862 struct ppp_stats stats;
43863 struct ppp_comp_stats cstats;
43864 - char *vers;
43865
43866 switch (cmd) {
43867 case SIOCGPPPSTATS:
43868 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43869 break;
43870
43871 case SIOCGPPPVER:
43872 - vers = PPP_VERSION;
43873 - if (copy_to_user(addr, vers, strlen(vers) + 1))
43874 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
43875 break;
43876 err = 0;
43877 break;
43878 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
43879 index 1252d9c..80e660b 100644
43880 --- a/drivers/net/slip/slhc.c
43881 +++ b/drivers/net/slip/slhc.c
43882 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
43883 register struct tcphdr *thp;
43884 register struct iphdr *ip;
43885 register struct cstate *cs;
43886 - int len, hdrlen;
43887 + long len, hdrlen;
43888 unsigned char *cp = icp;
43889
43890 /* We've got a compressed packet; read the change byte */
43891 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
43892 index 50e43e6..e1a5807 100644
43893 --- a/drivers/net/team/team.c
43894 +++ b/drivers/net/team/team.c
43895 @@ -2869,7 +2869,7 @@ static int team_device_event(struct notifier_block *unused,
43896 return NOTIFY_DONE;
43897 }
43898
43899 -static struct notifier_block team_notifier_block __read_mostly = {
43900 +static struct notifier_block team_notifier_block = {
43901 .notifier_call = team_device_event,
43902 };
43903
43904 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
43905 index 7cb105c..11214ff 100644
43906 --- a/drivers/net/tun.c
43907 +++ b/drivers/net/tun.c
43908 @@ -1826,7 +1826,7 @@ unlock:
43909 }
43910
43911 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43912 - unsigned long arg, int ifreq_len)
43913 + unsigned long arg, size_t ifreq_len)
43914 {
43915 struct tun_file *tfile = file->private_data;
43916 struct tun_struct *tun;
43917 @@ -1839,6 +1839,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43918 unsigned int ifindex;
43919 int ret;
43920
43921 + if (ifreq_len > sizeof ifr)
43922 + return -EFAULT;
43923 +
43924 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
43925 if (copy_from_user(&ifr, argp, ifreq_len))
43926 return -EFAULT;
43927 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
43928 index 86292e6..8d34433 100644
43929 --- a/drivers/net/usb/hso.c
43930 +++ b/drivers/net/usb/hso.c
43931 @@ -71,7 +71,7 @@
43932 #include <asm/byteorder.h>
43933 #include <linux/serial_core.h>
43934 #include <linux/serial.h>
43935 -
43936 +#include <asm/local.h>
43937
43938 #define MOD_AUTHOR "Option Wireless"
43939 #define MOD_DESCRIPTION "USB High Speed Option driver"
43940 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
43941 struct urb *urb;
43942
43943 urb = serial->rx_urb[0];
43944 - if (serial->port.count > 0) {
43945 + if (atomic_read(&serial->port.count) > 0) {
43946 count = put_rxbuf_data(urb, serial);
43947 if (count == -1)
43948 return;
43949 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
43950 DUMP1(urb->transfer_buffer, urb->actual_length);
43951
43952 /* Anyone listening? */
43953 - if (serial->port.count == 0)
43954 + if (atomic_read(&serial->port.count) == 0)
43955 return;
43956
43957 if (status == 0) {
43958 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
43959 tty_port_tty_set(&serial->port, tty);
43960
43961 /* check for port already opened, if not set the termios */
43962 - serial->port.count++;
43963 - if (serial->port.count == 1) {
43964 + if (atomic_inc_return(&serial->port.count) == 1) {
43965 serial->rx_state = RX_IDLE;
43966 /* Force default termio settings */
43967 _hso_serial_set_termios(tty, NULL);
43968 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
43969 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
43970 if (result) {
43971 hso_stop_serial_device(serial->parent);
43972 - serial->port.count--;
43973 + atomic_dec(&serial->port.count);
43974 kref_put(&serial->parent->ref, hso_serial_ref_free);
43975 }
43976 } else {
43977 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
43978
43979 /* reset the rts and dtr */
43980 /* do the actual close */
43981 - serial->port.count--;
43982 + atomic_dec(&serial->port.count);
43983
43984 - if (serial->port.count <= 0) {
43985 - serial->port.count = 0;
43986 + if (atomic_read(&serial->port.count) <= 0) {
43987 + atomic_set(&serial->port.count, 0);
43988 tty_port_tty_set(&serial->port, NULL);
43989 if (!usb_gone)
43990 hso_stop_serial_device(serial->parent);
43991 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
43992
43993 /* the actual setup */
43994 spin_lock_irqsave(&serial->serial_lock, flags);
43995 - if (serial->port.count)
43996 + if (atomic_read(&serial->port.count))
43997 _hso_serial_set_termios(tty, old);
43998 else
43999 tty->termios = *old;
44000 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44001 D1("Pending read interrupt on port %d\n", i);
44002 spin_lock(&serial->serial_lock);
44003 if (serial->rx_state == RX_IDLE &&
44004 - serial->port.count > 0) {
44005 + atomic_read(&serial->port.count) > 0) {
44006 /* Setup and send a ctrl req read on
44007 * port i */
44008 if (!serial->rx_urb_filled[0]) {
44009 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44010 /* Start all serial ports */
44011 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44012 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44013 - if (dev2ser(serial_table[i])->port.count) {
44014 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44015 result =
44016 hso_start_serial_device(serial_table[i], GFP_NOIO);
44017 hso_kick_transmit(dev2ser(serial_table[i]));
44018 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44019 index a79e9d3..78cd4fa 100644
44020 --- a/drivers/net/usb/sierra_net.c
44021 +++ b/drivers/net/usb/sierra_net.c
44022 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44023 /* atomic counter partially included in MAC address to make sure 2 devices
44024 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44025 */
44026 -static atomic_t iface_counter = ATOMIC_INIT(0);
44027 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44028
44029 /*
44030 * SYNC Timer Delay definition used to set the expiry time
44031 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44032 dev->net->netdev_ops = &sierra_net_device_ops;
44033
44034 /* change MAC addr to include, ifacenum, and to be unique */
44035 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44036 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44037 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44038
44039 /* we will have to manufacture ethernet headers, prepare template */
44040 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44041 index 2ef5b62..6fa0ec3 100644
44042 --- a/drivers/net/vxlan.c
44043 +++ b/drivers/net/vxlan.c
44044 @@ -2615,7 +2615,7 @@ nla_put_failure:
44045 return -EMSGSIZE;
44046 }
44047
44048 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44049 +static struct rtnl_link_ops vxlan_link_ops = {
44050 .kind = "vxlan",
44051 .maxtype = IFLA_VXLAN_MAX,
44052 .policy = vxlan_policy,
44053 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44054 index 0b60295..b8bfa5b 100644
44055 --- a/drivers/net/wimax/i2400m/rx.c
44056 +++ b/drivers/net/wimax/i2400m/rx.c
44057 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44058 if (i2400m->rx_roq == NULL)
44059 goto error_roq_alloc;
44060
44061 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44062 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44063 GFP_KERNEL);
44064 if (rd == NULL) {
44065 result = -ENOMEM;
44066 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44067 index 7fe1964..7016de0 100644
44068 --- a/drivers/net/wireless/airo.c
44069 +++ b/drivers/net/wireless/airo.c
44070 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44071 struct airo_info *ai = dev->ml_priv;
44072 int ridcode;
44073 int enabled;
44074 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44075 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44076 unsigned char *iobuf;
44077
44078 /* Only super-user can write RIDs */
44079 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44080 index 34c8a33..3261fdc 100644
44081 --- a/drivers/net/wireless/at76c50x-usb.c
44082 +++ b/drivers/net/wireless/at76c50x-usb.c
44083 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44084 }
44085
44086 /* Convert timeout from the DFU status to jiffies */
44087 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44088 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44089 {
44090 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44091 | (s->poll_timeout[1] << 8)
44092 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44093 index ef3329e..c28ff5d 100644
44094 --- a/drivers/net/wireless/ath/ath10k/htc.c
44095 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44096 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44097 /* registered target arrival callback from the HIF layer */
44098 int ath10k_htc_init(struct ath10k *ar)
44099 {
44100 - struct ath10k_hif_cb htc_callbacks;
44101 + static struct ath10k_hif_cb htc_callbacks = {
44102 + .rx_completion = ath10k_htc_rx_completion_handler,
44103 + .tx_completion = ath10k_htc_tx_completion_handler,
44104 + };
44105 struct ath10k_htc_ep *ep = NULL;
44106 struct ath10k_htc *htc = &ar->htc;
44107
44108 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44109 ath10k_htc_reset_endpoint_states(htc);
44110
44111 /* setup HIF layer callbacks */
44112 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44113 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44114 htc->ar = ar;
44115
44116 /* Get HIF default pipe for HTC message exchange */
44117 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44118 index e1dd8c7..9f91b3f 100644
44119 --- a/drivers/net/wireless/ath/ath10k/htc.h
44120 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44121 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44122
44123 struct ath10k_htc_ops {
44124 void (*target_send_suspend_complete)(struct ath10k *ar);
44125 -};
44126 +} __no_const;
44127
44128 struct ath10k_htc_ep_ops {
44129 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44130 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44131 -};
44132 +} __no_const;
44133
44134 /* service connection information */
44135 struct ath10k_htc_svc_conn_req {
44136 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44137 index 8d78253..bebbb68 100644
44138 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44139 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44140 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44141 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44142 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44143
44144 - ACCESS_ONCE(ads->ds_link) = i->link;
44145 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44146 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44147 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44148
44149 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44150 ctl6 = SM(i->keytype, AR_EncrType);
44151 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44152
44153 if ((i->is_first || i->is_last) &&
44154 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44155 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44156 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44157 | set11nTries(i->rates, 1)
44158 | set11nTries(i->rates, 2)
44159 | set11nTries(i->rates, 3)
44160 | (i->dur_update ? AR_DurUpdateEna : 0)
44161 | SM(0, AR_BurstDur);
44162
44163 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44164 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44165 | set11nRate(i->rates, 1)
44166 | set11nRate(i->rates, 2)
44167 | set11nRate(i->rates, 3);
44168 } else {
44169 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44170 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44171 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44172 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44173 }
44174
44175 if (!i->is_first) {
44176 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44177 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44178 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44179 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44180 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44181 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44182 return;
44183 }
44184
44185 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44186 break;
44187 }
44188
44189 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44190 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44191 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44192 | SM(i->txpower, AR_XmitPower)
44193 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44194 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44195 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44196 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44197
44198 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44199 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44200 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44201 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44202
44203 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44204 return;
44205
44206 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44207 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44208 | set11nPktDurRTSCTS(i->rates, 1);
44209
44210 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44211 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44212 | set11nPktDurRTSCTS(i->rates, 3);
44213
44214 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44215 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44216 | set11nRateFlags(i->rates, 1)
44217 | set11nRateFlags(i->rates, 2)
44218 | set11nRateFlags(i->rates, 3)
44219 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44220 index f6c5c1b..6058354 100644
44221 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44222 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44223 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44224 (i->qcu << AR_TxQcuNum_S) | desc_len;
44225
44226 checksum += val;
44227 - ACCESS_ONCE(ads->info) = val;
44228 + ACCESS_ONCE_RW(ads->info) = val;
44229
44230 checksum += i->link;
44231 - ACCESS_ONCE(ads->link) = i->link;
44232 + ACCESS_ONCE_RW(ads->link) = i->link;
44233
44234 checksum += i->buf_addr[0];
44235 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44236 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44237 checksum += i->buf_addr[1];
44238 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44239 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44240 checksum += i->buf_addr[2];
44241 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44242 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44243 checksum += i->buf_addr[3];
44244 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44245 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44246
44247 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44248 - ACCESS_ONCE(ads->ctl3) = val;
44249 + ACCESS_ONCE_RW(ads->ctl3) = val;
44250 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44251 - ACCESS_ONCE(ads->ctl5) = val;
44252 + ACCESS_ONCE_RW(ads->ctl5) = val;
44253 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44254 - ACCESS_ONCE(ads->ctl7) = val;
44255 + ACCESS_ONCE_RW(ads->ctl7) = val;
44256 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44257 - ACCESS_ONCE(ads->ctl9) = val;
44258 + ACCESS_ONCE_RW(ads->ctl9) = val;
44259
44260 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44261 - ACCESS_ONCE(ads->ctl10) = checksum;
44262 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44263
44264 if (i->is_first || i->is_last) {
44265 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44266 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44267 | set11nTries(i->rates, 1)
44268 | set11nTries(i->rates, 2)
44269 | set11nTries(i->rates, 3)
44270 | (i->dur_update ? AR_DurUpdateEna : 0)
44271 | SM(0, AR_BurstDur);
44272
44273 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44274 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44275 | set11nRate(i->rates, 1)
44276 | set11nRate(i->rates, 2)
44277 | set11nRate(i->rates, 3);
44278 } else {
44279 - ACCESS_ONCE(ads->ctl13) = 0;
44280 - ACCESS_ONCE(ads->ctl14) = 0;
44281 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44282 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44283 }
44284
44285 ads->ctl20 = 0;
44286 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44287
44288 ctl17 = SM(i->keytype, AR_EncrType);
44289 if (!i->is_first) {
44290 - ACCESS_ONCE(ads->ctl11) = 0;
44291 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44292 - ACCESS_ONCE(ads->ctl15) = 0;
44293 - ACCESS_ONCE(ads->ctl16) = 0;
44294 - ACCESS_ONCE(ads->ctl17) = ctl17;
44295 - ACCESS_ONCE(ads->ctl18) = 0;
44296 - ACCESS_ONCE(ads->ctl19) = 0;
44297 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44298 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44299 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44300 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44301 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44302 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44303 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44304 return;
44305 }
44306
44307 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44308 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44309 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44310 | SM(i->txpower, AR_XmitPower)
44311 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44312 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44313 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44314 ctl12 |= SM(val, AR_PAPRDChainMask);
44315
44316 - ACCESS_ONCE(ads->ctl12) = ctl12;
44317 - ACCESS_ONCE(ads->ctl17) = ctl17;
44318 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44319 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44320
44321 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44322 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44323 | set11nPktDurRTSCTS(i->rates, 1);
44324
44325 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44326 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44327 | set11nPktDurRTSCTS(i->rates, 3);
44328
44329 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44330 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44331 | set11nRateFlags(i->rates, 1)
44332 | set11nRateFlags(i->rates, 2)
44333 | set11nRateFlags(i->rates, 3)
44334 | SM(i->rtscts_rate, AR_RTSCTSRate);
44335
44336 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44337 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44338 }
44339
44340 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44341 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44342 index 69a907b..91e071c 100644
44343 --- a/drivers/net/wireless/ath/ath9k/hw.h
44344 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44345 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44346
44347 /* ANI */
44348 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44349 -};
44350 +} __no_const;
44351
44352 /**
44353 * struct ath_spec_scan - parameters for Atheros spectral scan
44354 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44355 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44356 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44357 #endif
44358 -};
44359 +} __no_const;
44360
44361 struct ath_nf_limits {
44362 s16 max;
44363 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44364 index 92190da..f3a4c4c 100644
44365 --- a/drivers/net/wireless/b43/phy_lp.c
44366 +++ b/drivers/net/wireless/b43/phy_lp.c
44367 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44368 {
44369 struct ssb_bus *bus = dev->dev->sdev->bus;
44370
44371 - static const struct b206x_channel *chandata = NULL;
44372 + const struct b206x_channel *chandata = NULL;
44373 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44374 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44375 u16 old_comm15, scale;
44376 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44377 index 9581d07..84f6a76 100644
44378 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44379 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44380 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44381 */
44382 if (il3945_mod_params.disable_hw_scan) {
44383 D_INFO("Disabling hw_scan\n");
44384 - il3945_mac_ops.hw_scan = NULL;
44385 + pax_open_kernel();
44386 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44387 + pax_close_kernel();
44388 }
44389
44390 D_INFO("*** LOAD DRIVER ***\n");
44391 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44392 index d94f8ab..5b568c8 100644
44393 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44394 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44395 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44396 {
44397 struct iwl_priv *priv = file->private_data;
44398 char buf[64];
44399 - int buf_size;
44400 + size_t buf_size;
44401 u32 offset, len;
44402
44403 memset(buf, 0, sizeof(buf));
44404 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44405 struct iwl_priv *priv = file->private_data;
44406
44407 char buf[8];
44408 - int buf_size;
44409 + size_t buf_size;
44410 u32 reset_flag;
44411
44412 memset(buf, 0, sizeof(buf));
44413 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44414 {
44415 struct iwl_priv *priv = file->private_data;
44416 char buf[8];
44417 - int buf_size;
44418 + size_t buf_size;
44419 int ht40;
44420
44421 memset(buf, 0, sizeof(buf));
44422 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44423 {
44424 struct iwl_priv *priv = file->private_data;
44425 char buf[8];
44426 - int buf_size;
44427 + size_t buf_size;
44428 int value;
44429
44430 memset(buf, 0, sizeof(buf));
44431 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44432 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44433 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44434
44435 -static const char *fmt_value = " %-30s %10u\n";
44436 -static const char *fmt_hex = " %-30s 0x%02X\n";
44437 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44438 -static const char *fmt_header =
44439 +static const char fmt_value[] = " %-30s %10u\n";
44440 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44441 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44442 +static const char fmt_header[] =
44443 "%-32s current cumulative delta max\n";
44444
44445 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44446 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44447 {
44448 struct iwl_priv *priv = file->private_data;
44449 char buf[8];
44450 - int buf_size;
44451 + size_t buf_size;
44452 int clear;
44453
44454 memset(buf, 0, sizeof(buf));
44455 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44456 {
44457 struct iwl_priv *priv = file->private_data;
44458 char buf[8];
44459 - int buf_size;
44460 + size_t buf_size;
44461 int trace;
44462
44463 memset(buf, 0, sizeof(buf));
44464 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44465 {
44466 struct iwl_priv *priv = file->private_data;
44467 char buf[8];
44468 - int buf_size;
44469 + size_t buf_size;
44470 int missed;
44471
44472 memset(buf, 0, sizeof(buf));
44473 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44474
44475 struct iwl_priv *priv = file->private_data;
44476 char buf[8];
44477 - int buf_size;
44478 + size_t buf_size;
44479 int plcp;
44480
44481 memset(buf, 0, sizeof(buf));
44482 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44483
44484 struct iwl_priv *priv = file->private_data;
44485 char buf[8];
44486 - int buf_size;
44487 + size_t buf_size;
44488 int flush;
44489
44490 memset(buf, 0, sizeof(buf));
44491 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44492
44493 struct iwl_priv *priv = file->private_data;
44494 char buf[8];
44495 - int buf_size;
44496 + size_t buf_size;
44497 int rts;
44498
44499 if (!priv->cfg->ht_params)
44500 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44501 {
44502 struct iwl_priv *priv = file->private_data;
44503 char buf[8];
44504 - int buf_size;
44505 + size_t buf_size;
44506
44507 memset(buf, 0, sizeof(buf));
44508 buf_size = min(count, sizeof(buf) - 1);
44509 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44510 struct iwl_priv *priv = file->private_data;
44511 u32 event_log_flag;
44512 char buf[8];
44513 - int buf_size;
44514 + size_t buf_size;
44515
44516 /* check that the interface is up */
44517 if (!iwl_is_ready(priv))
44518 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44519 struct iwl_priv *priv = file->private_data;
44520 char buf[8];
44521 u32 calib_disabled;
44522 - int buf_size;
44523 + size_t buf_size;
44524
44525 memset(buf, 0, sizeof(buf));
44526 buf_size = min(count, sizeof(buf) - 1);
44527 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44528 index 7aad766..06addb4 100644
44529 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44530 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44531 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44532 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44533 {
44534 struct iwl_nvm_data *data = priv->nvm_data;
44535 - char *debug_msg;
44536 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44537
44538 if (data->sku_cap_11n_enable &&
44539 !priv->cfg->ht_params) {
44540 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44541 return -EINVAL;
44542 }
44543
44544 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44545 IWL_DEBUG_INFO(priv, debug_msg,
44546 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44547 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44548 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44549 index c3f904d..4cadf83 100644
44550 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44551 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44552 @@ -1252,7 +1252,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44553 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44554
44555 char buf[8];
44556 - int buf_size;
44557 + size_t buf_size;
44558 u32 reset_flag;
44559
44560 memset(buf, 0, sizeof(buf));
44561 @@ -1273,7 +1273,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44562 {
44563 struct iwl_trans *trans = file->private_data;
44564 char buf[8];
44565 - int buf_size;
44566 + size_t buf_size;
44567 int csr;
44568
44569 memset(buf, 0, sizeof(buf));
44570 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44571 index 2cd3f54..e936f90 100644
44572 --- a/drivers/net/wireless/mac80211_hwsim.c
44573 +++ b/drivers/net/wireless/mac80211_hwsim.c
44574 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
44575
44576 if (channels > 1) {
44577 hwsim_if_comb.num_different_channels = channels;
44578 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44579 - mac80211_hwsim_ops.cancel_hw_scan =
44580 - mac80211_hwsim_cancel_hw_scan;
44581 - mac80211_hwsim_ops.sw_scan_start = NULL;
44582 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44583 - mac80211_hwsim_ops.remain_on_channel =
44584 - mac80211_hwsim_roc;
44585 - mac80211_hwsim_ops.cancel_remain_on_channel =
44586 - mac80211_hwsim_croc;
44587 - mac80211_hwsim_ops.add_chanctx =
44588 - mac80211_hwsim_add_chanctx;
44589 - mac80211_hwsim_ops.remove_chanctx =
44590 - mac80211_hwsim_remove_chanctx;
44591 - mac80211_hwsim_ops.change_chanctx =
44592 - mac80211_hwsim_change_chanctx;
44593 - mac80211_hwsim_ops.assign_vif_chanctx =
44594 - mac80211_hwsim_assign_vif_chanctx;
44595 - mac80211_hwsim_ops.unassign_vif_chanctx =
44596 - mac80211_hwsim_unassign_vif_chanctx;
44597 + pax_open_kernel();
44598 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44599 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44600 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44601 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
44602 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
44603 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
44604 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
44605 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
44606 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
44607 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
44608 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
44609 + pax_close_kernel();
44610 }
44611
44612 spin_lock_init(&hwsim_radio_lock);
44613 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
44614 index 8169a85..7fa3b47 100644
44615 --- a/drivers/net/wireless/rndis_wlan.c
44616 +++ b/drivers/net/wireless/rndis_wlan.c
44617 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
44618
44619 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
44620
44621 - if (rts_threshold < 0 || rts_threshold > 2347)
44622 + if (rts_threshold > 2347)
44623 rts_threshold = 2347;
44624
44625 tmp = cpu_to_le32(rts_threshold);
44626 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
44627 index fe4c572..99dedfa 100644
44628 --- a/drivers/net/wireless/rt2x00/rt2x00.h
44629 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
44630 @@ -387,7 +387,7 @@ struct rt2x00_intf {
44631 * for hardware which doesn't support hardware
44632 * sequence counting.
44633 */
44634 - atomic_t seqno;
44635 + atomic_unchecked_t seqno;
44636 };
44637
44638 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
44639 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
44640 index 66a2db8..70cad04 100644
44641 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
44642 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
44643 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
44644 * sequence counter given by mac80211.
44645 */
44646 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
44647 - seqno = atomic_add_return(0x10, &intf->seqno);
44648 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
44649 else
44650 - seqno = atomic_read(&intf->seqno);
44651 + seqno = atomic_read_unchecked(&intf->seqno);
44652
44653 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
44654 hdr->seq_ctrl |= cpu_to_le16(seqno);
44655 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
44656 index e2b3d9c..67a5184 100644
44657 --- a/drivers/net/wireless/ti/wl1251/sdio.c
44658 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
44659 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
44660
44661 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
44662
44663 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44664 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44665 + pax_open_kernel();
44666 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44667 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44668 + pax_close_kernel();
44669
44670 wl1251_info("using dedicated interrupt line");
44671 } else {
44672 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44673 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44674 + pax_open_kernel();
44675 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44676 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44677 + pax_close_kernel();
44678
44679 wl1251_info("using SDIO interrupt");
44680 }
44681 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
44682 index 1c627da..69f7d17 100644
44683 --- a/drivers/net/wireless/ti/wl12xx/main.c
44684 +++ b/drivers/net/wireless/ti/wl12xx/main.c
44685 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44686 sizeof(wl->conf.mem));
44687
44688 /* read data preparation is only needed by wl127x */
44689 - wl->ops->prepare_read = wl127x_prepare_read;
44690 + pax_open_kernel();
44691 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44692 + pax_close_kernel();
44693
44694 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44695 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44696 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44697 sizeof(wl->conf.mem));
44698
44699 /* read data preparation is only needed by wl127x */
44700 - wl->ops->prepare_read = wl127x_prepare_read;
44701 + pax_open_kernel();
44702 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44703 + pax_close_kernel();
44704
44705 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44706 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44707 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
44708 index 7aa0eb8..5a9ef38 100644
44709 --- a/drivers/net/wireless/ti/wl18xx/main.c
44710 +++ b/drivers/net/wireless/ti/wl18xx/main.c
44711 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
44712 }
44713
44714 if (!checksum_param) {
44715 - wl18xx_ops.set_rx_csum = NULL;
44716 - wl18xx_ops.init_vif = NULL;
44717 + pax_open_kernel();
44718 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
44719 + *(void **)&wl18xx_ops.init_vif = NULL;
44720 + pax_close_kernel();
44721 }
44722
44723 /* Enable 11a Band only if we have 5G antennas */
44724 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
44725 index 7ef0b4a..ff65c28 100644
44726 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
44727 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
44728 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
44729 {
44730 struct zd_usb *usb = urb->context;
44731 struct zd_usb_interrupt *intr = &usb->intr;
44732 - int len;
44733 + unsigned int len;
44734 u16 int_num;
44735
44736 ZD_ASSERT(in_interrupt());
44737 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
44738 index 59f95d8..53e0e7f 100644
44739 --- a/drivers/nfc/nfcwilink.c
44740 +++ b/drivers/nfc/nfcwilink.c
44741 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
44742
44743 static int nfcwilink_probe(struct platform_device *pdev)
44744 {
44745 - static struct nfcwilink *drv;
44746 + struct nfcwilink *drv;
44747 int rc;
44748 __u32 protocols;
44749
44750 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
44751 index d93b2b6..ae50401 100644
44752 --- a/drivers/oprofile/buffer_sync.c
44753 +++ b/drivers/oprofile/buffer_sync.c
44754 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
44755 if (cookie == NO_COOKIE)
44756 offset = pc;
44757 if (cookie == INVALID_COOKIE) {
44758 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44759 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44760 offset = pc;
44761 }
44762 if (cookie != last_cookie) {
44763 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
44764 /* add userspace sample */
44765
44766 if (!mm) {
44767 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
44768 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
44769 return 0;
44770 }
44771
44772 cookie = lookup_dcookie(mm, s->eip, &offset);
44773
44774 if (cookie == INVALID_COOKIE) {
44775 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44776 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44777 return 0;
44778 }
44779
44780 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
44781 /* ignore backtraces if failed to add a sample */
44782 if (state == sb_bt_start) {
44783 state = sb_bt_ignore;
44784 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
44785 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
44786 }
44787 }
44788 release_mm(mm);
44789 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
44790 index c0cc4e7..44d4e54 100644
44791 --- a/drivers/oprofile/event_buffer.c
44792 +++ b/drivers/oprofile/event_buffer.c
44793 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
44794 }
44795
44796 if (buffer_pos == buffer_size) {
44797 - atomic_inc(&oprofile_stats.event_lost_overflow);
44798 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
44799 return;
44800 }
44801
44802 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
44803 index ed2c3ec..deda85a 100644
44804 --- a/drivers/oprofile/oprof.c
44805 +++ b/drivers/oprofile/oprof.c
44806 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
44807 if (oprofile_ops.switch_events())
44808 return;
44809
44810 - atomic_inc(&oprofile_stats.multiplex_counter);
44811 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
44812 start_switch_worker();
44813 }
44814
44815 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
44816 index ee2cfce..7f8f699 100644
44817 --- a/drivers/oprofile/oprofile_files.c
44818 +++ b/drivers/oprofile/oprofile_files.c
44819 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
44820
44821 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
44822
44823 -static ssize_t timeout_read(struct file *file, char __user *buf,
44824 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
44825 size_t count, loff_t *offset)
44826 {
44827 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
44828 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
44829 index 59659ce..6c860a0 100644
44830 --- a/drivers/oprofile/oprofile_stats.c
44831 +++ b/drivers/oprofile/oprofile_stats.c
44832 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
44833 cpu_buf->sample_invalid_eip = 0;
44834 }
44835
44836 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
44837 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
44838 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
44839 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
44840 - atomic_set(&oprofile_stats.multiplex_counter, 0);
44841 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
44842 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
44843 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
44844 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
44845 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
44846 }
44847
44848
44849 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
44850 index 1fc622b..8c48fc3 100644
44851 --- a/drivers/oprofile/oprofile_stats.h
44852 +++ b/drivers/oprofile/oprofile_stats.h
44853 @@ -13,11 +13,11 @@
44854 #include <linux/atomic.h>
44855
44856 struct oprofile_stat_struct {
44857 - atomic_t sample_lost_no_mm;
44858 - atomic_t sample_lost_no_mapping;
44859 - atomic_t bt_lost_no_mapping;
44860 - atomic_t event_lost_overflow;
44861 - atomic_t multiplex_counter;
44862 + atomic_unchecked_t sample_lost_no_mm;
44863 + atomic_unchecked_t sample_lost_no_mapping;
44864 + atomic_unchecked_t bt_lost_no_mapping;
44865 + atomic_unchecked_t event_lost_overflow;
44866 + atomic_unchecked_t multiplex_counter;
44867 };
44868
44869 extern struct oprofile_stat_struct oprofile_stats;
44870 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
44871 index 3f49345..c750d0b 100644
44872 --- a/drivers/oprofile/oprofilefs.c
44873 +++ b/drivers/oprofile/oprofilefs.c
44874 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
44875
44876 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
44877 {
44878 - atomic_t *val = file->private_data;
44879 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
44880 + atomic_unchecked_t *val = file->private_data;
44881 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
44882 }
44883
44884
44885 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
44886
44887
44888 int oprofilefs_create_ro_atomic(struct dentry *root,
44889 - char const *name, atomic_t *val)
44890 + char const *name, atomic_unchecked_t *val)
44891 {
44892 return __oprofilefs_create_file(root, name,
44893 &atomic_ro_fops, 0444, val);
44894 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
44895 index 61be1d9..dec05d7 100644
44896 --- a/drivers/oprofile/timer_int.c
44897 +++ b/drivers/oprofile/timer_int.c
44898 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
44899 return NOTIFY_OK;
44900 }
44901
44902 -static struct notifier_block __refdata oprofile_cpu_notifier = {
44903 +static struct notifier_block oprofile_cpu_notifier = {
44904 .notifier_call = oprofile_cpu_notify,
44905 };
44906
44907 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
44908 index 92ed045..62d39bd7 100644
44909 --- a/drivers/parport/procfs.c
44910 +++ b/drivers/parport/procfs.c
44911 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
44912
44913 *ppos += len;
44914
44915 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
44916 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
44917 }
44918
44919 #ifdef CONFIG_PARPORT_1284
44920 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
44921
44922 *ppos += len;
44923
44924 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
44925 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
44926 }
44927 #endif /* IEEE1284.3 support. */
44928
44929 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
44930 index 2f5786c..61ab4d1 100644
44931 --- a/drivers/pci/hotplug/acpiphp_ibm.c
44932 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
44933 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
44934 goto init_cleanup;
44935 }
44936
44937 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
44938 + pax_open_kernel();
44939 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
44940 + pax_close_kernel();
44941 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
44942
44943 return retval;
44944 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
44945 index a6a71c4..c91097b 100644
44946 --- a/drivers/pci/hotplug/cpcihp_generic.c
44947 +++ b/drivers/pci/hotplug/cpcihp_generic.c
44948 @@ -73,7 +73,6 @@ static u16 port;
44949 static unsigned int enum_bit;
44950 static u8 enum_mask;
44951
44952 -static struct cpci_hp_controller_ops generic_hpc_ops;
44953 static struct cpci_hp_controller generic_hpc;
44954
44955 static int __init validate_parameters(void)
44956 @@ -139,6 +138,10 @@ static int query_enum(void)
44957 return ((value & enum_mask) == enum_mask);
44958 }
44959
44960 +static struct cpci_hp_controller_ops generic_hpc_ops = {
44961 + .query_enum = query_enum,
44962 +};
44963 +
44964 static int __init cpcihp_generic_init(void)
44965 {
44966 int status;
44967 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
44968 pci_dev_put(dev);
44969
44970 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
44971 - generic_hpc_ops.query_enum = query_enum;
44972 generic_hpc.ops = &generic_hpc_ops;
44973
44974 status = cpci_hp_register_controller(&generic_hpc);
44975 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
44976 index 449b4bb..257e2e8 100644
44977 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
44978 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
44979 @@ -59,7 +59,6 @@
44980 /* local variables */
44981 static bool debug;
44982 static bool poll;
44983 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
44984 static struct cpci_hp_controller zt5550_hpc;
44985
44986 /* Primary cPCI bus bridge device */
44987 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
44988 return 0;
44989 }
44990
44991 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
44992 + .query_enum = zt5550_hc_query_enum,
44993 +};
44994 +
44995 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
44996 {
44997 int status;
44998 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
44999 dbg("returned from zt5550_hc_config");
45000
45001 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45002 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45003 zt5550_hpc.ops = &zt5550_hpc_ops;
45004 if(!poll) {
45005 zt5550_hpc.irq = hc_dev->irq;
45006 zt5550_hpc.irq_flags = IRQF_SHARED;
45007 zt5550_hpc.dev_id = hc_dev;
45008
45009 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45010 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45011 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45012 + pax_open_kernel();
45013 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45014 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45015 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45016 + pax_open_kernel();
45017 } else {
45018 info("using ENUM# polling mode");
45019 }
45020 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45021 index 76ba8a1..20ca857 100644
45022 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45023 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45024 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45025
45026 void compaq_nvram_init (void __iomem *rom_start)
45027 {
45028 +
45029 +#ifndef CONFIG_PAX_KERNEXEC
45030 if (rom_start) {
45031 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45032 }
45033 +#endif
45034 +
45035 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45036
45037 /* initialize our int15 lock */
45038 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45039 index ec20f74..c1d961e 100644
45040 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45041 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45042 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45043 return -EINVAL;
45044 }
45045
45046 - slot->ops->owner = owner;
45047 - slot->ops->mod_name = mod_name;
45048 + pax_open_kernel();
45049 + *(struct module **)&slot->ops->owner = owner;
45050 + *(const char **)&slot->ops->mod_name = mod_name;
45051 + pax_close_kernel();
45052
45053 mutex_lock(&pci_hp_mutex);
45054 /*
45055 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45056 index f4a18f5..ff2463c 100644
45057 --- a/drivers/pci/hotplug/pciehp_core.c
45058 +++ b/drivers/pci/hotplug/pciehp_core.c
45059 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45060 struct slot *slot = ctrl->slot;
45061 struct hotplug_slot *hotplug = NULL;
45062 struct hotplug_slot_info *info = NULL;
45063 - struct hotplug_slot_ops *ops = NULL;
45064 + hotplug_slot_ops_no_const *ops = NULL;
45065 char name[SLOT_NAME_SIZE];
45066 int retval = -ENOMEM;
45067
45068 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45069 index 7128cfd..a0640d6 100644
45070 --- a/drivers/pci/pci-sysfs.c
45071 +++ b/drivers/pci/pci-sysfs.c
45072 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45073 {
45074 /* allocate attribute structure, piggyback attribute name */
45075 int name_len = write_combine ? 13 : 10;
45076 - struct bin_attribute *res_attr;
45077 + bin_attribute_no_const *res_attr;
45078 int retval;
45079
45080 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45081 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45082 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45083 {
45084 int retval;
45085 - struct bin_attribute *attr;
45086 + bin_attribute_no_const *attr;
45087
45088 /* If the device has VPD, try to expose it in sysfs. */
45089 if (dev->vpd) {
45090 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45091 {
45092 int retval;
45093 int rom_size = 0;
45094 - struct bin_attribute *attr;
45095 + bin_attribute_no_const *attr;
45096
45097 if (!sysfs_initialized)
45098 return -EACCES;
45099 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45100 index 8a00c06..18a9715 100644
45101 --- a/drivers/pci/pci.h
45102 +++ b/drivers/pci/pci.h
45103 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45104 struct pci_vpd {
45105 unsigned int len;
45106 const struct pci_vpd_ops *ops;
45107 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45108 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45109 };
45110
45111 int pci_vpd_pci22_init(struct pci_dev *dev);
45112 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45113 index 403a443..034e050 100644
45114 --- a/drivers/pci/pcie/aspm.c
45115 +++ b/drivers/pci/pcie/aspm.c
45116 @@ -27,9 +27,9 @@
45117 #define MODULE_PARAM_PREFIX "pcie_aspm."
45118
45119 /* Note: those are not register definitions */
45120 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45121 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45122 -#define ASPM_STATE_L1 (4) /* L1 state */
45123 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45124 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45125 +#define ASPM_STATE_L1 (4U) /* L1 state */
45126 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45127 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45128
45129 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45130 index 7ef0f86..17b710f 100644
45131 --- a/drivers/pci/probe.c
45132 +++ b/drivers/pci/probe.c
45133 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45134 struct pci_bus_region region, inverted_region;
45135 bool bar_too_big = false, bar_disabled = false;
45136
45137 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45138 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45139
45140 /* No printks while decoding is disabled! */
45141 if (!dev->mmio_always_on) {
45142 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45143 index cdc7836..528635c 100644
45144 --- a/drivers/pci/proc.c
45145 +++ b/drivers/pci/proc.c
45146 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45147 static int __init pci_proc_init(void)
45148 {
45149 struct pci_dev *dev = NULL;
45150 +
45151 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45152 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45153 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45154 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45155 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45156 +#endif
45157 +#else
45158 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45159 +#endif
45160 proc_create("devices", 0, proc_bus_pci_dir,
45161 &proc_bus_pci_dev_operations);
45162 proc_initialized = 1;
45163 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45164 index 3e5b4497..dcdfb70 100644
45165 --- a/drivers/platform/x86/chromeos_laptop.c
45166 +++ b/drivers/platform/x86/chromeos_laptop.c
45167 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45168 return 0;
45169 }
45170
45171 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45172 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45173 {
45174 .ident = "Samsung Series 5 550 - Touchpad",
45175 .matches = {
45176 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45177 index 62f8030..c7f2a45 100644
45178 --- a/drivers/platform/x86/msi-laptop.c
45179 +++ b/drivers/platform/x86/msi-laptop.c
45180 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45181
45182 if (!quirks->ec_read_only) {
45183 /* allow userland write sysfs file */
45184 - dev_attr_bluetooth.store = store_bluetooth;
45185 - dev_attr_wlan.store = store_wlan;
45186 - dev_attr_threeg.store = store_threeg;
45187 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45188 - dev_attr_wlan.attr.mode |= S_IWUSR;
45189 - dev_attr_threeg.attr.mode |= S_IWUSR;
45190 + pax_open_kernel();
45191 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45192 + *(void **)&dev_attr_wlan.store = store_wlan;
45193 + *(void **)&dev_attr_threeg.store = store_threeg;
45194 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45195 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45196 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45197 + pax_close_kernel();
45198 }
45199
45200 /* disable hardware control by fn key */
45201 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45202 index 70222f2..8c8ce66 100644
45203 --- a/drivers/platform/x86/msi-wmi.c
45204 +++ b/drivers/platform/x86/msi-wmi.c
45205 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45206 static void msi_wmi_notify(u32 value, void *context)
45207 {
45208 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45209 - static struct key_entry *key;
45210 + struct key_entry *key;
45211 union acpi_object *obj;
45212 acpi_status status;
45213
45214 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45215 index 13ec195..6af61af 100644
45216 --- a/drivers/platform/x86/sony-laptop.c
45217 +++ b/drivers/platform/x86/sony-laptop.c
45218 @@ -2475,7 +2475,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45219 }
45220
45221 /* High speed charging function */
45222 -static struct device_attribute *hsc_handle;
45223 +static device_attribute_no_const *hsc_handle;
45224
45225 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45226 struct device_attribute *attr,
45227 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45228 index 4e86e97..04d50d1 100644
45229 --- a/drivers/platform/x86/thinkpad_acpi.c
45230 +++ b/drivers/platform/x86/thinkpad_acpi.c
45231 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45232 return 0;
45233 }
45234
45235 -void static hotkey_mask_warn_incomplete_mask(void)
45236 +static void hotkey_mask_warn_incomplete_mask(void)
45237 {
45238 /* log only what the user can fix... */
45239 const u32 wantedmask = hotkey_driver_mask &
45240 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45241 }
45242 }
45243
45244 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45245 - struct tp_nvram_state *newn,
45246 - const u32 event_mask)
45247 -{
45248 -
45249 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45250 do { \
45251 if ((event_mask & (1 << __scancode)) && \
45252 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45253 tpacpi_hotkey_send_key(__scancode); \
45254 } while (0)
45255
45256 - void issue_volchange(const unsigned int oldvol,
45257 - const unsigned int newvol)
45258 - {
45259 - unsigned int i = oldvol;
45260 +static void issue_volchange(const unsigned int oldvol,
45261 + const unsigned int newvol,
45262 + const u32 event_mask)
45263 +{
45264 + unsigned int i = oldvol;
45265
45266 - while (i > newvol) {
45267 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45268 - i--;
45269 - }
45270 - while (i < newvol) {
45271 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45272 - i++;
45273 - }
45274 + while (i > newvol) {
45275 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45276 + i--;
45277 }
45278 + while (i < newvol) {
45279 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45280 + i++;
45281 + }
45282 +}
45283
45284 - void issue_brightnesschange(const unsigned int oldbrt,
45285 - const unsigned int newbrt)
45286 - {
45287 - unsigned int i = oldbrt;
45288 +static void issue_brightnesschange(const unsigned int oldbrt,
45289 + const unsigned int newbrt,
45290 + const u32 event_mask)
45291 +{
45292 + unsigned int i = oldbrt;
45293
45294 - while (i > newbrt) {
45295 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45296 - i--;
45297 - }
45298 - while (i < newbrt) {
45299 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45300 - i++;
45301 - }
45302 + while (i > newbrt) {
45303 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45304 + i--;
45305 + }
45306 + while (i < newbrt) {
45307 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45308 + i++;
45309 }
45310 +}
45311
45312 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45313 + struct tp_nvram_state *newn,
45314 + const u32 event_mask)
45315 +{
45316 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45317 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45318 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45319 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45320 oldn->volume_level != newn->volume_level) {
45321 /* recently muted, or repeated mute keypress, or
45322 * multiple presses ending in mute */
45323 - issue_volchange(oldn->volume_level, newn->volume_level);
45324 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45325 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45326 }
45327 } else {
45328 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45329 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45330 }
45331 if (oldn->volume_level != newn->volume_level) {
45332 - issue_volchange(oldn->volume_level, newn->volume_level);
45333 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45334 } else if (oldn->volume_toggle != newn->volume_toggle) {
45335 /* repeated vol up/down keypress at end of scale ? */
45336 if (newn->volume_level == 0)
45337 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45338 /* handle brightness */
45339 if (oldn->brightness_level != newn->brightness_level) {
45340 issue_brightnesschange(oldn->brightness_level,
45341 - newn->brightness_level);
45342 + newn->brightness_level,
45343 + event_mask);
45344 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45345 /* repeated key presses that didn't change state */
45346 if (newn->brightness_level == 0)
45347 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45348 && !tp_features.bright_unkfw)
45349 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45350 }
45351 +}
45352
45353 #undef TPACPI_COMPARE_KEY
45354 #undef TPACPI_MAY_SEND_KEY
45355 -}
45356
45357 /*
45358 * Polling driver
45359 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45360 index 769d265..a3a05ca 100644
45361 --- a/drivers/pnp/pnpbios/bioscalls.c
45362 +++ b/drivers/pnp/pnpbios/bioscalls.c
45363 @@ -58,7 +58,7 @@ do { \
45364 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45365 } while(0)
45366
45367 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45368 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45369 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45370
45371 /*
45372 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45373
45374 cpu = get_cpu();
45375 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45376 +
45377 + pax_open_kernel();
45378 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45379 + pax_close_kernel();
45380
45381 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45382 spin_lock_irqsave(&pnp_bios_lock, flags);
45383 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45384 :"memory");
45385 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45386
45387 + pax_open_kernel();
45388 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45389 + pax_close_kernel();
45390 +
45391 put_cpu();
45392
45393 /* If we get here and this is set then the PnP BIOS faulted on us. */
45394 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45395 return status;
45396 }
45397
45398 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45399 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45400 {
45401 int i;
45402
45403 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45404 pnp_bios_callpoint.offset = header->fields.pm16offset;
45405 pnp_bios_callpoint.segment = PNP_CS16;
45406
45407 + pax_open_kernel();
45408 +
45409 for_each_possible_cpu(i) {
45410 struct desc_struct *gdt = get_cpu_gdt_table(i);
45411 if (!gdt)
45412 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45413 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45414 (unsigned long)__va(header->fields.pm16dseg));
45415 }
45416 +
45417 + pax_close_kernel();
45418 }
45419 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45420 index d95e101..67f0c3f 100644
45421 --- a/drivers/pnp/resource.c
45422 +++ b/drivers/pnp/resource.c
45423 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45424 return 1;
45425
45426 /* check if the resource is valid */
45427 - if (*irq < 0 || *irq > 15)
45428 + if (*irq > 15)
45429 return 0;
45430
45431 /* check if the resource is reserved */
45432 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45433 return 1;
45434
45435 /* check if the resource is valid */
45436 - if (*dma < 0 || *dma == 4 || *dma > 7)
45437 + if (*dma == 4 || *dma > 7)
45438 return 0;
45439
45440 /* check if the resource is reserved */
45441 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45442 index 0c52e2a..3421ab7 100644
45443 --- a/drivers/power/pda_power.c
45444 +++ b/drivers/power/pda_power.c
45445 @@ -37,7 +37,11 @@ static int polling;
45446
45447 #if IS_ENABLED(CONFIG_USB_PHY)
45448 static struct usb_phy *transceiver;
45449 -static struct notifier_block otg_nb;
45450 +static int otg_handle_notification(struct notifier_block *nb,
45451 + unsigned long event, void *unused);
45452 +static struct notifier_block otg_nb = {
45453 + .notifier_call = otg_handle_notification
45454 +};
45455 #endif
45456
45457 static struct regulator *ac_draw;
45458 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45459
45460 #if IS_ENABLED(CONFIG_USB_PHY)
45461 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45462 - otg_nb.notifier_call = otg_handle_notification;
45463 ret = usb_register_notifier(transceiver, &otg_nb);
45464 if (ret) {
45465 dev_err(dev, "failure to register otg notifier\n");
45466 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45467 index cc439fd..8fa30df 100644
45468 --- a/drivers/power/power_supply.h
45469 +++ b/drivers/power/power_supply.h
45470 @@ -16,12 +16,12 @@ struct power_supply;
45471
45472 #ifdef CONFIG_SYSFS
45473
45474 -extern void power_supply_init_attrs(struct device_type *dev_type);
45475 +extern void power_supply_init_attrs(void);
45476 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45477
45478 #else
45479
45480 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45481 +static inline void power_supply_init_attrs(void) {}
45482 #define power_supply_uevent NULL
45483
45484 #endif /* CONFIG_SYSFS */
45485 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45486 index 00e6672..2642c08 100644
45487 --- a/drivers/power/power_supply_core.c
45488 +++ b/drivers/power/power_supply_core.c
45489 @@ -24,7 +24,10 @@
45490 struct class *power_supply_class;
45491 EXPORT_SYMBOL_GPL(power_supply_class);
45492
45493 -static struct device_type power_supply_dev_type;
45494 +extern const struct attribute_group *power_supply_attr_groups[];
45495 +static struct device_type power_supply_dev_type = {
45496 + .groups = power_supply_attr_groups,
45497 +};
45498
45499 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45500 struct power_supply *supply)
45501 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
45502 return PTR_ERR(power_supply_class);
45503
45504 power_supply_class->dev_uevent = power_supply_uevent;
45505 - power_supply_init_attrs(&power_supply_dev_type);
45506 + power_supply_init_attrs();
45507
45508 return 0;
45509 }
45510 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45511 index 44420d1..967126e 100644
45512 --- a/drivers/power/power_supply_sysfs.c
45513 +++ b/drivers/power/power_supply_sysfs.c
45514 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45515 .is_visible = power_supply_attr_is_visible,
45516 };
45517
45518 -static const struct attribute_group *power_supply_attr_groups[] = {
45519 +const struct attribute_group *power_supply_attr_groups[] = {
45520 &power_supply_attr_group,
45521 NULL,
45522 };
45523
45524 -void power_supply_init_attrs(struct device_type *dev_type)
45525 +void power_supply_init_attrs(void)
45526 {
45527 int i;
45528
45529 - dev_type->groups = power_supply_attr_groups;
45530 -
45531 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45532 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45533 }
45534 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45535 index a01b8b3..37c2afe 100644
45536 --- a/drivers/regulator/core.c
45537 +++ b/drivers/regulator/core.c
45538 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45539 {
45540 const struct regulation_constraints *constraints = NULL;
45541 const struct regulator_init_data *init_data;
45542 - static atomic_t regulator_no = ATOMIC_INIT(0);
45543 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45544 struct regulator_dev *rdev;
45545 struct device *dev;
45546 int ret, i;
45547 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45548 rdev->dev.of_node = config->of_node;
45549 rdev->dev.parent = dev;
45550 dev_set_name(&rdev->dev, "regulator.%d",
45551 - atomic_inc_return(&regulator_no) - 1);
45552 + atomic_inc_return_unchecked(&regulator_no) - 1);
45553 ret = device_register(&rdev->dev);
45554 if (ret != 0) {
45555 put_device(&rdev->dev);
45556 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45557 index 144bcac..d20e7db 100644
45558 --- a/drivers/regulator/max8660.c
45559 +++ b/drivers/regulator/max8660.c
45560 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
45561 max8660->shadow_regs[MAX8660_OVER1] = 5;
45562 } else {
45563 /* Otherwise devices can be toggled via software */
45564 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45565 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45566 + pax_open_kernel();
45567 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45568 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45569 + pax_close_kernel();
45570 }
45571
45572 /*
45573 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45574 index 5b77ab7..a62f061 100644
45575 --- a/drivers/regulator/max8973-regulator.c
45576 +++ b/drivers/regulator/max8973-regulator.c
45577 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45578 if (!pdata || !pdata->enable_ext_control) {
45579 max->desc.enable_reg = MAX8973_VOUT;
45580 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45581 - max->ops.enable = regulator_enable_regmap;
45582 - max->ops.disable = regulator_disable_regmap;
45583 - max->ops.is_enabled = regulator_is_enabled_regmap;
45584 + pax_open_kernel();
45585 + *(void **)&max->ops.enable = regulator_enable_regmap;
45586 + *(void **)&max->ops.disable = regulator_disable_regmap;
45587 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45588 + pax_close_kernel();
45589 }
45590
45591 if (pdata) {
45592 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45593 index 1037e07..e64dea1 100644
45594 --- a/drivers/regulator/mc13892-regulator.c
45595 +++ b/drivers/regulator/mc13892-regulator.c
45596 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45597 }
45598 mc13xxx_unlock(mc13892);
45599
45600 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45601 + pax_open_kernel();
45602 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45603 = mc13892_vcam_set_mode;
45604 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45605 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45606 = mc13892_vcam_get_mode;
45607 + pax_close_kernel();
45608
45609 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
45610 ARRAY_SIZE(mc13892_regulators));
45611 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
45612 index 24e733c..bfbaa3e 100644
45613 --- a/drivers/rtc/rtc-cmos.c
45614 +++ b/drivers/rtc/rtc-cmos.c
45615 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
45616 hpet_rtc_timer_init();
45617
45618 /* export at least the first block of NVRAM */
45619 - nvram.size = address_space - NVRAM_OFFSET;
45620 + pax_open_kernel();
45621 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
45622 + pax_close_kernel();
45623 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
45624 if (retval < 0) {
45625 dev_dbg(dev, "can't create nvram file? %d\n", retval);
45626 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
45627 index d049393..bb20be0 100644
45628 --- a/drivers/rtc/rtc-dev.c
45629 +++ b/drivers/rtc/rtc-dev.c
45630 @@ -16,6 +16,7 @@
45631 #include <linux/module.h>
45632 #include <linux/rtc.h>
45633 #include <linux/sched.h>
45634 +#include <linux/grsecurity.h>
45635 #include "rtc-core.h"
45636
45637 static dev_t rtc_devt;
45638 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
45639 if (copy_from_user(&tm, uarg, sizeof(tm)))
45640 return -EFAULT;
45641
45642 + gr_log_timechange();
45643 +
45644 return rtc_set_time(rtc, &tm);
45645
45646 case RTC_PIE_ON:
45647 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
45648 index ca18fd1..055e42d 100644
45649 --- a/drivers/rtc/rtc-ds1307.c
45650 +++ b/drivers/rtc/rtc-ds1307.c
45651 @@ -107,7 +107,7 @@ struct ds1307 {
45652 u8 offset; /* register's offset */
45653 u8 regs[11];
45654 u16 nvram_offset;
45655 - struct bin_attribute *nvram;
45656 + bin_attribute_no_const *nvram;
45657 enum ds_type type;
45658 unsigned long flags;
45659 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
45660 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
45661 index fcb0329..d77b7f2 100644
45662 --- a/drivers/rtc/rtc-m48t59.c
45663 +++ b/drivers/rtc/rtc-m48t59.c
45664 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
45665 if (IS_ERR(m48t59->rtc))
45666 return PTR_ERR(m48t59->rtc);
45667
45668 - m48t59_nvram_attr.size = pdata->offset;
45669 + pax_open_kernel();
45670 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
45671 + pax_close_kernel();
45672
45673 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
45674 if (ret)
45675 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
45676 index 14b5f8d..cc9bd26 100644
45677 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
45678 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
45679 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
45680 for (bit = 0; bit < 8; bit++) {
45681
45682 if ((pci_status[i] & (0x1 << bit)) != 0) {
45683 - static const char *s;
45684 + const char *s;
45685
45686 s = pci_status_strings[bit];
45687 if (i == 7/*TARG*/ && bit == 3)
45688 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
45689
45690 for (bit = 0; bit < 8; bit++) {
45691
45692 - if ((split_status[i] & (0x1 << bit)) != 0) {
45693 - static const char *s;
45694 -
45695 - s = split_status_strings[bit];
45696 - printk(s, ahd_name(ahd),
45697 + if ((split_status[i] & (0x1 << bit)) != 0)
45698 + printk(split_status_strings[bit], ahd_name(ahd),
45699 split_status_source[i]);
45700 - }
45701
45702 if (i > 1)
45703 continue;
45704
45705 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
45706 - static const char *s;
45707 -
45708 - s = split_status_strings[bit];
45709 - printk(s, ahd_name(ahd), "SG");
45710 - }
45711 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
45712 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
45713 }
45714 }
45715 /*
45716 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
45717 index e693af6..2e525b6 100644
45718 --- a/drivers/scsi/bfa/bfa_fcpim.h
45719 +++ b/drivers/scsi/bfa/bfa_fcpim.h
45720 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
45721
45722 struct bfa_itn_s {
45723 bfa_isr_func_t isr;
45724 -};
45725 +} __no_const;
45726
45727 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
45728 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
45729 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
45730 index 90814fe..4384138 100644
45731 --- a/drivers/scsi/bfa/bfa_ioc.h
45732 +++ b/drivers/scsi/bfa/bfa_ioc.h
45733 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
45734 bfa_ioc_disable_cbfn_t disable_cbfn;
45735 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
45736 bfa_ioc_reset_cbfn_t reset_cbfn;
45737 -};
45738 +} __no_const;
45739
45740 /*
45741 * IOC event notification mechanism.
45742 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
45743 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
45744 enum bfi_ioc_state fwstate);
45745 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
45746 -};
45747 +} __no_const;
45748
45749 /*
45750 * Queue element to wait for room in request queue. FIFO order is
45751 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
45752 index c9382d6..6619864 100644
45753 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
45754 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
45755 @@ -33,8 +33,8 @@
45756 */
45757 #include "libfcoe.h"
45758
45759 -static atomic_t ctlr_num;
45760 -static atomic_t fcf_num;
45761 +static atomic_unchecked_t ctlr_num;
45762 +static atomic_unchecked_t fcf_num;
45763
45764 /*
45765 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
45766 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
45767 if (!ctlr)
45768 goto out;
45769
45770 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
45771 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
45772 ctlr->f = f;
45773 ctlr->mode = FIP_CONN_TYPE_FABRIC;
45774 INIT_LIST_HEAD(&ctlr->fcfs);
45775 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
45776 fcf->dev.parent = &ctlr->dev;
45777 fcf->dev.bus = &fcoe_bus_type;
45778 fcf->dev.type = &fcoe_fcf_device_type;
45779 - fcf->id = atomic_inc_return(&fcf_num) - 1;
45780 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
45781 fcf->state = FCOE_FCF_STATE_UNKNOWN;
45782
45783 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
45784 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
45785 {
45786 int error;
45787
45788 - atomic_set(&ctlr_num, 0);
45789 - atomic_set(&fcf_num, 0);
45790 + atomic_set_unchecked(&ctlr_num, 0);
45791 + atomic_set_unchecked(&fcf_num, 0);
45792
45793 error = bus_register(&fcoe_bus_type);
45794 if (error)
45795 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
45796 index df0c3c7..b00e1d0 100644
45797 --- a/drivers/scsi/hosts.c
45798 +++ b/drivers/scsi/hosts.c
45799 @@ -42,7 +42,7 @@
45800 #include "scsi_logging.h"
45801
45802
45803 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45804 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45805
45806
45807 static void scsi_host_cls_release(struct device *dev)
45808 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
45809 * subtract one because we increment first then return, but we need to
45810 * know what the next host number was before increment
45811 */
45812 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
45813 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
45814 shost->dma_channel = 0xff;
45815
45816 /* These three are default values which can be overridden */
45817 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
45818 index 891c86b..dd1224a0 100644
45819 --- a/drivers/scsi/hpsa.c
45820 +++ b/drivers/scsi/hpsa.c
45821 @@ -578,7 +578,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
45822 unsigned long flags;
45823
45824 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
45825 - return h->access.command_completed(h, q);
45826 + return h->access->command_completed(h, q);
45827
45828 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
45829 a = rq->head[rq->current_entry];
45830 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
45831 while (!list_empty(&h->reqQ)) {
45832 c = list_entry(h->reqQ.next, struct CommandList, list);
45833 /* can't do anything if fifo is full */
45834 - if ((h->access.fifo_full(h))) {
45835 + if ((h->access->fifo_full(h))) {
45836 dev_warn(&h->pdev->dev, "fifo full\n");
45837 break;
45838 }
45839 @@ -3466,7 +3466,7 @@ static void start_io(struct ctlr_info *h)
45840
45841 /* Tell the controller execute command */
45842 spin_unlock_irqrestore(&h->lock, flags);
45843 - h->access.submit_command(h, c);
45844 + h->access->submit_command(h, c);
45845 spin_lock_irqsave(&h->lock, flags);
45846 }
45847 spin_unlock_irqrestore(&h->lock, flags);
45848 @@ -3474,17 +3474,17 @@ static void start_io(struct ctlr_info *h)
45849
45850 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
45851 {
45852 - return h->access.command_completed(h, q);
45853 + return h->access->command_completed(h, q);
45854 }
45855
45856 static inline bool interrupt_pending(struct ctlr_info *h)
45857 {
45858 - return h->access.intr_pending(h);
45859 + return h->access->intr_pending(h);
45860 }
45861
45862 static inline long interrupt_not_for_us(struct ctlr_info *h)
45863 {
45864 - return (h->access.intr_pending(h) == 0) ||
45865 + return (h->access->intr_pending(h) == 0) ||
45866 (h->interrupts_enabled == 0);
45867 }
45868
45869 @@ -4386,7 +4386,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
45870 if (prod_index < 0)
45871 return -ENODEV;
45872 h->product_name = products[prod_index].product_name;
45873 - h->access = *(products[prod_index].access);
45874 + h->access = products[prod_index].access;
45875
45876 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
45877 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
45878 @@ -4668,7 +4668,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
45879
45880 assert_spin_locked(&lockup_detector_lock);
45881 remove_ctlr_from_lockup_detector_list(h);
45882 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45883 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45884 spin_lock_irqsave(&h->lock, flags);
45885 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
45886 spin_unlock_irqrestore(&h->lock, flags);
45887 @@ -4845,7 +4845,7 @@ reinit_after_soft_reset:
45888 }
45889
45890 /* make sure the board interrupts are off */
45891 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45892 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45893
45894 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
45895 goto clean2;
45896 @@ -4879,7 +4879,7 @@ reinit_after_soft_reset:
45897 * fake ones to scoop up any residual completions.
45898 */
45899 spin_lock_irqsave(&h->lock, flags);
45900 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45901 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45902 spin_unlock_irqrestore(&h->lock, flags);
45903 free_irqs(h);
45904 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
45905 @@ -4898,9 +4898,9 @@ reinit_after_soft_reset:
45906 dev_info(&h->pdev->dev, "Board READY.\n");
45907 dev_info(&h->pdev->dev,
45908 "Waiting for stale completions to drain.\n");
45909 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45910 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45911 msleep(10000);
45912 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45913 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45914
45915 rc = controller_reset_failed(h->cfgtable);
45916 if (rc)
45917 @@ -4921,7 +4921,7 @@ reinit_after_soft_reset:
45918 }
45919
45920 /* Turn the interrupts on so we can service requests */
45921 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45922 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45923
45924 hpsa_hba_inquiry(h);
45925 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
45926 @@ -4976,7 +4976,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
45927 * To write all data in the battery backed cache to disks
45928 */
45929 hpsa_flush_cache(h);
45930 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45931 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45932 hpsa_free_irqs_and_disable_msix(h);
45933 }
45934
45935 @@ -5144,7 +5144,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
45936 return;
45937 }
45938 /* Change the access methods to the performant access methods */
45939 - h->access = SA5_performant_access;
45940 + h->access = &SA5_performant_access;
45941 h->transMethod = CFGTBL_Trans_Performant;
45942 }
45943
45944 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
45945 index bc85e72..ae04a39 100644
45946 --- a/drivers/scsi/hpsa.h
45947 +++ b/drivers/scsi/hpsa.h
45948 @@ -79,7 +79,7 @@ struct ctlr_info {
45949 unsigned int msix_vector;
45950 unsigned int msi_vector;
45951 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
45952 - struct access_method access;
45953 + struct access_method *access;
45954
45955 /* queue and queue Info */
45956 struct list_head reqQ;
45957 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
45958 index 5879929..32b241d 100644
45959 --- a/drivers/scsi/libfc/fc_exch.c
45960 +++ b/drivers/scsi/libfc/fc_exch.c
45961 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
45962 u16 pool_max_index;
45963
45964 struct {
45965 - atomic_t no_free_exch;
45966 - atomic_t no_free_exch_xid;
45967 - atomic_t xid_not_found;
45968 - atomic_t xid_busy;
45969 - atomic_t seq_not_found;
45970 - atomic_t non_bls_resp;
45971 + atomic_unchecked_t no_free_exch;
45972 + atomic_unchecked_t no_free_exch_xid;
45973 + atomic_unchecked_t xid_not_found;
45974 + atomic_unchecked_t xid_busy;
45975 + atomic_unchecked_t seq_not_found;
45976 + atomic_unchecked_t non_bls_resp;
45977 } stats;
45978 };
45979
45980 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
45981 /* allocate memory for exchange */
45982 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
45983 if (!ep) {
45984 - atomic_inc(&mp->stats.no_free_exch);
45985 + atomic_inc_unchecked(&mp->stats.no_free_exch);
45986 goto out;
45987 }
45988 memset(ep, 0, sizeof(*ep));
45989 @@ -797,7 +797,7 @@ out:
45990 return ep;
45991 err:
45992 spin_unlock_bh(&pool->lock);
45993 - atomic_inc(&mp->stats.no_free_exch_xid);
45994 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
45995 mempool_free(ep, mp->ep_pool);
45996 return NULL;
45997 }
45998 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
45999 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46000 ep = fc_exch_find(mp, xid);
46001 if (!ep) {
46002 - atomic_inc(&mp->stats.xid_not_found);
46003 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46004 reject = FC_RJT_OX_ID;
46005 goto out;
46006 }
46007 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46008 ep = fc_exch_find(mp, xid);
46009 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46010 if (ep) {
46011 - atomic_inc(&mp->stats.xid_busy);
46012 + atomic_inc_unchecked(&mp->stats.xid_busy);
46013 reject = FC_RJT_RX_ID;
46014 goto rel;
46015 }
46016 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46017 }
46018 xid = ep->xid; /* get our XID */
46019 } else if (!ep) {
46020 - atomic_inc(&mp->stats.xid_not_found);
46021 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46022 reject = FC_RJT_RX_ID; /* XID not found */
46023 goto out;
46024 }
46025 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46026 } else {
46027 sp = &ep->seq;
46028 if (sp->id != fh->fh_seq_id) {
46029 - atomic_inc(&mp->stats.seq_not_found);
46030 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46031 if (f_ctl & FC_FC_END_SEQ) {
46032 /*
46033 * Update sequence_id based on incoming last
46034 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46035
46036 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46037 if (!ep) {
46038 - atomic_inc(&mp->stats.xid_not_found);
46039 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46040 goto out;
46041 }
46042 if (ep->esb_stat & ESB_ST_COMPLETE) {
46043 - atomic_inc(&mp->stats.xid_not_found);
46044 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46045 goto rel;
46046 }
46047 if (ep->rxid == FC_XID_UNKNOWN)
46048 ep->rxid = ntohs(fh->fh_rx_id);
46049 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46050 - atomic_inc(&mp->stats.xid_not_found);
46051 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46052 goto rel;
46053 }
46054 if (ep->did != ntoh24(fh->fh_s_id) &&
46055 ep->did != FC_FID_FLOGI) {
46056 - atomic_inc(&mp->stats.xid_not_found);
46057 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46058 goto rel;
46059 }
46060 sof = fr_sof(fp);
46061 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46062 sp->ssb_stat |= SSB_ST_RESP;
46063 sp->id = fh->fh_seq_id;
46064 } else if (sp->id != fh->fh_seq_id) {
46065 - atomic_inc(&mp->stats.seq_not_found);
46066 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46067 goto rel;
46068 }
46069
46070 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46071 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46072
46073 if (!sp)
46074 - atomic_inc(&mp->stats.xid_not_found);
46075 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46076 else
46077 - atomic_inc(&mp->stats.non_bls_resp);
46078 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46079
46080 fc_frame_free(fp);
46081 }
46082 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46083
46084 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46085 mp = ema->mp;
46086 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46087 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46088 st->fc_no_free_exch_xid +=
46089 - atomic_read(&mp->stats.no_free_exch_xid);
46090 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46091 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46092 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46093 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46094 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46095 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46096 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46097 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46098 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46099 }
46100 }
46101 EXPORT_SYMBOL(fc_exch_update_stats);
46102 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46103 index 161c98e..6d563b3 100644
46104 --- a/drivers/scsi/libsas/sas_ata.c
46105 +++ b/drivers/scsi/libsas/sas_ata.c
46106 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46107 .postreset = ata_std_postreset,
46108 .error_handler = ata_std_error_handler,
46109 .post_internal_cmd = sas_ata_post_internal,
46110 - .qc_defer = ata_std_qc_defer,
46111 + .qc_defer = ata_std_qc_defer,
46112 .qc_prep = ata_noop_qc_prep,
46113 .qc_issue = sas_ata_qc_issue,
46114 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46115 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46116 index 4e1b75c..0bbdfa9 100644
46117 --- a/drivers/scsi/lpfc/lpfc.h
46118 +++ b/drivers/scsi/lpfc/lpfc.h
46119 @@ -432,7 +432,7 @@ struct lpfc_vport {
46120 struct dentry *debug_nodelist;
46121 struct dentry *vport_debugfs_root;
46122 struct lpfc_debugfs_trc *disc_trc;
46123 - atomic_t disc_trc_cnt;
46124 + atomic_unchecked_t disc_trc_cnt;
46125 #endif
46126 uint8_t stat_data_enabled;
46127 uint8_t stat_data_blocked;
46128 @@ -865,8 +865,8 @@ struct lpfc_hba {
46129 struct timer_list fabric_block_timer;
46130 unsigned long bit_flags;
46131 #define FABRIC_COMANDS_BLOCKED 0
46132 - atomic_t num_rsrc_err;
46133 - atomic_t num_cmd_success;
46134 + atomic_unchecked_t num_rsrc_err;
46135 + atomic_unchecked_t num_cmd_success;
46136 unsigned long last_rsrc_error_time;
46137 unsigned long last_ramp_down_time;
46138 unsigned long last_ramp_up_time;
46139 @@ -902,7 +902,7 @@ struct lpfc_hba {
46140
46141 struct dentry *debug_slow_ring_trc;
46142 struct lpfc_debugfs_trc *slow_ring_trc;
46143 - atomic_t slow_ring_trc_cnt;
46144 + atomic_unchecked_t slow_ring_trc_cnt;
46145 /* iDiag debugfs sub-directory */
46146 struct dentry *idiag_root;
46147 struct dentry *idiag_pci_cfg;
46148 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46149 index 60084e6..0e2e700 100644
46150 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46151 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46152 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46153
46154 #include <linux/debugfs.h>
46155
46156 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46157 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46158 static unsigned long lpfc_debugfs_start_time = 0L;
46159
46160 /* iDiag */
46161 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46162 lpfc_debugfs_enable = 0;
46163
46164 len = 0;
46165 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46166 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46167 (lpfc_debugfs_max_disc_trc - 1);
46168 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46169 dtp = vport->disc_trc + i;
46170 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46171 lpfc_debugfs_enable = 0;
46172
46173 len = 0;
46174 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46175 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46176 (lpfc_debugfs_max_slow_ring_trc - 1);
46177 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46178 dtp = phba->slow_ring_trc + i;
46179 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46180 !vport || !vport->disc_trc)
46181 return;
46182
46183 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46184 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46185 (lpfc_debugfs_max_disc_trc - 1);
46186 dtp = vport->disc_trc + index;
46187 dtp->fmt = fmt;
46188 dtp->data1 = data1;
46189 dtp->data2 = data2;
46190 dtp->data3 = data3;
46191 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46192 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46193 dtp->jif = jiffies;
46194 #endif
46195 return;
46196 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46197 !phba || !phba->slow_ring_trc)
46198 return;
46199
46200 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46201 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46202 (lpfc_debugfs_max_slow_ring_trc - 1);
46203 dtp = phba->slow_ring_trc + index;
46204 dtp->fmt = fmt;
46205 dtp->data1 = data1;
46206 dtp->data2 = data2;
46207 dtp->data3 = data3;
46208 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46209 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46210 dtp->jif = jiffies;
46211 #endif
46212 return;
46213 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46214 "slow_ring buffer\n");
46215 goto debug_failed;
46216 }
46217 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46218 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46219 memset(phba->slow_ring_trc, 0,
46220 (sizeof(struct lpfc_debugfs_trc) *
46221 lpfc_debugfs_max_slow_ring_trc));
46222 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46223 "buffer\n");
46224 goto debug_failed;
46225 }
46226 - atomic_set(&vport->disc_trc_cnt, 0);
46227 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46228
46229 snprintf(name, sizeof(name), "discovery_trace");
46230 vport->debug_disc_trc =
46231 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46232 index 647f5bf..d0068b9 100644
46233 --- a/drivers/scsi/lpfc/lpfc_init.c
46234 +++ b/drivers/scsi/lpfc/lpfc_init.c
46235 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46236 "misc_register returned with status %d", error);
46237
46238 if (lpfc_enable_npiv) {
46239 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46240 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46241 + pax_open_kernel();
46242 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46243 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46244 + pax_close_kernel();
46245 }
46246 lpfc_transport_template =
46247 fc_attach_transport(&lpfc_transport_functions);
46248 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46249 index c913e8c..d34a119 100644
46250 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46251 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46252 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46253 uint32_t evt_posted;
46254
46255 spin_lock_irqsave(&phba->hbalock, flags);
46256 - atomic_inc(&phba->num_rsrc_err);
46257 + atomic_inc_unchecked(&phba->num_rsrc_err);
46258 phba->last_rsrc_error_time = jiffies;
46259
46260 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46261 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46262 unsigned long flags;
46263 struct lpfc_hba *phba = vport->phba;
46264 uint32_t evt_posted;
46265 - atomic_inc(&phba->num_cmd_success);
46266 + atomic_inc_unchecked(&phba->num_cmd_success);
46267
46268 if (vport->cfg_lun_queue_depth <= queue_depth)
46269 return;
46270 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46271 unsigned long num_rsrc_err, num_cmd_success;
46272 int i;
46273
46274 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46275 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46276 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46277 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46278
46279 /*
46280 * The error and success command counters are global per
46281 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46282 }
46283 }
46284 lpfc_destroy_vport_work_array(phba, vports);
46285 - atomic_set(&phba->num_rsrc_err, 0);
46286 - atomic_set(&phba->num_cmd_success, 0);
46287 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46288 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46289 }
46290
46291 /**
46292 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46293 }
46294 }
46295 lpfc_destroy_vport_work_array(phba, vports);
46296 - atomic_set(&phba->num_rsrc_err, 0);
46297 - atomic_set(&phba->num_cmd_success, 0);
46298 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46299 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46300 }
46301
46302 /**
46303 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46304 index 7f0af4f..193ac3e 100644
46305 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46306 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46307 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46308 {
46309 struct scsi_device *sdev = to_scsi_device(dev);
46310 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46311 - static struct _raid_device *raid_device;
46312 + struct _raid_device *raid_device;
46313 unsigned long flags;
46314 Mpi2RaidVolPage0_t vol_pg0;
46315 Mpi2ConfigReply_t mpi_reply;
46316 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46317 {
46318 struct scsi_device *sdev = to_scsi_device(dev);
46319 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46320 - static struct _raid_device *raid_device;
46321 + struct _raid_device *raid_device;
46322 unsigned long flags;
46323 Mpi2RaidVolPage0_t vol_pg0;
46324 Mpi2ConfigReply_t mpi_reply;
46325 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46326 struct fw_event_work *fw_event)
46327 {
46328 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46329 - static struct _raid_device *raid_device;
46330 + struct _raid_device *raid_device;
46331 unsigned long flags;
46332 u16 handle;
46333
46334 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46335 u64 sas_address;
46336 struct _sas_device *sas_device;
46337 struct _sas_node *expander_device;
46338 - static struct _raid_device *raid_device;
46339 + struct _raid_device *raid_device;
46340 u8 retry_count;
46341 unsigned long flags;
46342
46343 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46344 index 1eb7b028..b2a6080 100644
46345 --- a/drivers/scsi/pmcraid.c
46346 +++ b/drivers/scsi/pmcraid.c
46347 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46348 res->scsi_dev = scsi_dev;
46349 scsi_dev->hostdata = res;
46350 res->change_detected = 0;
46351 - atomic_set(&res->read_failures, 0);
46352 - atomic_set(&res->write_failures, 0);
46353 + atomic_set_unchecked(&res->read_failures, 0);
46354 + atomic_set_unchecked(&res->write_failures, 0);
46355 rc = 0;
46356 }
46357 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46358 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46359
46360 /* If this was a SCSI read/write command keep count of errors */
46361 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46362 - atomic_inc(&res->read_failures);
46363 + atomic_inc_unchecked(&res->read_failures);
46364 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46365 - atomic_inc(&res->write_failures);
46366 + atomic_inc_unchecked(&res->write_failures);
46367
46368 if (!RES_IS_GSCSI(res->cfg_entry) &&
46369 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46370 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46371 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46372 * hrrq_id assigned here in queuecommand
46373 */
46374 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46375 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46376 pinstance->num_hrrq;
46377 cmd->cmd_done = pmcraid_io_done;
46378
46379 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46380 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46381 * hrrq_id assigned here in queuecommand
46382 */
46383 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46384 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46385 pinstance->num_hrrq;
46386
46387 if (request_size) {
46388 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46389
46390 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46391 /* add resources only after host is added into system */
46392 - if (!atomic_read(&pinstance->expose_resources))
46393 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46394 return;
46395
46396 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46397 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46398 init_waitqueue_head(&pinstance->reset_wait_q);
46399
46400 atomic_set(&pinstance->outstanding_cmds, 0);
46401 - atomic_set(&pinstance->last_message_id, 0);
46402 - atomic_set(&pinstance->expose_resources, 0);
46403 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46404 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46405
46406 INIT_LIST_HEAD(&pinstance->free_res_q);
46407 INIT_LIST_HEAD(&pinstance->used_res_q);
46408 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46409 /* Schedule worker thread to handle CCN and take care of adding and
46410 * removing devices to OS
46411 */
46412 - atomic_set(&pinstance->expose_resources, 1);
46413 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46414 schedule_work(&pinstance->worker_q);
46415 return rc;
46416
46417 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46418 index e1d150f..6c6df44 100644
46419 --- a/drivers/scsi/pmcraid.h
46420 +++ b/drivers/scsi/pmcraid.h
46421 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46422 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46423
46424 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46425 - atomic_t last_message_id;
46426 + atomic_unchecked_t last_message_id;
46427
46428 /* configuration table */
46429 struct pmcraid_config_table *cfg_table;
46430 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46431 atomic_t outstanding_cmds;
46432
46433 /* should add/delete resources to mid-layer now ?*/
46434 - atomic_t expose_resources;
46435 + atomic_unchecked_t expose_resources;
46436
46437
46438
46439 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46440 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46441 };
46442 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46443 - atomic_t read_failures; /* count of failed READ commands */
46444 - atomic_t write_failures; /* count of failed WRITE commands */
46445 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46446 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46447
46448 /* To indicate add/delete/modify during CCN */
46449 u8 change_detected;
46450 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46451 index 5f174b8..98d32b0 100644
46452 --- a/drivers/scsi/qla2xxx/qla_attr.c
46453 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46454 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46455 return 0;
46456 }
46457
46458 -struct fc_function_template qla2xxx_transport_functions = {
46459 +fc_function_template_no_const qla2xxx_transport_functions = {
46460
46461 .show_host_node_name = 1,
46462 .show_host_port_name = 1,
46463 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46464 .bsg_timeout = qla24xx_bsg_timeout,
46465 };
46466
46467 -struct fc_function_template qla2xxx_transport_vport_functions = {
46468 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46469
46470 .show_host_node_name = 1,
46471 .show_host_port_name = 1,
46472 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46473 index 4446bf5..9a3574d 100644
46474 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46475 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46476 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46477 struct device_attribute;
46478 extern struct device_attribute *qla2x00_host_attrs[];
46479 struct fc_function_template;
46480 -extern struct fc_function_template qla2xxx_transport_functions;
46481 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46482 +extern fc_function_template_no_const qla2xxx_transport_functions;
46483 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46484 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46485 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46486 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46487 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46488 index 9f01bbb..5e1dcee 100644
46489 --- a/drivers/scsi/qla2xxx/qla_os.c
46490 +++ b/drivers/scsi/qla2xxx/qla_os.c
46491 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46492 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46493 /* Ok, a 64bit DMA mask is applicable. */
46494 ha->flags.enable_64bit_addressing = 1;
46495 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46496 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46497 + pax_open_kernel();
46498 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46499 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46500 + pax_close_kernel();
46501 return;
46502 }
46503 }
46504 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46505 index 41327d4..feb03d479 100644
46506 --- a/drivers/scsi/qla4xxx/ql4_def.h
46507 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46508 @@ -296,7 +296,7 @@ struct ddb_entry {
46509 * (4000 only) */
46510 atomic_t relogin_timer; /* Max Time to wait for
46511 * relogin to complete */
46512 - atomic_t relogin_retry_count; /* Num of times relogin has been
46513 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46514 * retried */
46515 uint32_t default_time2wait; /* Default Min time between
46516 * relogins (+aens) */
46517 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46518 index f8a0a26..ec03cee 100644
46519 --- a/drivers/scsi/qla4xxx/ql4_os.c
46520 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46521 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46522 */
46523 if (!iscsi_is_session_online(cls_sess)) {
46524 /* Reset retry relogin timer */
46525 - atomic_inc(&ddb_entry->relogin_retry_count);
46526 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46527 DEBUG2(ql4_printk(KERN_INFO, ha,
46528 "%s: index[%d] relogin timed out-retrying"
46529 " relogin (%d), retry (%d)\n", __func__,
46530 ddb_entry->fw_ddb_index,
46531 - atomic_read(&ddb_entry->relogin_retry_count),
46532 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46533 ddb_entry->default_time2wait + 4));
46534 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46535 atomic_set(&ddb_entry->retry_relogin_timer,
46536 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46537
46538 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46539 atomic_set(&ddb_entry->relogin_timer, 0);
46540 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46541 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46542 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46543 ddb_entry->default_relogin_timeout =
46544 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46545 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46546 index eaa808e..95f8841 100644
46547 --- a/drivers/scsi/scsi.c
46548 +++ b/drivers/scsi/scsi.c
46549 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46550 unsigned long timeout;
46551 int rtn = 0;
46552
46553 - atomic_inc(&cmd->device->iorequest_cnt);
46554 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46555
46556 /* check if the device is still usable */
46557 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46558 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46559 index d1549b7..2f60767 100644
46560 --- a/drivers/scsi/scsi_lib.c
46561 +++ b/drivers/scsi/scsi_lib.c
46562 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46563 shost = sdev->host;
46564 scsi_init_cmd_errh(cmd);
46565 cmd->result = DID_NO_CONNECT << 16;
46566 - atomic_inc(&cmd->device->iorequest_cnt);
46567 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46568
46569 /*
46570 * SCSI request completion path will do scsi_device_unbusy(),
46571 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46572
46573 INIT_LIST_HEAD(&cmd->eh_entry);
46574
46575 - atomic_inc(&cmd->device->iodone_cnt);
46576 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46577 if (cmd->result)
46578 - atomic_inc(&cmd->device->ioerr_cnt);
46579 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46580
46581 disposition = scsi_decide_disposition(cmd);
46582 if (disposition != SUCCESS &&
46583 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46584 index 40c6394..62356c2 100644
46585 --- a/drivers/scsi/scsi_sysfs.c
46586 +++ b/drivers/scsi/scsi_sysfs.c
46587 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46588 char *buf) \
46589 { \
46590 struct scsi_device *sdev = to_scsi_device(dev); \
46591 - unsigned long long count = atomic_read(&sdev->field); \
46592 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46593 return snprintf(buf, 20, "0x%llx\n", count); \
46594 } \
46595 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46596 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46597 index 84a1fdf..693b0d6 100644
46598 --- a/drivers/scsi/scsi_tgt_lib.c
46599 +++ b/drivers/scsi/scsi_tgt_lib.c
46600 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46601 int err;
46602
46603 dprintk("%lx %u\n", uaddr, len);
46604 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46605 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46606 if (err) {
46607 /*
46608 * TODO: need to fixup sg_tablesize, max_segment_size,
46609 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46610 index 4628fd5..a94a1c2 100644
46611 --- a/drivers/scsi/scsi_transport_fc.c
46612 +++ b/drivers/scsi/scsi_transport_fc.c
46613 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46614 * Netlink Infrastructure
46615 */
46616
46617 -static atomic_t fc_event_seq;
46618 +static atomic_unchecked_t fc_event_seq;
46619
46620 /**
46621 * fc_get_event_number - Obtain the next sequential FC event number
46622 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46623 u32
46624 fc_get_event_number(void)
46625 {
46626 - return atomic_add_return(1, &fc_event_seq);
46627 + return atomic_add_return_unchecked(1, &fc_event_seq);
46628 }
46629 EXPORT_SYMBOL(fc_get_event_number);
46630
46631 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46632 {
46633 int error;
46634
46635 - atomic_set(&fc_event_seq, 0);
46636 + atomic_set_unchecked(&fc_event_seq, 0);
46637
46638 error = transport_class_register(&fc_host_class);
46639 if (error)
46640 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46641 char *cp;
46642
46643 *val = simple_strtoul(buf, &cp, 0);
46644 - if ((*cp && (*cp != '\n')) || (*val < 0))
46645 + if (*cp && (*cp != '\n'))
46646 return -EINVAL;
46647 /*
46648 * Check for overflow; dev_loss_tmo is u32
46649 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46650 index e4a989f..293090c 100644
46651 --- a/drivers/scsi/scsi_transport_iscsi.c
46652 +++ b/drivers/scsi/scsi_transport_iscsi.c
46653 @@ -79,7 +79,7 @@ struct iscsi_internal {
46654 struct transport_container session_cont;
46655 };
46656
46657 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
46658 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
46659 static struct workqueue_struct *iscsi_eh_timer_workq;
46660
46661 static DEFINE_IDA(iscsi_sess_ida);
46662 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
46663 int err;
46664
46665 ihost = shost->shost_data;
46666 - session->sid = atomic_add_return(1, &iscsi_session_nr);
46667 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
46668
46669 if (target_id == ISCSI_MAX_TARGET) {
46670 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
46671 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
46672 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
46673 ISCSI_TRANSPORT_VERSION);
46674
46675 - atomic_set(&iscsi_session_nr, 0);
46676 + atomic_set_unchecked(&iscsi_session_nr, 0);
46677
46678 err = class_register(&iscsi_transport_class);
46679 if (err)
46680 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
46681 index f379c7f..e8fc69c 100644
46682 --- a/drivers/scsi/scsi_transport_srp.c
46683 +++ b/drivers/scsi/scsi_transport_srp.c
46684 @@ -33,7 +33,7 @@
46685 #include "scsi_transport_srp_internal.h"
46686
46687 struct srp_host_attrs {
46688 - atomic_t next_port_id;
46689 + atomic_unchecked_t next_port_id;
46690 };
46691 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
46692
46693 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
46694 struct Scsi_Host *shost = dev_to_shost(dev);
46695 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
46696
46697 - atomic_set(&srp_host->next_port_id, 0);
46698 + atomic_set_unchecked(&srp_host->next_port_id, 0);
46699 return 0;
46700 }
46701
46702 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
46703 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
46704 rport->roles = ids->roles;
46705
46706 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
46707 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
46708 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
46709
46710 transport_setup_device(&rport->dev);
46711 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
46712 index 5693f6d7..b0bf05a 100644
46713 --- a/drivers/scsi/sd.c
46714 +++ b/drivers/scsi/sd.c
46715 @@ -2934,7 +2934,7 @@ static int sd_probe(struct device *dev)
46716 sdkp->disk = gd;
46717 sdkp->index = index;
46718 atomic_set(&sdkp->openers, 0);
46719 - atomic_set(&sdkp->device->ioerr_cnt, 0);
46720 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
46721
46722 if (!sdp->request_queue->rq_timeout) {
46723 if (sdp->type != TYPE_MOD)
46724 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
46725 index df5e961..df6b97f 100644
46726 --- a/drivers/scsi/sg.c
46727 +++ b/drivers/scsi/sg.c
46728 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
46729 sdp->disk->disk_name,
46730 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
46731 NULL,
46732 - (char *)arg);
46733 + (char __user *)arg);
46734 case BLKTRACESTART:
46735 return blk_trace_startstop(sdp->device->request_queue, 1);
46736 case BLKTRACESTOP:
46737 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
46738 index 9e039c6..ae9e800 100644
46739 --- a/drivers/spi/spi.c
46740 +++ b/drivers/spi/spi.c
46741 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
46742 EXPORT_SYMBOL_GPL(spi_bus_unlock);
46743
46744 /* portable code must never pass more than 32 bytes */
46745 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
46746 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
46747
46748 static u8 *buf;
46749
46750 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
46751 index 2c61783..4d49e4e 100644
46752 --- a/drivers/staging/android/timed_output.c
46753 +++ b/drivers/staging/android/timed_output.c
46754 @@ -25,7 +25,7 @@
46755 #include "timed_output.h"
46756
46757 static struct class *timed_output_class;
46758 -static atomic_t device_count;
46759 +static atomic_unchecked_t device_count;
46760
46761 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
46762 char *buf)
46763 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
46764 timed_output_class = class_create(THIS_MODULE, "timed_output");
46765 if (IS_ERR(timed_output_class))
46766 return PTR_ERR(timed_output_class);
46767 - atomic_set(&device_count, 0);
46768 + atomic_set_unchecked(&device_count, 0);
46769 timed_output_class->dev_groups = timed_output_groups;
46770 }
46771
46772 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
46773 if (ret < 0)
46774 return ret;
46775
46776 - tdev->index = atomic_inc_return(&device_count);
46777 + tdev->index = atomic_inc_return_unchecked(&device_count);
46778 tdev->dev = device_create(timed_output_class, NULL,
46779 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
46780 if (IS_ERR(tdev->dev))
46781 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
46782 index 0247a20..cb9595c 100644
46783 --- a/drivers/staging/gdm724x/gdm_tty.c
46784 +++ b/drivers/staging/gdm724x/gdm_tty.c
46785 @@ -45,7 +45,7 @@
46786 #define gdm_tty_send_control(n, r, v, d, l) (\
46787 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
46788
46789 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
46790 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
46791
46792 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
46793 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
46794 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
46795 index ef5064e..fce01db 100644
46796 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
46797 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
46798 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
46799 return 0;
46800 }
46801
46802 -sfw_test_client_ops_t brw_test_client;
46803 -void brw_init_test_client(void)
46804 -{
46805 - brw_test_client.tso_init = brw_client_init;
46806 - brw_test_client.tso_fini = brw_client_fini;
46807 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
46808 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
46809 +sfw_test_client_ops_t brw_test_client = {
46810 + .tso_init = brw_client_init,
46811 + .tso_fini = brw_client_fini,
46812 + .tso_prep_rpc = brw_client_prep_rpc,
46813 + .tso_done_rpc = brw_client_done_rpc,
46814 };
46815
46816 srpc_service_t brw_test_service;
46817 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
46818 index 483c785..e1a2a7b 100644
46819 --- a/drivers/staging/lustre/lnet/selftest/framework.c
46820 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
46821 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
46822
46823 extern sfw_test_client_ops_t ping_test_client;
46824 extern srpc_service_t ping_test_service;
46825 -extern void ping_init_test_client(void);
46826 extern void ping_init_test_service(void);
46827
46828 extern sfw_test_client_ops_t brw_test_client;
46829 extern srpc_service_t brw_test_service;
46830 -extern void brw_init_test_client(void);
46831 extern void brw_init_test_service(void);
46832
46833
46834 @@ -1684,12 +1682,10 @@ sfw_startup (void)
46835 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
46836 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
46837
46838 - brw_init_test_client();
46839 brw_init_test_service();
46840 rc = sfw_register_test(&brw_test_service, &brw_test_client);
46841 LASSERT (rc == 0);
46842
46843 - ping_init_test_client();
46844 ping_init_test_service();
46845 rc = sfw_register_test(&ping_test_service, &ping_test_client);
46846 LASSERT (rc == 0);
46847 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
46848 index f0f9194..b589047 100644
46849 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
46850 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
46851 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
46852 return 0;
46853 }
46854
46855 -sfw_test_client_ops_t ping_test_client;
46856 -void ping_init_test_client(void)
46857 -{
46858 - ping_test_client.tso_init = ping_client_init;
46859 - ping_test_client.tso_fini = ping_client_fini;
46860 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
46861 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
46862 -}
46863 +sfw_test_client_ops_t ping_test_client = {
46864 + .tso_init = ping_client_init,
46865 + .tso_fini = ping_client_fini,
46866 + .tso_prep_rpc = ping_client_prep_rpc,
46867 + .tso_done_rpc = ping_client_done_rpc,
46868 +};
46869
46870 srpc_service_t ping_test_service;
46871 void ping_init_test_service(void)
46872 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46873 index 7020d9c..0d3b580 100644
46874 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
46875 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46876 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
46877 ldlm_completion_callback lcs_completion;
46878 ldlm_blocking_callback lcs_blocking;
46879 ldlm_glimpse_callback lcs_glimpse;
46880 -};
46881 +} __no_const;
46882
46883 /* ldlm_lockd.c */
46884 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
46885 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
46886 index a612255..9a9e2dd 100644
46887 --- a/drivers/staging/lustre/lustre/include/obd.h
46888 +++ b/drivers/staging/lustre/lustre/include/obd.h
46889 @@ -1417,7 +1417,7 @@ struct md_ops {
46890 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
46891 * wrapper function in include/linux/obd_class.h.
46892 */
46893 -};
46894 +} __no_const;
46895
46896 struct lsm_operations {
46897 void (*lsm_free)(struct lov_stripe_md *);
46898 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46899 index fc6c977..df1f956 100644
46900 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46901 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46902 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
46903 int LL_PROC_PROTO(proc_console_max_delay_cs)
46904 {
46905 int rc, max_delay_cs;
46906 - ctl_table_t dummy = *table;
46907 + ctl_table_no_const dummy = *table;
46908 cfs_duration_t d;
46909
46910 dummy.data = &max_delay_cs;
46911 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
46912 int LL_PROC_PROTO(proc_console_min_delay_cs)
46913 {
46914 int rc, min_delay_cs;
46915 - ctl_table_t dummy = *table;
46916 + ctl_table_no_const dummy = *table;
46917 cfs_duration_t d;
46918
46919 dummy.data = &min_delay_cs;
46920 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
46921 int LL_PROC_PROTO(proc_console_backoff)
46922 {
46923 int rc, backoff;
46924 - ctl_table_t dummy = *table;
46925 + ctl_table_no_const dummy = *table;
46926
46927 dummy.data = &backoff;
46928 dummy.proc_handler = &proc_dointvec;
46929 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
46930 index 3675020..e80d92c 100644
46931 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
46932 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
46933 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
46934
46935 static int solo_sysfs_init(struct solo_dev *solo_dev)
46936 {
46937 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
46938 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
46939 struct device *dev = &solo_dev->dev;
46940 const char *driver;
46941 int i;
46942 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46943 index 3335941..2b26186 100644
46944 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
46945 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46946 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
46947
46948 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
46949 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
46950 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
46951 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
46952 if (p2m_id < 0)
46953 p2m_id = -p2m_id;
46954 }
46955 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
46956 index 6f91d2e..3f011d2 100644
46957 --- a/drivers/staging/media/solo6x10/solo6x10.h
46958 +++ b/drivers/staging/media/solo6x10/solo6x10.h
46959 @@ -238,7 +238,7 @@ struct solo_dev {
46960
46961 /* P2M DMA Engine */
46962 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
46963 - atomic_t p2m_count;
46964 + atomic_unchecked_t p2m_count;
46965 int p2m_jiffies;
46966 unsigned int p2m_timeouts;
46967
46968 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
46969 index e14a1bb..9cb9bbe 100644
46970 --- a/drivers/staging/octeon/ethernet-rx.c
46971 +++ b/drivers/staging/octeon/ethernet-rx.c
46972 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46973 /* Increment RX stats for virtual ports */
46974 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
46975 #ifdef CONFIG_64BIT
46976 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
46977 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
46978 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
46979 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
46980 #else
46981 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
46982 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
46983 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
46984 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
46985 #endif
46986 }
46987 netif_receive_skb(skb);
46988 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46989 dev->name);
46990 */
46991 #ifdef CONFIG_64BIT
46992 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
46993 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
46994 #else
46995 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
46996 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
46997 #endif
46998 dev_kfree_skb_irq(skb);
46999 }
47000 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47001 index c3a90e7..023619a 100644
47002 --- a/drivers/staging/octeon/ethernet.c
47003 +++ b/drivers/staging/octeon/ethernet.c
47004 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47005 * since the RX tasklet also increments it.
47006 */
47007 #ifdef CONFIG_64BIT
47008 - atomic64_add(rx_status.dropped_packets,
47009 - (atomic64_t *)&priv->stats.rx_dropped);
47010 + atomic64_add_unchecked(rx_status.dropped_packets,
47011 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47012 #else
47013 - atomic_add(rx_status.dropped_packets,
47014 - (atomic_t *)&priv->stats.rx_dropped);
47015 + atomic_add_unchecked(rx_status.dropped_packets,
47016 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47017 #endif
47018 }
47019
47020 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47021 index 439c3c9..2d74293 100644
47022 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47023 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47024 @@ -271,7 +271,7 @@ struct hal_ops {
47025 s32 (*c2h_handler)(struct adapter *padapter,
47026 struct c2h_evt_hdr *c2h_evt);
47027 c2h_id_filter c2h_id_filter_ccx;
47028 -};
47029 +} __no_const;
47030
47031 enum rt_eeprom_type {
47032 EEPROM_93C46,
47033 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47034 index eb6f0e5..e6a0958 100644
47035 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47036 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47037 @@ -126,7 +126,7 @@ struct _io_ops {
47038 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47039 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47040 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47041 -};
47042 +} __no_const;
47043
47044 struct io_req {
47045 struct list_head list;
47046 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47047 index dc23395..cf7e9b1 100644
47048 --- a/drivers/staging/rtl8712/rtl871x_io.h
47049 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47050 @@ -108,7 +108,7 @@ struct _io_ops {
47051 u8 *pmem);
47052 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47053 u8 *pmem);
47054 -};
47055 +} __no_const;
47056
47057 struct io_req {
47058 struct list_head list;
47059 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47060 index 1f5088b..0e59820 100644
47061 --- a/drivers/staging/sbe-2t3e3/netdev.c
47062 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47063 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47064 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47065
47066 if (rlen)
47067 - if (copy_to_user(data, &resp, rlen))
47068 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47069 return -EFAULT;
47070
47071 return 0;
47072 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47073 index a863a98..d272795 100644
47074 --- a/drivers/staging/usbip/vhci.h
47075 +++ b/drivers/staging/usbip/vhci.h
47076 @@ -83,7 +83,7 @@ struct vhci_hcd {
47077 unsigned resuming:1;
47078 unsigned long re_timeout;
47079
47080 - atomic_t seqnum;
47081 + atomic_unchecked_t seqnum;
47082
47083 /*
47084 * NOTE:
47085 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47086 index d7974cb..d78076b 100644
47087 --- a/drivers/staging/usbip/vhci_hcd.c
47088 +++ b/drivers/staging/usbip/vhci_hcd.c
47089 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47090
47091 spin_lock(&vdev->priv_lock);
47092
47093 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47094 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47095 if (priv->seqnum == 0xffff)
47096 dev_info(&urb->dev->dev, "seqnum max\n");
47097
47098 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47099 return -ENOMEM;
47100 }
47101
47102 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47103 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47104 if (unlink->seqnum == 0xffff)
47105 pr_info("seqnum max\n");
47106
47107 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47108 vdev->rhport = rhport;
47109 }
47110
47111 - atomic_set(&vhci->seqnum, 0);
47112 + atomic_set_unchecked(&vhci->seqnum, 0);
47113 spin_lock_init(&vhci->lock);
47114
47115 hcd->power_budget = 0; /* no limit */
47116 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47117 index d07fcb5..358e1e1 100644
47118 --- a/drivers/staging/usbip/vhci_rx.c
47119 +++ b/drivers/staging/usbip/vhci_rx.c
47120 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47121 if (!urb) {
47122 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47123 pr_info("max seqnum %d\n",
47124 - atomic_read(&the_controller->seqnum));
47125 + atomic_read_unchecked(&the_controller->seqnum));
47126 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47127 return;
47128 }
47129 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47130 index 8acff44..bdb2fca 100644
47131 --- a/drivers/staging/vt6655/hostap.c
47132 +++ b/drivers/staging/vt6655/hostap.c
47133 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47134 *
47135 */
47136
47137 +static net_device_ops_no_const apdev_netdev_ops;
47138 +
47139 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47140 {
47141 PSDevice apdev_priv;
47142 struct net_device *dev = pDevice->dev;
47143 int ret;
47144 - const struct net_device_ops apdev_netdev_ops = {
47145 - .ndo_start_xmit = pDevice->tx_80211,
47146 - };
47147
47148 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47149
47150 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47151 *apdev_priv = *pDevice;
47152 eth_hw_addr_inherit(pDevice->apdev, dev);
47153
47154 + /* only half broken now */
47155 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47156 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47157
47158 pDevice->apdev->type = ARPHRD_IEEE80211;
47159 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47160 index c699a30..b90a5fd 100644
47161 --- a/drivers/staging/vt6656/hostap.c
47162 +++ b/drivers/staging/vt6656/hostap.c
47163 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47164 *
47165 */
47166
47167 +static net_device_ops_no_const apdev_netdev_ops;
47168 +
47169 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47170 {
47171 struct vnt_private *apdev_priv;
47172 struct net_device *dev = pDevice->dev;
47173 int ret;
47174 - const struct net_device_ops apdev_netdev_ops = {
47175 - .ndo_start_xmit = pDevice->tx_80211,
47176 - };
47177
47178 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47179
47180 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47181 *apdev_priv = *pDevice;
47182 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47183
47184 + /* only half broken now */
47185 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47186 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47187
47188 pDevice->apdev->type = ARPHRD_IEEE80211;
47189 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47190 index e51b09a..5ebac31 100644
47191 --- a/drivers/target/sbp/sbp_target.c
47192 +++ b/drivers/target/sbp/sbp_target.c
47193 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47194
47195 #define SESSION_MAINTENANCE_INTERVAL HZ
47196
47197 -static atomic_t login_id = ATOMIC_INIT(0);
47198 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47199
47200 static void session_maintenance_work(struct work_struct *);
47201 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47202 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47203 login->lun = se_lun;
47204 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47205 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47206 - login->login_id = atomic_inc_return(&login_id);
47207 + login->login_id = atomic_inc_return_unchecked(&login_id);
47208
47209 login->tgt_agt = sbp_target_agent_register(login);
47210 if (IS_ERR(login->tgt_agt)) {
47211 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47212 index d90dbb0..6cbe585 100644
47213 --- a/drivers/target/target_core_device.c
47214 +++ b/drivers/target/target_core_device.c
47215 @@ -1431,7 +1431,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47216 spin_lock_init(&dev->se_tmr_lock);
47217 spin_lock_init(&dev->qf_cmd_lock);
47218 sema_init(&dev->caw_sem, 1);
47219 - atomic_set(&dev->dev_ordered_id, 0);
47220 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47221 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47222 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47223 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47224 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47225 index 81e945e..e40c92f 100644
47226 --- a/drivers/target/target_core_transport.c
47227 +++ b/drivers/target/target_core_transport.c
47228 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47229 * Used to determine when ORDERED commands should go from
47230 * Dormant to Active status.
47231 */
47232 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47233 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47234 smp_mb__after_atomic_inc();
47235 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47236 cmd->se_ordered_id, cmd->sam_task_attr,
47237 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47238 index 33f83fe..d80f8e1 100644
47239 --- a/drivers/tty/cyclades.c
47240 +++ b/drivers/tty/cyclades.c
47241 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47242 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47243 info->port.count);
47244 #endif
47245 - info->port.count++;
47246 + atomic_inc(&info->port.count);
47247 #ifdef CY_DEBUG_COUNT
47248 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47249 - current->pid, info->port.count);
47250 + current->pid, atomic_read(&info->port.count));
47251 #endif
47252
47253 /*
47254 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47255 for (j = 0; j < cy_card[i].nports; j++) {
47256 info = &cy_card[i].ports[j];
47257
47258 - if (info->port.count) {
47259 + if (atomic_read(&info->port.count)) {
47260 /* XXX is the ldisc num worth this? */
47261 struct tty_struct *tty;
47262 struct tty_ldisc *ld;
47263 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47264 index 9eba119..5070303 100644
47265 --- a/drivers/tty/hvc/hvc_console.c
47266 +++ b/drivers/tty/hvc/hvc_console.c
47267 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47268
47269 spin_lock_irqsave(&hp->port.lock, flags);
47270 /* Check and then increment for fast path open. */
47271 - if (hp->port.count++ > 0) {
47272 + if (atomic_inc_return(&hp->port.count) > 1) {
47273 spin_unlock_irqrestore(&hp->port.lock, flags);
47274 hvc_kick();
47275 return 0;
47276 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47277
47278 spin_lock_irqsave(&hp->port.lock, flags);
47279
47280 - if (--hp->port.count == 0) {
47281 + if (atomic_dec_return(&hp->port.count) == 0) {
47282 spin_unlock_irqrestore(&hp->port.lock, flags);
47283 /* We are done with the tty pointer now. */
47284 tty_port_tty_set(&hp->port, NULL);
47285 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47286 */
47287 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47288 } else {
47289 - if (hp->port.count < 0)
47290 + if (atomic_read(&hp->port.count) < 0)
47291 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47292 - hp->vtermno, hp->port.count);
47293 + hp->vtermno, atomic_read(&hp->port.count));
47294 spin_unlock_irqrestore(&hp->port.lock, flags);
47295 }
47296 }
47297 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47298 * open->hangup case this can be called after the final close so prevent
47299 * that from happening for now.
47300 */
47301 - if (hp->port.count <= 0) {
47302 + if (atomic_read(&hp->port.count) <= 0) {
47303 spin_unlock_irqrestore(&hp->port.lock, flags);
47304 return;
47305 }
47306
47307 - hp->port.count = 0;
47308 + atomic_set(&hp->port.count, 0);
47309 spin_unlock_irqrestore(&hp->port.lock, flags);
47310 tty_port_tty_set(&hp->port, NULL);
47311
47312 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47313 return -EPIPE;
47314
47315 /* FIXME what's this (unprotected) check for? */
47316 - if (hp->port.count <= 0)
47317 + if (atomic_read(&hp->port.count) <= 0)
47318 return -EIO;
47319
47320 spin_lock_irqsave(&hp->lock, flags);
47321 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47322 index 81e939e..95ead10 100644
47323 --- a/drivers/tty/hvc/hvcs.c
47324 +++ b/drivers/tty/hvc/hvcs.c
47325 @@ -83,6 +83,7 @@
47326 #include <asm/hvcserver.h>
47327 #include <asm/uaccess.h>
47328 #include <asm/vio.h>
47329 +#include <asm/local.h>
47330
47331 /*
47332 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47333 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47334
47335 spin_lock_irqsave(&hvcsd->lock, flags);
47336
47337 - if (hvcsd->port.count > 0) {
47338 + if (atomic_read(&hvcsd->port.count) > 0) {
47339 spin_unlock_irqrestore(&hvcsd->lock, flags);
47340 printk(KERN_INFO "HVCS: vterm state unchanged. "
47341 "The hvcs device node is still in use.\n");
47342 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47343 }
47344 }
47345
47346 - hvcsd->port.count = 0;
47347 + atomic_set(&hvcsd->port.count, 0);
47348 hvcsd->port.tty = tty;
47349 tty->driver_data = hvcsd;
47350
47351 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47352 unsigned long flags;
47353
47354 spin_lock_irqsave(&hvcsd->lock, flags);
47355 - hvcsd->port.count++;
47356 + atomic_inc(&hvcsd->port.count);
47357 hvcsd->todo_mask |= HVCS_SCHED_READ;
47358 spin_unlock_irqrestore(&hvcsd->lock, flags);
47359
47360 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47361 hvcsd = tty->driver_data;
47362
47363 spin_lock_irqsave(&hvcsd->lock, flags);
47364 - if (--hvcsd->port.count == 0) {
47365 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47366
47367 vio_disable_interrupts(hvcsd->vdev);
47368
47369 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47370
47371 free_irq(irq, hvcsd);
47372 return;
47373 - } else if (hvcsd->port.count < 0) {
47374 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47375 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47376 " is missmanaged.\n",
47377 - hvcsd->vdev->unit_address, hvcsd->port.count);
47378 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47379 }
47380
47381 spin_unlock_irqrestore(&hvcsd->lock, flags);
47382 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47383
47384 spin_lock_irqsave(&hvcsd->lock, flags);
47385 /* Preserve this so that we know how many kref refs to put */
47386 - temp_open_count = hvcsd->port.count;
47387 + temp_open_count = atomic_read(&hvcsd->port.count);
47388
47389 /*
47390 * Don't kref put inside the spinlock because the destruction
47391 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47392 tty->driver_data = NULL;
47393 hvcsd->port.tty = NULL;
47394
47395 - hvcsd->port.count = 0;
47396 + atomic_set(&hvcsd->port.count, 0);
47397
47398 /* This will drop any buffered data on the floor which is OK in a hangup
47399 * scenario. */
47400 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47401 * the middle of a write operation? This is a crummy place to do this
47402 * but we want to keep it all in the spinlock.
47403 */
47404 - if (hvcsd->port.count <= 0) {
47405 + if (atomic_read(&hvcsd->port.count) <= 0) {
47406 spin_unlock_irqrestore(&hvcsd->lock, flags);
47407 return -ENODEV;
47408 }
47409 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47410 {
47411 struct hvcs_struct *hvcsd = tty->driver_data;
47412
47413 - if (!hvcsd || hvcsd->port.count <= 0)
47414 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47415 return 0;
47416
47417 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47418 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47419 index 4190199..48f2920 100644
47420 --- a/drivers/tty/hvc/hvsi.c
47421 +++ b/drivers/tty/hvc/hvsi.c
47422 @@ -85,7 +85,7 @@ struct hvsi_struct {
47423 int n_outbuf;
47424 uint32_t vtermno;
47425 uint32_t virq;
47426 - atomic_t seqno; /* HVSI packet sequence number */
47427 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47428 uint16_t mctrl;
47429 uint8_t state; /* HVSI protocol state */
47430 uint8_t flags;
47431 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47432
47433 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47434 packet.hdr.len = sizeof(struct hvsi_query_response);
47435 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47436 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47437 packet.verb = VSV_SEND_VERSION_NUMBER;
47438 packet.u.version = HVSI_VERSION;
47439 packet.query_seqno = query_seqno+1;
47440 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47441
47442 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47443 packet.hdr.len = sizeof(struct hvsi_query);
47444 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47445 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47446 packet.verb = verb;
47447
47448 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47449 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47450 int wrote;
47451
47452 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47453 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47454 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47455 packet.hdr.len = sizeof(struct hvsi_control);
47456 packet.verb = VSV_SET_MODEM_CTL;
47457 packet.mask = HVSI_TSDTR;
47458 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47459 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47460
47461 packet.hdr.type = VS_DATA_PACKET_HEADER;
47462 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47463 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47464 packet.hdr.len = count + sizeof(struct hvsi_header);
47465 memcpy(&packet.data, buf, count);
47466
47467 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47468 struct hvsi_control packet __ALIGNED__;
47469
47470 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47471 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47472 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47473 packet.hdr.len = 6;
47474 packet.verb = VSV_CLOSE_PROTOCOL;
47475
47476 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47477 index ac27671..0f627ee 100644
47478 --- a/drivers/tty/hvc/hvsi_lib.c
47479 +++ b/drivers/tty/hvc/hvsi_lib.c
47480 @@ -9,7 +9,7 @@
47481
47482 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47483 {
47484 - packet->seqno = atomic_inc_return(&pv->seqno);
47485 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47486
47487 /* Assumes that always succeeds, works in practice */
47488 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47489 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47490
47491 /* Reset state */
47492 pv->established = 0;
47493 - atomic_set(&pv->seqno, 0);
47494 + atomic_set_unchecked(&pv->seqno, 0);
47495
47496 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47497
47498 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47499 pv->mctrl_update = 0;
47500 q.hdr.type = VS_QUERY_PACKET_HEADER;
47501 q.hdr.len = sizeof(struct hvsi_query);
47502 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47503 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47504 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47505 rc = hvsi_send_packet(pv, &q.hdr);
47506 if (rc <= 0) {
47507 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47508 index 8fd72ff..34a0bed 100644
47509 --- a/drivers/tty/ipwireless/tty.c
47510 +++ b/drivers/tty/ipwireless/tty.c
47511 @@ -29,6 +29,7 @@
47512 #include <linux/tty_driver.h>
47513 #include <linux/tty_flip.h>
47514 #include <linux/uaccess.h>
47515 +#include <asm/local.h>
47516
47517 #include "tty.h"
47518 #include "network.h"
47519 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47520 mutex_unlock(&tty->ipw_tty_mutex);
47521 return -ENODEV;
47522 }
47523 - if (tty->port.count == 0)
47524 + if (atomic_read(&tty->port.count) == 0)
47525 tty->tx_bytes_queued = 0;
47526
47527 - tty->port.count++;
47528 + atomic_inc(&tty->port.count);
47529
47530 tty->port.tty = linux_tty;
47531 linux_tty->driver_data = tty;
47532 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47533
47534 static void do_ipw_close(struct ipw_tty *tty)
47535 {
47536 - tty->port.count--;
47537 -
47538 - if (tty->port.count == 0) {
47539 + if (atomic_dec_return(&tty->port.count) == 0) {
47540 struct tty_struct *linux_tty = tty->port.tty;
47541
47542 if (linux_tty != NULL) {
47543 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47544 return;
47545
47546 mutex_lock(&tty->ipw_tty_mutex);
47547 - if (tty->port.count == 0) {
47548 + if (atomic_read(&tty->port.count) == 0) {
47549 mutex_unlock(&tty->ipw_tty_mutex);
47550 return;
47551 }
47552 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47553
47554 mutex_lock(&tty->ipw_tty_mutex);
47555
47556 - if (!tty->port.count) {
47557 + if (!atomic_read(&tty->port.count)) {
47558 mutex_unlock(&tty->ipw_tty_mutex);
47559 return;
47560 }
47561 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47562 return -ENODEV;
47563
47564 mutex_lock(&tty->ipw_tty_mutex);
47565 - if (!tty->port.count) {
47566 + if (!atomic_read(&tty->port.count)) {
47567 mutex_unlock(&tty->ipw_tty_mutex);
47568 return -EINVAL;
47569 }
47570 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47571 if (!tty)
47572 return -ENODEV;
47573
47574 - if (!tty->port.count)
47575 + if (!atomic_read(&tty->port.count))
47576 return -EINVAL;
47577
47578 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47579 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47580 if (!tty)
47581 return 0;
47582
47583 - if (!tty->port.count)
47584 + if (!atomic_read(&tty->port.count))
47585 return 0;
47586
47587 return tty->tx_bytes_queued;
47588 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47589 if (!tty)
47590 return -ENODEV;
47591
47592 - if (!tty->port.count)
47593 + if (!atomic_read(&tty->port.count))
47594 return -EINVAL;
47595
47596 return get_control_lines(tty);
47597 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47598 if (!tty)
47599 return -ENODEV;
47600
47601 - if (!tty->port.count)
47602 + if (!atomic_read(&tty->port.count))
47603 return -EINVAL;
47604
47605 return set_control_lines(tty, set, clear);
47606 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47607 if (!tty)
47608 return -ENODEV;
47609
47610 - if (!tty->port.count)
47611 + if (!atomic_read(&tty->port.count))
47612 return -EINVAL;
47613
47614 /* FIXME: Exactly how is the tty object locked here .. */
47615 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47616 * are gone */
47617 mutex_lock(&ttyj->ipw_tty_mutex);
47618 }
47619 - while (ttyj->port.count)
47620 + while (atomic_read(&ttyj->port.count))
47621 do_ipw_close(ttyj);
47622 ipwireless_disassociate_network_ttys(network,
47623 ttyj->channel_idx);
47624 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47625 index 1deaca4..c8582d4 100644
47626 --- a/drivers/tty/moxa.c
47627 +++ b/drivers/tty/moxa.c
47628 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47629 }
47630
47631 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47632 - ch->port.count++;
47633 + atomic_inc(&ch->port.count);
47634 tty->driver_data = ch;
47635 tty_port_tty_set(&ch->port, tty);
47636 mutex_lock(&ch->port.mutex);
47637 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47638 index c0f76da..d974c32 100644
47639 --- a/drivers/tty/n_gsm.c
47640 +++ b/drivers/tty/n_gsm.c
47641 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47642 spin_lock_init(&dlci->lock);
47643 mutex_init(&dlci->mutex);
47644 dlci->fifo = &dlci->_fifo;
47645 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47646 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47647 kfree(dlci);
47648 return NULL;
47649 }
47650 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47651 struct gsm_dlci *dlci = tty->driver_data;
47652 struct tty_port *port = &dlci->port;
47653
47654 - port->count++;
47655 + atomic_inc(&port->count);
47656 dlci_get(dlci);
47657 dlci_get(dlci->gsm->dlci[0]);
47658 mux_get(dlci->gsm);
47659 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47660 index 7a744b6..6aa4aa9 100644
47661 --- a/drivers/tty/n_tty.c
47662 +++ b/drivers/tty/n_tty.c
47663 @@ -2498,6 +2498,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47664 {
47665 *ops = tty_ldisc_N_TTY;
47666 ops->owner = NULL;
47667 - ops->refcount = ops->flags = 0;
47668 + atomic_set(&ops->refcount, 0);
47669 + ops->flags = 0;
47670 }
47671 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47672 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47673 index 25c9bc7..24077b7 100644
47674 --- a/drivers/tty/pty.c
47675 +++ b/drivers/tty/pty.c
47676 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
47677 panic("Couldn't register Unix98 pts driver");
47678
47679 /* Now create the /dev/ptmx special device */
47680 + pax_open_kernel();
47681 tty_default_fops(&ptmx_fops);
47682 - ptmx_fops.open = ptmx_open;
47683 + *(void **)&ptmx_fops.open = ptmx_open;
47684 + pax_close_kernel();
47685
47686 cdev_init(&ptmx_cdev, &ptmx_fops);
47687 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47688 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47689 index 354564e..fe50d9a 100644
47690 --- a/drivers/tty/rocket.c
47691 +++ b/drivers/tty/rocket.c
47692 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47693 tty->driver_data = info;
47694 tty_port_tty_set(port, tty);
47695
47696 - if (port->count++ == 0) {
47697 + if (atomic_inc_return(&port->count) == 1) {
47698 atomic_inc(&rp_num_ports_open);
47699
47700 #ifdef ROCKET_DEBUG_OPEN
47701 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47702 #endif
47703 }
47704 #ifdef ROCKET_DEBUG_OPEN
47705 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47706 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47707 #endif
47708
47709 /*
47710 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47711 spin_unlock_irqrestore(&info->port.lock, flags);
47712 return;
47713 }
47714 - if (info->port.count)
47715 + if (atomic_read(&info->port.count))
47716 atomic_dec(&rp_num_ports_open);
47717 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47718 spin_unlock_irqrestore(&info->port.lock, flags);
47719 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47720 index 1274499..f541382 100644
47721 --- a/drivers/tty/serial/ioc4_serial.c
47722 +++ b/drivers/tty/serial/ioc4_serial.c
47723 @@ -437,7 +437,7 @@ struct ioc4_soft {
47724 } is_intr_info[MAX_IOC4_INTR_ENTS];
47725
47726 /* Number of entries active in the above array */
47727 - atomic_t is_num_intrs;
47728 + atomic_unchecked_t is_num_intrs;
47729 } is_intr_type[IOC4_NUM_INTR_TYPES];
47730
47731 /* is_ir_lock must be held while
47732 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47733 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47734 || (type == IOC4_OTHER_INTR_TYPE)));
47735
47736 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47737 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47738 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47739
47740 /* Save off the lower level interrupt handler */
47741 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47742
47743 soft = arg;
47744 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47745 - num_intrs = (int)atomic_read(
47746 + num_intrs = (int)atomic_read_unchecked(
47747 &soft->is_intr_type[intr_type].is_num_intrs);
47748
47749 this_mir = this_ir = pending_intrs(soft, intr_type);
47750 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47751 index a260cde..6b2b5ce 100644
47752 --- a/drivers/tty/serial/kgdboc.c
47753 +++ b/drivers/tty/serial/kgdboc.c
47754 @@ -24,8 +24,9 @@
47755 #define MAX_CONFIG_LEN 40
47756
47757 static struct kgdb_io kgdboc_io_ops;
47758 +static struct kgdb_io kgdboc_io_ops_console;
47759
47760 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47761 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47762 static int configured = -1;
47763
47764 static char config[MAX_CONFIG_LEN];
47765 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47766 kgdboc_unregister_kbd();
47767 if (configured == 1)
47768 kgdb_unregister_io_module(&kgdboc_io_ops);
47769 + else if (configured == 2)
47770 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47771 }
47772
47773 static int configure_kgdboc(void)
47774 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47775 int err;
47776 char *cptr = config;
47777 struct console *cons;
47778 + int is_console = 0;
47779
47780 err = kgdboc_option_setup(config);
47781 if (err || !strlen(config) || isspace(config[0]))
47782 goto noconfig;
47783
47784 err = -ENODEV;
47785 - kgdboc_io_ops.is_console = 0;
47786 kgdb_tty_driver = NULL;
47787
47788 kgdboc_use_kms = 0;
47789 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47790 int idx;
47791 if (cons->device && cons->device(cons, &idx) == p &&
47792 idx == tty_line) {
47793 - kgdboc_io_ops.is_console = 1;
47794 + is_console = 1;
47795 break;
47796 }
47797 cons = cons->next;
47798 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47799 kgdb_tty_line = tty_line;
47800
47801 do_register:
47802 - err = kgdb_register_io_module(&kgdboc_io_ops);
47803 + if (is_console) {
47804 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
47805 + configured = 2;
47806 + } else {
47807 + err = kgdb_register_io_module(&kgdboc_io_ops);
47808 + configured = 1;
47809 + }
47810 if (err)
47811 goto noconfig;
47812
47813 @@ -205,8 +214,6 @@ do_register:
47814 if (err)
47815 goto nmi_con_failed;
47816
47817 - configured = 1;
47818 -
47819 return 0;
47820
47821 nmi_con_failed:
47822 @@ -223,7 +230,7 @@ noconfig:
47823 static int __init init_kgdboc(void)
47824 {
47825 /* Already configured? */
47826 - if (configured == 1)
47827 + if (configured >= 1)
47828 return 0;
47829
47830 return configure_kgdboc();
47831 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
47832 if (config[len - 1] == '\n')
47833 config[len - 1] = '\0';
47834
47835 - if (configured == 1)
47836 + if (configured >= 1)
47837 cleanup_kgdboc();
47838
47839 /* Go and configure with the new params. */
47840 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
47841 .post_exception = kgdboc_post_exp_handler,
47842 };
47843
47844 +static struct kgdb_io kgdboc_io_ops_console = {
47845 + .name = "kgdboc",
47846 + .read_char = kgdboc_get_char,
47847 + .write_char = kgdboc_put_char,
47848 + .pre_exception = kgdboc_pre_exp_handler,
47849 + .post_exception = kgdboc_post_exp_handler,
47850 + .is_console = 1
47851 +};
47852 +
47853 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
47854 /* This is only available if kgdboc is a built in for early debugging */
47855 static int __init kgdboc_early_init(char *opt)
47856 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
47857 index b5d779c..3622cfe 100644
47858 --- a/drivers/tty/serial/msm_serial.c
47859 +++ b/drivers/tty/serial/msm_serial.c
47860 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
47861 .cons = MSM_CONSOLE,
47862 };
47863
47864 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
47865 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
47866
47867 static const struct of_device_id msm_uartdm_table[] = {
47868 { .compatible = "qcom,msm-uartdm" },
47869 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
47870 int irq;
47871
47872 if (pdev->id == -1)
47873 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
47874 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
47875
47876 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
47877 return -ENXIO;
47878 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
47879 index f3dfa19..342f2ff 100644
47880 --- a/drivers/tty/serial/samsung.c
47881 +++ b/drivers/tty/serial/samsung.c
47882 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
47883 }
47884 }
47885
47886 +static int s3c64xx_serial_startup(struct uart_port *port);
47887 static int s3c24xx_serial_startup(struct uart_port *port)
47888 {
47889 struct s3c24xx_uart_port *ourport = to_ourport(port);
47890 int ret;
47891
47892 + /* Startup sequence is different for s3c64xx and higher SoC's */
47893 + if (s3c24xx_serial_has_interrupt_mask(port))
47894 + return s3c64xx_serial_startup(port);
47895 +
47896 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
47897 port->mapbase, port->membase);
47898
47899 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
47900 /* setup info for port */
47901 port->dev = &platdev->dev;
47902
47903 - /* Startup sequence is different for s3c64xx and higher SoC's */
47904 - if (s3c24xx_serial_has_interrupt_mask(port))
47905 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
47906 -
47907 port->uartclk = 1;
47908
47909 if (cfg->uart_flags & UPF_CONS_FLOW) {
47910 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
47911 index 0f02351..07c59c5 100644
47912 --- a/drivers/tty/serial/serial_core.c
47913 +++ b/drivers/tty/serial/serial_core.c
47914 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
47915 uart_flush_buffer(tty);
47916 uart_shutdown(tty, state);
47917 spin_lock_irqsave(&port->lock, flags);
47918 - port->count = 0;
47919 + atomic_set(&port->count, 0);
47920 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
47921 spin_unlock_irqrestore(&port->lock, flags);
47922 tty_port_tty_set(port, NULL);
47923 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47924 goto end;
47925 }
47926
47927 - port->count++;
47928 + atomic_inc(&port->count);
47929 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
47930 retval = -ENXIO;
47931 goto err_dec_count;
47932 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47933 /*
47934 * Make sure the device is in D0 state.
47935 */
47936 - if (port->count == 1)
47937 + if (atomic_read(&port->count) == 1)
47938 uart_change_pm(state, UART_PM_STATE_ON);
47939
47940 /*
47941 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47942 end:
47943 return retval;
47944 err_dec_count:
47945 - port->count--;
47946 + atomic_inc(&port->count);
47947 mutex_unlock(&port->mutex);
47948 goto end;
47949 }
47950 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
47951 index e1ce141..6d4ed80 100644
47952 --- a/drivers/tty/synclink.c
47953 +++ b/drivers/tty/synclink.c
47954 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47955
47956 if (debug_level >= DEBUG_LEVEL_INFO)
47957 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
47958 - __FILE__,__LINE__, info->device_name, info->port.count);
47959 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
47960
47961 if (tty_port_close_start(&info->port, tty, filp) == 0)
47962 goto cleanup;
47963 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47964 cleanup:
47965 if (debug_level >= DEBUG_LEVEL_INFO)
47966 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
47967 - tty->driver->name, info->port.count);
47968 + tty->driver->name, atomic_read(&info->port.count));
47969
47970 } /* end of mgsl_close() */
47971
47972 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
47973
47974 mgsl_flush_buffer(tty);
47975 shutdown(info);
47976 -
47977 - info->port.count = 0;
47978 +
47979 + atomic_set(&info->port.count, 0);
47980 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
47981 info->port.tty = NULL;
47982
47983 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47984
47985 if (debug_level >= DEBUG_LEVEL_INFO)
47986 printk("%s(%d):block_til_ready before block on %s count=%d\n",
47987 - __FILE__,__LINE__, tty->driver->name, port->count );
47988 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
47989
47990 spin_lock_irqsave(&info->irq_spinlock, flags);
47991 if (!tty_hung_up_p(filp)) {
47992 extra_count = true;
47993 - port->count--;
47994 + atomic_dec(&port->count);
47995 }
47996 spin_unlock_irqrestore(&info->irq_spinlock, flags);
47997 port->blocked_open++;
47998 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47999
48000 if (debug_level >= DEBUG_LEVEL_INFO)
48001 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48002 - __FILE__,__LINE__, tty->driver->name, port->count );
48003 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48004
48005 tty_unlock(tty);
48006 schedule();
48007 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48008
48009 /* FIXME: Racy on hangup during close wait */
48010 if (extra_count)
48011 - port->count++;
48012 + atomic_inc(&port->count);
48013 port->blocked_open--;
48014
48015 if (debug_level >= DEBUG_LEVEL_INFO)
48016 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48017 - __FILE__,__LINE__, tty->driver->name, port->count );
48018 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48019
48020 if (!retval)
48021 port->flags |= ASYNC_NORMAL_ACTIVE;
48022 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48023
48024 if (debug_level >= DEBUG_LEVEL_INFO)
48025 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48026 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48027 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48028
48029 /* If port is closing, signal caller to try again */
48030 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48031 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48032 spin_unlock_irqrestore(&info->netlock, flags);
48033 goto cleanup;
48034 }
48035 - info->port.count++;
48036 + atomic_inc(&info->port.count);
48037 spin_unlock_irqrestore(&info->netlock, flags);
48038
48039 - if (info->port.count == 1) {
48040 + if (atomic_read(&info->port.count) == 1) {
48041 /* 1st open on this device, init hardware */
48042 retval = startup(info);
48043 if (retval < 0)
48044 @@ -3446,8 +3446,8 @@ cleanup:
48045 if (retval) {
48046 if (tty->count == 1)
48047 info->port.tty = NULL; /* tty layer will release tty struct */
48048 - if(info->port.count)
48049 - info->port.count--;
48050 + if (atomic_read(&info->port.count))
48051 + atomic_dec(&info->port.count);
48052 }
48053
48054 return retval;
48055 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48056 unsigned short new_crctype;
48057
48058 /* return error if TTY interface open */
48059 - if (info->port.count)
48060 + if (atomic_read(&info->port.count))
48061 return -EBUSY;
48062
48063 switch (encoding)
48064 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48065
48066 /* arbitrate between network and tty opens */
48067 spin_lock_irqsave(&info->netlock, flags);
48068 - if (info->port.count != 0 || info->netcount != 0) {
48069 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48070 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48071 spin_unlock_irqrestore(&info->netlock, flags);
48072 return -EBUSY;
48073 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48074 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48075
48076 /* return error if TTY interface open */
48077 - if (info->port.count)
48078 + if (atomic_read(&info->port.count))
48079 return -EBUSY;
48080
48081 if (cmd != SIOCWANDEV)
48082 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48083 index 1abf946..1ee34fc 100644
48084 --- a/drivers/tty/synclink_gt.c
48085 +++ b/drivers/tty/synclink_gt.c
48086 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48087 tty->driver_data = info;
48088 info->port.tty = tty;
48089
48090 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48091 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48092
48093 /* If port is closing, signal caller to try again */
48094 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48095 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48096 mutex_unlock(&info->port.mutex);
48097 goto cleanup;
48098 }
48099 - info->port.count++;
48100 + atomic_inc(&info->port.count);
48101 spin_unlock_irqrestore(&info->netlock, flags);
48102
48103 - if (info->port.count == 1) {
48104 + if (atomic_read(&info->port.count) == 1) {
48105 /* 1st open on this device, init hardware */
48106 retval = startup(info);
48107 if (retval < 0) {
48108 @@ -715,8 +715,8 @@ cleanup:
48109 if (retval) {
48110 if (tty->count == 1)
48111 info->port.tty = NULL; /* tty layer will release tty struct */
48112 - if(info->port.count)
48113 - info->port.count--;
48114 + if(atomic_read(&info->port.count))
48115 + atomic_dec(&info->port.count);
48116 }
48117
48118 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48119 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48120
48121 if (sanity_check(info, tty->name, "close"))
48122 return;
48123 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48124 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48125
48126 if (tty_port_close_start(&info->port, tty, filp) == 0)
48127 goto cleanup;
48128 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48129 tty_port_close_end(&info->port, tty);
48130 info->port.tty = NULL;
48131 cleanup:
48132 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48133 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48134 }
48135
48136 static void hangup(struct tty_struct *tty)
48137 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48138 shutdown(info);
48139
48140 spin_lock_irqsave(&info->port.lock, flags);
48141 - info->port.count = 0;
48142 + atomic_set(&info->port.count, 0);
48143 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48144 info->port.tty = NULL;
48145 spin_unlock_irqrestore(&info->port.lock, flags);
48146 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48147 unsigned short new_crctype;
48148
48149 /* return error if TTY interface open */
48150 - if (info->port.count)
48151 + if (atomic_read(&info->port.count))
48152 return -EBUSY;
48153
48154 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48155 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48156
48157 /* arbitrate between network and tty opens */
48158 spin_lock_irqsave(&info->netlock, flags);
48159 - if (info->port.count != 0 || info->netcount != 0) {
48160 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48161 DBGINFO(("%s hdlc_open busy\n", dev->name));
48162 spin_unlock_irqrestore(&info->netlock, flags);
48163 return -EBUSY;
48164 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48165 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48166
48167 /* return error if TTY interface open */
48168 - if (info->port.count)
48169 + if (atomic_read(&info->port.count))
48170 return -EBUSY;
48171
48172 if (cmd != SIOCWANDEV)
48173 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48174 if (port == NULL)
48175 continue;
48176 spin_lock(&port->lock);
48177 - if ((port->port.count || port->netcount) &&
48178 + if ((atomic_read(&port->port.count) || port->netcount) &&
48179 port->pending_bh && !port->bh_running &&
48180 !port->bh_requested) {
48181 DBGISR(("%s bh queued\n", port->device_name));
48182 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48183 spin_lock_irqsave(&info->lock, flags);
48184 if (!tty_hung_up_p(filp)) {
48185 extra_count = true;
48186 - port->count--;
48187 + atomic_dec(&port->count);
48188 }
48189 spin_unlock_irqrestore(&info->lock, flags);
48190 port->blocked_open++;
48191 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48192 remove_wait_queue(&port->open_wait, &wait);
48193
48194 if (extra_count)
48195 - port->count++;
48196 + atomic_inc(&port->count);
48197 port->blocked_open--;
48198
48199 if (!retval)
48200 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48201 index dc6e969..5dc8786 100644
48202 --- a/drivers/tty/synclinkmp.c
48203 +++ b/drivers/tty/synclinkmp.c
48204 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48205
48206 if (debug_level >= DEBUG_LEVEL_INFO)
48207 printk("%s(%d):%s open(), old ref count = %d\n",
48208 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48209 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48210
48211 /* If port is closing, signal caller to try again */
48212 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48213 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48214 spin_unlock_irqrestore(&info->netlock, flags);
48215 goto cleanup;
48216 }
48217 - info->port.count++;
48218 + atomic_inc(&info->port.count);
48219 spin_unlock_irqrestore(&info->netlock, flags);
48220
48221 - if (info->port.count == 1) {
48222 + if (atomic_read(&info->port.count) == 1) {
48223 /* 1st open on this device, init hardware */
48224 retval = startup(info);
48225 if (retval < 0)
48226 @@ -796,8 +796,8 @@ cleanup:
48227 if (retval) {
48228 if (tty->count == 1)
48229 info->port.tty = NULL; /* tty layer will release tty struct */
48230 - if(info->port.count)
48231 - info->port.count--;
48232 + if(atomic_read(&info->port.count))
48233 + atomic_dec(&info->port.count);
48234 }
48235
48236 return retval;
48237 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48238
48239 if (debug_level >= DEBUG_LEVEL_INFO)
48240 printk("%s(%d):%s close() entry, count=%d\n",
48241 - __FILE__,__LINE__, info->device_name, info->port.count);
48242 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48243
48244 if (tty_port_close_start(&info->port, tty, filp) == 0)
48245 goto cleanup;
48246 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48247 cleanup:
48248 if (debug_level >= DEBUG_LEVEL_INFO)
48249 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48250 - tty->driver->name, info->port.count);
48251 + tty->driver->name, atomic_read(&info->port.count));
48252 }
48253
48254 /* Called by tty_hangup() when a hangup is signaled.
48255 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48256 shutdown(info);
48257
48258 spin_lock_irqsave(&info->port.lock, flags);
48259 - info->port.count = 0;
48260 + atomic_set(&info->port.count, 0);
48261 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48262 info->port.tty = NULL;
48263 spin_unlock_irqrestore(&info->port.lock, flags);
48264 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48265 unsigned short new_crctype;
48266
48267 /* return error if TTY interface open */
48268 - if (info->port.count)
48269 + if (atomic_read(&info->port.count))
48270 return -EBUSY;
48271
48272 switch (encoding)
48273 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48274
48275 /* arbitrate between network and tty opens */
48276 spin_lock_irqsave(&info->netlock, flags);
48277 - if (info->port.count != 0 || info->netcount != 0) {
48278 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48279 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48280 spin_unlock_irqrestore(&info->netlock, flags);
48281 return -EBUSY;
48282 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48283 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48284
48285 /* return error if TTY interface open */
48286 - if (info->port.count)
48287 + if (atomic_read(&info->port.count))
48288 return -EBUSY;
48289
48290 if (cmd != SIOCWANDEV)
48291 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48292 * do not request bottom half processing if the
48293 * device is not open in a normal mode.
48294 */
48295 - if ( port && (port->port.count || port->netcount) &&
48296 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48297 port->pending_bh && !port->bh_running &&
48298 !port->bh_requested ) {
48299 if ( debug_level >= DEBUG_LEVEL_ISR )
48300 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48301
48302 if (debug_level >= DEBUG_LEVEL_INFO)
48303 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48304 - __FILE__,__LINE__, tty->driver->name, port->count );
48305 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48306
48307 spin_lock_irqsave(&info->lock, flags);
48308 if (!tty_hung_up_p(filp)) {
48309 extra_count = true;
48310 - port->count--;
48311 + atomic_dec(&port->count);
48312 }
48313 spin_unlock_irqrestore(&info->lock, flags);
48314 port->blocked_open++;
48315 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48316
48317 if (debug_level >= DEBUG_LEVEL_INFO)
48318 printk("%s(%d):%s block_til_ready() count=%d\n",
48319 - __FILE__,__LINE__, tty->driver->name, port->count );
48320 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48321
48322 tty_unlock(tty);
48323 schedule();
48324 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48325 remove_wait_queue(&port->open_wait, &wait);
48326
48327 if (extra_count)
48328 - port->count++;
48329 + atomic_inc(&port->count);
48330 port->blocked_open--;
48331
48332 if (debug_level >= DEBUG_LEVEL_INFO)
48333 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48334 - __FILE__,__LINE__, tty->driver->name, port->count );
48335 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48336
48337 if (!retval)
48338 port->flags |= ASYNC_NORMAL_ACTIVE;
48339 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48340 index 40a9fe9..a3f10cc 100644
48341 --- a/drivers/tty/sysrq.c
48342 +++ b/drivers/tty/sysrq.c
48343 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48344 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48345 size_t count, loff_t *ppos)
48346 {
48347 - if (count) {
48348 + if (count && capable(CAP_SYS_ADMIN)) {
48349 char c;
48350
48351 if (get_user(c, buf))
48352 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48353 index 3a1a01a..b12cda2 100644
48354 --- a/drivers/tty/tty_io.c
48355 +++ b/drivers/tty/tty_io.c
48356 @@ -3473,7 +3473,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48357
48358 void tty_default_fops(struct file_operations *fops)
48359 {
48360 - *fops = tty_fops;
48361 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48362 }
48363
48364 /*
48365 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48366 index 6458e11..6cfc218 100644
48367 --- a/drivers/tty/tty_ldisc.c
48368 +++ b/drivers/tty/tty_ldisc.c
48369 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48370 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48371 tty_ldiscs[disc] = new_ldisc;
48372 new_ldisc->num = disc;
48373 - new_ldisc->refcount = 0;
48374 + atomic_set(&new_ldisc->refcount, 0);
48375 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48376
48377 return ret;
48378 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
48379 return -EINVAL;
48380
48381 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48382 - if (tty_ldiscs[disc]->refcount)
48383 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48384 ret = -EBUSY;
48385 else
48386 tty_ldiscs[disc] = NULL;
48387 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48388 if (ldops) {
48389 ret = ERR_PTR(-EAGAIN);
48390 if (try_module_get(ldops->owner)) {
48391 - ldops->refcount++;
48392 + atomic_inc(&ldops->refcount);
48393 ret = ldops;
48394 }
48395 }
48396 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48397 unsigned long flags;
48398
48399 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48400 - ldops->refcount--;
48401 + atomic_dec(&ldops->refcount);
48402 module_put(ldops->owner);
48403 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48404 }
48405 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48406 index f597e88..b7f68ed 100644
48407 --- a/drivers/tty/tty_port.c
48408 +++ b/drivers/tty/tty_port.c
48409 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48410 unsigned long flags;
48411
48412 spin_lock_irqsave(&port->lock, flags);
48413 - port->count = 0;
48414 + atomic_set(&port->count, 0);
48415 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48416 tty = port->tty;
48417 if (tty)
48418 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48419 /* The port lock protects the port counts */
48420 spin_lock_irqsave(&port->lock, flags);
48421 if (!tty_hung_up_p(filp))
48422 - port->count--;
48423 + atomic_dec(&port->count);
48424 port->blocked_open++;
48425 spin_unlock_irqrestore(&port->lock, flags);
48426
48427 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48428 we must not mess that up further */
48429 spin_lock_irqsave(&port->lock, flags);
48430 if (!tty_hung_up_p(filp))
48431 - port->count++;
48432 + atomic_inc(&port->count);
48433 port->blocked_open--;
48434 if (retval == 0)
48435 port->flags |= ASYNC_NORMAL_ACTIVE;
48436 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48437 return 0;
48438 }
48439
48440 - if (tty->count == 1 && port->count != 1) {
48441 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48442 printk(KERN_WARNING
48443 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48444 - port->count);
48445 - port->count = 1;
48446 + atomic_read(&port->count));
48447 + atomic_set(&port->count, 1);
48448 }
48449 - if (--port->count < 0) {
48450 + if (atomic_dec_return(&port->count) < 0) {
48451 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48452 - port->count);
48453 - port->count = 0;
48454 + atomic_read(&port->count));
48455 + atomic_set(&port->count, 0);
48456 }
48457
48458 - if (port->count) {
48459 + if (atomic_read(&port->count)) {
48460 spin_unlock_irqrestore(&port->lock, flags);
48461 if (port->ops->drop)
48462 port->ops->drop(port);
48463 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48464 {
48465 spin_lock_irq(&port->lock);
48466 if (!tty_hung_up_p(filp))
48467 - ++port->count;
48468 + atomic_inc(&port->count);
48469 spin_unlock_irq(&port->lock);
48470 tty_port_tty_set(port, tty);
48471
48472 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48473 index d0e3a44..5f8b754 100644
48474 --- a/drivers/tty/vt/keyboard.c
48475 +++ b/drivers/tty/vt/keyboard.c
48476 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48477 kbd->kbdmode == VC_OFF) &&
48478 value != KVAL(K_SAK))
48479 return; /* SAK is allowed even in raw mode */
48480 +
48481 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48482 + {
48483 + void *func = fn_handler[value];
48484 + if (func == fn_show_state || func == fn_show_ptregs ||
48485 + func == fn_show_mem)
48486 + return;
48487 + }
48488 +#endif
48489 +
48490 fn_handler[value](vc);
48491 }
48492
48493 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48494 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48495 return -EFAULT;
48496
48497 - if (!capable(CAP_SYS_TTY_CONFIG))
48498 - perm = 0;
48499 -
48500 switch (cmd) {
48501 case KDGKBENT:
48502 /* Ensure another thread doesn't free it under us */
48503 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48504 spin_unlock_irqrestore(&kbd_event_lock, flags);
48505 return put_user(val, &user_kbe->kb_value);
48506 case KDSKBENT:
48507 + if (!capable(CAP_SYS_TTY_CONFIG))
48508 + perm = 0;
48509 +
48510 if (!perm)
48511 return -EPERM;
48512 if (!i && v == K_NOSUCHMAP) {
48513 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48514 int i, j, k;
48515 int ret;
48516
48517 - if (!capable(CAP_SYS_TTY_CONFIG))
48518 - perm = 0;
48519 -
48520 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48521 if (!kbs) {
48522 ret = -ENOMEM;
48523 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48524 kfree(kbs);
48525 return ((p && *p) ? -EOVERFLOW : 0);
48526 case KDSKBSENT:
48527 + if (!capable(CAP_SYS_TTY_CONFIG))
48528 + perm = 0;
48529 +
48530 if (!perm) {
48531 ret = -EPERM;
48532 goto reterr;
48533 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48534 index 0e808cf..26c24ab 100644
48535 --- a/drivers/uio/uio.c
48536 +++ b/drivers/uio/uio.c
48537 @@ -25,6 +25,7 @@
48538 #include <linux/kobject.h>
48539 #include <linux/cdev.h>
48540 #include <linux/uio_driver.h>
48541 +#include <asm/local.h>
48542
48543 #define UIO_MAX_DEVICES (1U << MINORBITS)
48544
48545 @@ -32,7 +33,7 @@ struct uio_device {
48546 struct module *owner;
48547 struct device *dev;
48548 int minor;
48549 - atomic_t event;
48550 + atomic_unchecked_t event;
48551 struct fasync_struct *async_queue;
48552 wait_queue_head_t wait;
48553 struct uio_info *info;
48554 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
48555 struct device_attribute *attr, char *buf)
48556 {
48557 struct uio_device *idev = dev_get_drvdata(dev);
48558 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48559 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48560 }
48561 static DEVICE_ATTR_RO(event);
48562
48563 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
48564 {
48565 struct uio_device *idev = info->uio_dev;
48566
48567 - atomic_inc(&idev->event);
48568 + atomic_inc_unchecked(&idev->event);
48569 wake_up_interruptible(&idev->wait);
48570 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48571 }
48572 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48573 }
48574
48575 listener->dev = idev;
48576 - listener->event_count = atomic_read(&idev->event);
48577 + listener->event_count = atomic_read_unchecked(&idev->event);
48578 filep->private_data = listener;
48579
48580 if (idev->info->open) {
48581 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48582 return -EIO;
48583
48584 poll_wait(filep, &idev->wait, wait);
48585 - if (listener->event_count != atomic_read(&idev->event))
48586 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48587 return POLLIN | POLLRDNORM;
48588 return 0;
48589 }
48590 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48591 do {
48592 set_current_state(TASK_INTERRUPTIBLE);
48593
48594 - event_count = atomic_read(&idev->event);
48595 + event_count = atomic_read_unchecked(&idev->event);
48596 if (event_count != listener->event_count) {
48597 if (copy_to_user(buf, &event_count, count))
48598 retval = -EFAULT;
48599 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48600 static int uio_find_mem_index(struct vm_area_struct *vma)
48601 {
48602 struct uio_device *idev = vma->vm_private_data;
48603 + unsigned long size;
48604
48605 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48606 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48607 + size = idev->info->mem[vma->vm_pgoff].size;
48608 + if (size == 0)
48609 + return -1;
48610 + if (vma->vm_end - vma->vm_start > size)
48611 return -1;
48612 return (int)vma->vm_pgoff;
48613 }
48614 @@ -818,7 +823,7 @@ int __uio_register_device(struct module *owner,
48615 idev->owner = owner;
48616 idev->info = info;
48617 init_waitqueue_head(&idev->wait);
48618 - atomic_set(&idev->event, 0);
48619 + atomic_set_unchecked(&idev->event, 0);
48620
48621 ret = uio_get_minor(idev);
48622 if (ret)
48623 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48624 index 8a7eb77..c00402f 100644
48625 --- a/drivers/usb/atm/cxacru.c
48626 +++ b/drivers/usb/atm/cxacru.c
48627 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48628 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48629 if (ret < 2)
48630 return -EINVAL;
48631 - if (index < 0 || index > 0x7f)
48632 + if (index > 0x7f)
48633 return -EINVAL;
48634 pos += tmp;
48635
48636 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48637 index 25a7bfc..57f3cf5 100644
48638 --- a/drivers/usb/atm/usbatm.c
48639 +++ b/drivers/usb/atm/usbatm.c
48640 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48641 if (printk_ratelimit())
48642 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48643 __func__, vpi, vci);
48644 - atomic_inc(&vcc->stats->rx_err);
48645 + atomic_inc_unchecked(&vcc->stats->rx_err);
48646 return;
48647 }
48648
48649 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48650 if (length > ATM_MAX_AAL5_PDU) {
48651 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48652 __func__, length, vcc);
48653 - atomic_inc(&vcc->stats->rx_err);
48654 + atomic_inc_unchecked(&vcc->stats->rx_err);
48655 goto out;
48656 }
48657
48658 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48659 if (sarb->len < pdu_length) {
48660 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48661 __func__, pdu_length, sarb->len, vcc);
48662 - atomic_inc(&vcc->stats->rx_err);
48663 + atomic_inc_unchecked(&vcc->stats->rx_err);
48664 goto out;
48665 }
48666
48667 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48668 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48669 __func__, vcc);
48670 - atomic_inc(&vcc->stats->rx_err);
48671 + atomic_inc_unchecked(&vcc->stats->rx_err);
48672 goto out;
48673 }
48674
48675 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48676 if (printk_ratelimit())
48677 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48678 __func__, length);
48679 - atomic_inc(&vcc->stats->rx_drop);
48680 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48681 goto out;
48682 }
48683
48684 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48685
48686 vcc->push(vcc, skb);
48687
48688 - atomic_inc(&vcc->stats->rx);
48689 + atomic_inc_unchecked(&vcc->stats->rx);
48690 out:
48691 skb_trim(sarb, 0);
48692 }
48693 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
48694 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48695
48696 usbatm_pop(vcc, skb);
48697 - atomic_inc(&vcc->stats->tx);
48698 + atomic_inc_unchecked(&vcc->stats->tx);
48699
48700 skb = skb_dequeue(&instance->sndqueue);
48701 }
48702 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48703 if (!left--)
48704 return sprintf(page,
48705 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48706 - atomic_read(&atm_dev->stats.aal5.tx),
48707 - atomic_read(&atm_dev->stats.aal5.tx_err),
48708 - atomic_read(&atm_dev->stats.aal5.rx),
48709 - atomic_read(&atm_dev->stats.aal5.rx_err),
48710 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48711 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48712 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48713 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48714 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48715 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48716
48717 if (!left--) {
48718 if (instance->disconnected)
48719 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48720 index 2a3bbdf..91d72cf 100644
48721 --- a/drivers/usb/core/devices.c
48722 +++ b/drivers/usb/core/devices.c
48723 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48724 * time it gets called.
48725 */
48726 static struct device_connect_event {
48727 - atomic_t count;
48728 + atomic_unchecked_t count;
48729 wait_queue_head_t wait;
48730 } device_event = {
48731 .count = ATOMIC_INIT(1),
48732 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48733
48734 void usbfs_conn_disc_event(void)
48735 {
48736 - atomic_add(2, &device_event.count);
48737 + atomic_add_unchecked(2, &device_event.count);
48738 wake_up(&device_event.wait);
48739 }
48740
48741 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48742
48743 poll_wait(file, &device_event.wait, wait);
48744
48745 - event_count = atomic_read(&device_event.count);
48746 + event_count = atomic_read_unchecked(&device_event.count);
48747 if (file->f_version != event_count) {
48748 file->f_version = event_count;
48749 return POLLIN | POLLRDNORM;
48750 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48751 index f20a044..d1059aa 100644
48752 --- a/drivers/usb/core/hcd.c
48753 +++ b/drivers/usb/core/hcd.c
48754 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48755 */
48756 usb_get_urb(urb);
48757 atomic_inc(&urb->use_count);
48758 - atomic_inc(&urb->dev->urbnum);
48759 + atomic_inc_unchecked(&urb->dev->urbnum);
48760 usbmon_urb_submit(&hcd->self, urb);
48761
48762 /* NOTE requirements on root-hub callers (usbfs and the hub
48763 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48764 urb->hcpriv = NULL;
48765 INIT_LIST_HEAD(&urb->urb_list);
48766 atomic_dec(&urb->use_count);
48767 - atomic_dec(&urb->dev->urbnum);
48768 + atomic_dec_unchecked(&urb->dev->urbnum);
48769 if (atomic_read(&urb->reject))
48770 wake_up(&usb_kill_urb_queue);
48771 usb_put_urb(urb);
48772 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
48773 index 243c672..8b66fbb 100644
48774 --- a/drivers/usb/core/hub.c
48775 +++ b/drivers/usb/core/hub.c
48776 @@ -27,6 +27,7 @@
48777 #include <linux/freezer.h>
48778 #include <linux/random.h>
48779 #include <linux/pm_qos.h>
48780 +#include <linux/grsecurity.h>
48781
48782 #include <asm/uaccess.h>
48783 #include <asm/byteorder.h>
48784 @@ -4467,6 +4468,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
48785 goto done;
48786 return;
48787 }
48788 +
48789 + if (gr_handle_new_usb())
48790 + goto done;
48791 +
48792 if (hub_is_superspeed(hub->hdev))
48793 unit_load = 150;
48794 else
48795 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
48796 index 82927e1..4993dbf 100644
48797 --- a/drivers/usb/core/message.c
48798 +++ b/drivers/usb/core/message.c
48799 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
48800 * Return: If successful, the number of bytes transferred. Otherwise, a negative
48801 * error number.
48802 */
48803 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48804 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48805 __u8 requesttype, __u16 value, __u16 index, void *data,
48806 __u16 size, int timeout)
48807 {
48808 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
48809 * If successful, 0. Otherwise a negative error number. The number of actual
48810 * bytes transferred will be stored in the @actual_length paramater.
48811 */
48812 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48813 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48814 void *data, int len, int *actual_length, int timeout)
48815 {
48816 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
48817 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
48818 * bytes transferred will be stored in the @actual_length paramater.
48819 *
48820 */
48821 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48822 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48823 void *data, int len, int *actual_length, int timeout)
48824 {
48825 struct urb *urb;
48826 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
48827 index ca516ac..6c36ee4 100644
48828 --- a/drivers/usb/core/sysfs.c
48829 +++ b/drivers/usb/core/sysfs.c
48830 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
48831 struct usb_device *udev;
48832
48833 udev = to_usb_device(dev);
48834 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
48835 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
48836 }
48837 static DEVICE_ATTR_RO(urbnum);
48838
48839 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
48840 index 0a6ee2e..6f8d7e8 100644
48841 --- a/drivers/usb/core/usb.c
48842 +++ b/drivers/usb/core/usb.c
48843 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
48844 set_dev_node(&dev->dev, dev_to_node(bus->controller));
48845 dev->state = USB_STATE_ATTACHED;
48846 dev->lpm_disable_count = 1;
48847 - atomic_set(&dev->urbnum, 0);
48848 + atomic_set_unchecked(&dev->urbnum, 0);
48849
48850 INIT_LIST_HEAD(&dev->ep0.urb_list);
48851 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
48852 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
48853 index 5452c0f..34c9145 100644
48854 --- a/drivers/usb/dwc3/gadget.c
48855 +++ b/drivers/usb/dwc3/gadget.c
48856 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
48857 if (!usb_endpoint_xfer_isoc(desc))
48858 return 0;
48859
48860 - memset(&trb_link, 0, sizeof(trb_link));
48861 -
48862 /* Link TRB for ISOC. The HWO bit is never reset */
48863 trb_st_hw = &dep->trb_pool[0];
48864
48865 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
48866 index 5e29dde..eca992f 100644
48867 --- a/drivers/usb/early/ehci-dbgp.c
48868 +++ b/drivers/usb/early/ehci-dbgp.c
48869 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
48870
48871 #ifdef CONFIG_KGDB
48872 static struct kgdb_io kgdbdbgp_io_ops;
48873 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
48874 +static struct kgdb_io kgdbdbgp_io_ops_console;
48875 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
48876 #else
48877 #define dbgp_kgdb_mode (0)
48878 #endif
48879 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
48880 .write_char = kgdbdbgp_write_char,
48881 };
48882
48883 +static struct kgdb_io kgdbdbgp_io_ops_console = {
48884 + .name = "kgdbdbgp",
48885 + .read_char = kgdbdbgp_read_char,
48886 + .write_char = kgdbdbgp_write_char,
48887 + .is_console = 1
48888 +};
48889 +
48890 static int kgdbdbgp_wait_time;
48891
48892 static int __init kgdbdbgp_parse_config(char *str)
48893 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
48894 ptr++;
48895 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
48896 }
48897 - kgdb_register_io_module(&kgdbdbgp_io_ops);
48898 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
48899 + if (early_dbgp_console.index != -1)
48900 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
48901 + else
48902 + kgdb_register_io_module(&kgdbdbgp_io_ops);
48903
48904 return 0;
48905 }
48906 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
48907 index b369292..9f3ba40 100644
48908 --- a/drivers/usb/gadget/u_serial.c
48909 +++ b/drivers/usb/gadget/u_serial.c
48910 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48911 spin_lock_irq(&port->port_lock);
48912
48913 /* already open? Great. */
48914 - if (port->port.count) {
48915 + if (atomic_read(&port->port.count)) {
48916 status = 0;
48917 - port->port.count++;
48918 + atomic_inc(&port->port.count);
48919
48920 /* currently opening/closing? wait ... */
48921 } else if (port->openclose) {
48922 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48923 tty->driver_data = port;
48924 port->port.tty = tty;
48925
48926 - port->port.count = 1;
48927 + atomic_set(&port->port.count, 1);
48928 port->openclose = false;
48929
48930 /* if connected, start the I/O stream */
48931 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48932
48933 spin_lock_irq(&port->port_lock);
48934
48935 - if (port->port.count != 1) {
48936 - if (port->port.count == 0)
48937 + if (atomic_read(&port->port.count) != 1) {
48938 + if (atomic_read(&port->port.count) == 0)
48939 WARN_ON(1);
48940 else
48941 - --port->port.count;
48942 + atomic_dec(&port->port.count);
48943 goto exit;
48944 }
48945
48946 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48947 * and sleep if necessary
48948 */
48949 port->openclose = true;
48950 - port->port.count = 0;
48951 + atomic_set(&port->port.count, 0);
48952
48953 gser = port->port_usb;
48954 if (gser && gser->disconnect)
48955 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
48956 int cond;
48957
48958 spin_lock_irq(&port->port_lock);
48959 - cond = (port->port.count == 0) && !port->openclose;
48960 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
48961 spin_unlock_irq(&port->port_lock);
48962 return cond;
48963 }
48964 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
48965 /* if it's already open, start I/O ... and notify the serial
48966 * protocol about open/close status (connect/disconnect).
48967 */
48968 - if (port->port.count) {
48969 + if (atomic_read(&port->port.count)) {
48970 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
48971 gs_start_io(port);
48972 if (gser->connect)
48973 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
48974
48975 port->port_usb = NULL;
48976 gser->ioport = NULL;
48977 - if (port->port.count > 0 || port->openclose) {
48978 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
48979 wake_up_interruptible(&port->drain_wait);
48980 if (port->port.tty)
48981 tty_hangup(port->port.tty);
48982 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
48983
48984 /* finally, free any unused/unusable I/O buffers */
48985 spin_lock_irqsave(&port->port_lock, flags);
48986 - if (port->port.count == 0 && !port->openclose)
48987 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
48988 gs_buf_free(&port->port_write_buf);
48989 gs_free_requests(gser->out, &port->read_pool, NULL);
48990 gs_free_requests(gser->out, &port->read_queue, NULL);
48991 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
48992 index 835fc08..f8b22bf 100644
48993 --- a/drivers/usb/host/ehci-hub.c
48994 +++ b/drivers/usb/host/ehci-hub.c
48995 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
48996 urb->transfer_flags = URB_DIR_IN;
48997 usb_get_urb(urb);
48998 atomic_inc(&urb->use_count);
48999 - atomic_inc(&urb->dev->urbnum);
49000 + atomic_inc_unchecked(&urb->dev->urbnum);
49001 urb->setup_dma = dma_map_single(
49002 hcd->self.controller,
49003 urb->setup_packet,
49004 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49005 urb->status = -EINPROGRESS;
49006 usb_get_urb(urb);
49007 atomic_inc(&urb->use_count);
49008 - atomic_inc(&urb->dev->urbnum);
49009 + atomic_inc_unchecked(&urb->dev->urbnum);
49010 retval = submit_single_step_set_feature(hcd, urb, 0);
49011 if (!retval && !wait_for_completion_timeout(&done,
49012 msecs_to_jiffies(2000))) {
49013 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49014 index ba6a5d6..f88f7f3 100644
49015 --- a/drivers/usb/misc/appledisplay.c
49016 +++ b/drivers/usb/misc/appledisplay.c
49017 @@ -83,7 +83,7 @@ struct appledisplay {
49018 spinlock_t lock;
49019 };
49020
49021 -static atomic_t count_displays = ATOMIC_INIT(0);
49022 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49023 static struct workqueue_struct *wq;
49024
49025 static void appledisplay_complete(struct urb *urb)
49026 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49027
49028 /* Register backlight device */
49029 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49030 - atomic_inc_return(&count_displays) - 1);
49031 + atomic_inc_return_unchecked(&count_displays) - 1);
49032 memset(&props, 0, sizeof(struct backlight_properties));
49033 props.type = BACKLIGHT_RAW;
49034 props.max_brightness = 0xff;
49035 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49036 index c69bb50..215ef37 100644
49037 --- a/drivers/usb/serial/console.c
49038 +++ b/drivers/usb/serial/console.c
49039 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49040
49041 info->port = port;
49042
49043 - ++port->port.count;
49044 + atomic_inc(&port->port.count);
49045 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49046 if (serial->type->set_termios) {
49047 /*
49048 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49049 }
49050 /* Now that any required fake tty operations are completed restore
49051 * the tty port count */
49052 - --port->port.count;
49053 + atomic_dec(&port->port.count);
49054 /* The console is special in terms of closing the device so
49055 * indicate this port is now acting as a system console. */
49056 port->port.console = 1;
49057 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49058 free_tty:
49059 kfree(tty);
49060 reset_open_count:
49061 - port->port.count = 0;
49062 + atomic_set(&port->port.count, 0);
49063 usb_autopm_put_interface(serial->interface);
49064 error_get_interface:
49065 usb_serial_put(serial);
49066 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49067 static void usb_console_write(struct console *co,
49068 const char *buf, unsigned count)
49069 {
49070 - static struct usbcons_info *info = &usbcons_info;
49071 + struct usbcons_info *info = &usbcons_info;
49072 struct usb_serial_port *port = info->port;
49073 struct usb_serial *serial;
49074 int retval = -ENODEV;
49075 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49076 index 75f70f0..d467e1a 100644
49077 --- a/drivers/usb/storage/usb.h
49078 +++ b/drivers/usb/storage/usb.h
49079 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49080 __u8 useProtocol;
49081 __u8 useTransport;
49082 int (*initFunction)(struct us_data *);
49083 -};
49084 +} __do_const;
49085
49086
49087 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49088 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49089 index cf250c2..ad9d904 100644
49090 --- a/drivers/usb/wusbcore/wa-hc.h
49091 +++ b/drivers/usb/wusbcore/wa-hc.h
49092 @@ -199,7 +199,7 @@ struct wahc {
49093 spinlock_t xfer_list_lock;
49094 struct work_struct xfer_enqueue_work;
49095 struct work_struct xfer_error_work;
49096 - atomic_t xfer_id_count;
49097 + atomic_unchecked_t xfer_id_count;
49098 };
49099
49100
49101 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49102 spin_lock_init(&wa->xfer_list_lock);
49103 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49104 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49105 - atomic_set(&wa->xfer_id_count, 1);
49106 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49107 }
49108
49109 /**
49110 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49111 index 6ad02f5..cc52c8b 100644
49112 --- a/drivers/usb/wusbcore/wa-xfer.c
49113 +++ b/drivers/usb/wusbcore/wa-xfer.c
49114 @@ -299,7 +299,7 @@ out:
49115 */
49116 static void wa_xfer_id_init(struct wa_xfer *xfer)
49117 {
49118 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49119 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49120 }
49121
49122 /*
49123 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49124 index 1eab4ac..e21efc9 100644
49125 --- a/drivers/vfio/vfio.c
49126 +++ b/drivers/vfio/vfio.c
49127 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49128 return 0;
49129
49130 /* TODO Prevent device auto probing */
49131 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49132 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49133 iommu_group_id(group->iommu_group));
49134
49135 return 0;
49136 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49137 index 5174eba..86e764a 100644
49138 --- a/drivers/vhost/vringh.c
49139 +++ b/drivers/vhost/vringh.c
49140 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49141
49142 static inline int putu16_kern(u16 *p, u16 val)
49143 {
49144 - ACCESS_ONCE(*p) = val;
49145 + ACCESS_ONCE_RW(*p) = val;
49146 return 0;
49147 }
49148
49149 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49150 index e43401a..dd49b3f 100644
49151 --- a/drivers/video/arcfb.c
49152 +++ b/drivers/video/arcfb.c
49153 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49154 return -ENOSPC;
49155
49156 err = 0;
49157 - if ((count + p) > fbmemlength) {
49158 + if (count > (fbmemlength - p)) {
49159 count = fbmemlength - p;
49160 err = -ENOSPC;
49161 }
49162 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49163 index a4dfe8c..297ddd9 100644
49164 --- a/drivers/video/aty/aty128fb.c
49165 +++ b/drivers/video/aty/aty128fb.c
49166 @@ -149,7 +149,7 @@ enum {
49167 };
49168
49169 /* Must match above enum */
49170 -static char * const r128_family[] = {
49171 +static const char * const r128_family[] = {
49172 "AGP",
49173 "PCI",
49174 "PRO AGP",
49175 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49176 index 9b0f12c..024673d 100644
49177 --- a/drivers/video/aty/atyfb_base.c
49178 +++ b/drivers/video/aty/atyfb_base.c
49179 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49180 par->accel_flags = var->accel_flags; /* hack */
49181
49182 if (var->accel_flags) {
49183 - info->fbops->fb_sync = atyfb_sync;
49184 + pax_open_kernel();
49185 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49186 + pax_close_kernel();
49187 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49188 } else {
49189 - info->fbops->fb_sync = NULL;
49190 + pax_open_kernel();
49191 + *(void **)&info->fbops->fb_sync = NULL;
49192 + pax_close_kernel();
49193 info->flags |= FBINFO_HWACCEL_DISABLED;
49194 }
49195
49196 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49197 index 95ec042..e6affdd 100644
49198 --- a/drivers/video/aty/mach64_cursor.c
49199 +++ b/drivers/video/aty/mach64_cursor.c
49200 @@ -7,6 +7,7 @@
49201 #include <linux/string.h>
49202
49203 #include <asm/io.h>
49204 +#include <asm/pgtable.h>
49205
49206 #ifdef __sparc__
49207 #include <asm/fbio.h>
49208 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49209 info->sprite.buf_align = 16; /* and 64 lines tall. */
49210 info->sprite.flags = FB_PIXMAP_IO;
49211
49212 - info->fbops->fb_cursor = atyfb_cursor;
49213 + pax_open_kernel();
49214 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49215 + pax_close_kernel();
49216
49217 return 0;
49218 }
49219 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49220 index bca6ccc..252107e 100644
49221 --- a/drivers/video/backlight/kb3886_bl.c
49222 +++ b/drivers/video/backlight/kb3886_bl.c
49223 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49224 static unsigned long kb3886bl_flags;
49225 #define KB3886BL_SUSPENDED 0x01
49226
49227 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49228 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49229 {
49230 .ident = "Sahara Touch-iT",
49231 .matches = {
49232 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49233 index 900aa4e..6d49418 100644
49234 --- a/drivers/video/fb_defio.c
49235 +++ b/drivers/video/fb_defio.c
49236 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49237
49238 BUG_ON(!fbdefio);
49239 mutex_init(&fbdefio->lock);
49240 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49241 + pax_open_kernel();
49242 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49243 + pax_close_kernel();
49244 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49245 INIT_LIST_HEAD(&fbdefio->pagelist);
49246 if (fbdefio->delay == 0) /* set a default of 1 s */
49247 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49248 page->mapping = NULL;
49249 }
49250
49251 - info->fbops->fb_mmap = NULL;
49252 + *(void **)&info->fbops->fb_mmap = NULL;
49253 mutex_destroy(&fbdefio->lock);
49254 }
49255 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49256 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49257 index dacaf74..8478a46 100644
49258 --- a/drivers/video/fbmem.c
49259 +++ b/drivers/video/fbmem.c
49260 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49261 image->dx += image->width + 8;
49262 }
49263 } else if (rotate == FB_ROTATE_UD) {
49264 - for (x = 0; x < num && image->dx >= 0; x++) {
49265 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49266 info->fbops->fb_imageblit(info, image);
49267 image->dx -= image->width + 8;
49268 }
49269 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49270 image->dy += image->height + 8;
49271 }
49272 } else if (rotate == FB_ROTATE_CCW) {
49273 - for (x = 0; x < num && image->dy >= 0; x++) {
49274 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49275 info->fbops->fb_imageblit(info, image);
49276 image->dy -= image->height + 8;
49277 }
49278 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49279 return -EFAULT;
49280 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49281 return -EINVAL;
49282 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49283 + if (con2fb.framebuffer >= FB_MAX)
49284 return -EINVAL;
49285 if (!registered_fb[con2fb.framebuffer])
49286 request_module("fb%d", con2fb.framebuffer);
49287 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49288 index 8d456dc..b4fa44b 100644
49289 --- a/drivers/video/hyperv_fb.c
49290 +++ b/drivers/video/hyperv_fb.c
49291 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49292 static inline int synthvid_send(struct hv_device *hdev,
49293 struct synthvid_msg *msg)
49294 {
49295 - static atomic64_t request_id = ATOMIC64_INIT(0);
49296 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49297 int ret;
49298
49299 msg->pipe_hdr.type = PIPE_MSG_DATA;
49300 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49301
49302 ret = vmbus_sendpacket(hdev->channel, msg,
49303 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49304 - atomic64_inc_return(&request_id),
49305 + atomic64_inc_return_unchecked(&request_id),
49306 VM_PKT_DATA_INBAND, 0);
49307
49308 if (ret)
49309 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49310 index 7672d2e..b56437f 100644
49311 --- a/drivers/video/i810/i810_accel.c
49312 +++ b/drivers/video/i810/i810_accel.c
49313 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49314 }
49315 }
49316 printk("ringbuffer lockup!!!\n");
49317 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49318 i810_report_error(mmio);
49319 par->dev_flags |= LOCKUP;
49320 info->pixmap.scan_align = 1;
49321 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49322 index 3c14e43..2630570 100644
49323 --- a/drivers/video/logo/logo_linux_clut224.ppm
49324 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49325 @@ -2,1603 +2,1123 @@ P3
49326 # Standard 224-color Linux logo
49327 80 80
49328 255
49329 - 0 0 0 0 0 0 0 0 0 0 0 0
49330 - 0 0 0 0 0 0 0 0 0 0 0 0
49331 - 0 0 0 0 0 0 0 0 0 0 0 0
49332 - 0 0 0 0 0 0 0 0 0 0 0 0
49333 - 0 0 0 0 0 0 0 0 0 0 0 0
49334 - 0 0 0 0 0 0 0 0 0 0 0 0
49335 - 0 0 0 0 0 0 0 0 0 0 0 0
49336 - 0 0 0 0 0 0 0 0 0 0 0 0
49337 - 0 0 0 0 0 0 0 0 0 0 0 0
49338 - 6 6 6 6 6 6 10 10 10 10 10 10
49339 - 10 10 10 6 6 6 6 6 6 6 6 6
49340 - 0 0 0 0 0 0 0 0 0 0 0 0
49341 - 0 0 0 0 0 0 0 0 0 0 0 0
49342 - 0 0 0 0 0 0 0 0 0 0 0 0
49343 - 0 0 0 0 0 0 0 0 0 0 0 0
49344 - 0 0 0 0 0 0 0 0 0 0 0 0
49345 - 0 0 0 0 0 0 0 0 0 0 0 0
49346 - 0 0 0 0 0 0 0 0 0 0 0 0
49347 - 0 0 0 0 0 0 0 0 0 0 0 0
49348 - 0 0 0 0 0 0 0 0 0 0 0 0
49349 - 0 0 0 0 0 0 0 0 0 0 0 0
49350 - 0 0 0 0 0 0 0 0 0 0 0 0
49351 - 0 0 0 0 0 0 0 0 0 0 0 0
49352 - 0 0 0 0 0 0 0 0 0 0 0 0
49353 - 0 0 0 0 0 0 0 0 0 0 0 0
49354 - 0 0 0 0 0 0 0 0 0 0 0 0
49355 - 0 0 0 0 0 0 0 0 0 0 0 0
49356 - 0 0 0 0 0 0 0 0 0 0 0 0
49357 - 0 0 0 6 6 6 10 10 10 14 14 14
49358 - 22 22 22 26 26 26 30 30 30 34 34 34
49359 - 30 30 30 30 30 30 26 26 26 18 18 18
49360 - 14 14 14 10 10 10 6 6 6 0 0 0
49361 - 0 0 0 0 0 0 0 0 0 0 0 0
49362 - 0 0 0 0 0 0 0 0 0 0 0 0
49363 - 0 0 0 0 0 0 0 0 0 0 0 0
49364 - 0 0 0 0 0 0 0 0 0 0 0 0
49365 - 0 0 0 0 0 0 0 0 0 0 0 0
49366 - 0 0 0 0 0 0 0 0 0 0 0 0
49367 - 0 0 0 0 0 0 0 0 0 0 0 0
49368 - 0 0 0 0 0 0 0 0 0 0 0 0
49369 - 0 0 0 0 0 0 0 0 0 0 0 0
49370 - 0 0 0 0 0 1 0 0 1 0 0 0
49371 - 0 0 0 0 0 0 0 0 0 0 0 0
49372 - 0 0 0 0 0 0 0 0 0 0 0 0
49373 - 0 0 0 0 0 0 0 0 0 0 0 0
49374 - 0 0 0 0 0 0 0 0 0 0 0 0
49375 - 0 0 0 0 0 0 0 0 0 0 0 0
49376 - 0 0 0 0 0 0 0 0 0 0 0 0
49377 - 6 6 6 14 14 14 26 26 26 42 42 42
49378 - 54 54 54 66 66 66 78 78 78 78 78 78
49379 - 78 78 78 74 74 74 66 66 66 54 54 54
49380 - 42 42 42 26 26 26 18 18 18 10 10 10
49381 - 6 6 6 0 0 0 0 0 0 0 0 0
49382 - 0 0 0 0 0 0 0 0 0 0 0 0
49383 - 0 0 0 0 0 0 0 0 0 0 0 0
49384 - 0 0 0 0 0 0 0 0 0 0 0 0
49385 - 0 0 0 0 0 0 0 0 0 0 0 0
49386 - 0 0 0 0 0 0 0 0 0 0 0 0
49387 - 0 0 0 0 0 0 0 0 0 0 0 0
49388 - 0 0 0 0 0 0 0 0 0 0 0 0
49389 - 0 0 0 0 0 0 0 0 0 0 0 0
49390 - 0 0 1 0 0 0 0 0 0 0 0 0
49391 - 0 0 0 0 0 0 0 0 0 0 0 0
49392 - 0 0 0 0 0 0 0 0 0 0 0 0
49393 - 0 0 0 0 0 0 0 0 0 0 0 0
49394 - 0 0 0 0 0 0 0 0 0 0 0 0
49395 - 0 0 0 0 0 0 0 0 0 0 0 0
49396 - 0 0 0 0 0 0 0 0 0 10 10 10
49397 - 22 22 22 42 42 42 66 66 66 86 86 86
49398 - 66 66 66 38 38 38 38 38 38 22 22 22
49399 - 26 26 26 34 34 34 54 54 54 66 66 66
49400 - 86 86 86 70 70 70 46 46 46 26 26 26
49401 - 14 14 14 6 6 6 0 0 0 0 0 0
49402 - 0 0 0 0 0 0 0 0 0 0 0 0
49403 - 0 0 0 0 0 0 0 0 0 0 0 0
49404 - 0 0 0 0 0 0 0 0 0 0 0 0
49405 - 0 0 0 0 0 0 0 0 0 0 0 0
49406 - 0 0 0 0 0 0 0 0 0 0 0 0
49407 - 0 0 0 0 0 0 0 0 0 0 0 0
49408 - 0 0 0 0 0 0 0 0 0 0 0 0
49409 - 0 0 0 0 0 0 0 0 0 0 0 0
49410 - 0 0 1 0 0 1 0 0 1 0 0 0
49411 - 0 0 0 0 0 0 0 0 0 0 0 0
49412 - 0 0 0 0 0 0 0 0 0 0 0 0
49413 - 0 0 0 0 0 0 0 0 0 0 0 0
49414 - 0 0 0 0 0 0 0 0 0 0 0 0
49415 - 0 0 0 0 0 0 0 0 0 0 0 0
49416 - 0 0 0 0 0 0 10 10 10 26 26 26
49417 - 50 50 50 82 82 82 58 58 58 6 6 6
49418 - 2 2 6 2 2 6 2 2 6 2 2 6
49419 - 2 2 6 2 2 6 2 2 6 2 2 6
49420 - 6 6 6 54 54 54 86 86 86 66 66 66
49421 - 38 38 38 18 18 18 6 6 6 0 0 0
49422 - 0 0 0 0 0 0 0 0 0 0 0 0
49423 - 0 0 0 0 0 0 0 0 0 0 0 0
49424 - 0 0 0 0 0 0 0 0 0 0 0 0
49425 - 0 0 0 0 0 0 0 0 0 0 0 0
49426 - 0 0 0 0 0 0 0 0 0 0 0 0
49427 - 0 0 0 0 0 0 0 0 0 0 0 0
49428 - 0 0 0 0 0 0 0 0 0 0 0 0
49429 - 0 0 0 0 0 0 0 0 0 0 0 0
49430 - 0 0 0 0 0 0 0 0 0 0 0 0
49431 - 0 0 0 0 0 0 0 0 0 0 0 0
49432 - 0 0 0 0 0 0 0 0 0 0 0 0
49433 - 0 0 0 0 0 0 0 0 0 0 0 0
49434 - 0 0 0 0 0 0 0 0 0 0 0 0
49435 - 0 0 0 0 0 0 0 0 0 0 0 0
49436 - 0 0 0 6 6 6 22 22 22 50 50 50
49437 - 78 78 78 34 34 34 2 2 6 2 2 6
49438 - 2 2 6 2 2 6 2 2 6 2 2 6
49439 - 2 2 6 2 2 6 2 2 6 2 2 6
49440 - 2 2 6 2 2 6 6 6 6 70 70 70
49441 - 78 78 78 46 46 46 22 22 22 6 6 6
49442 - 0 0 0 0 0 0 0 0 0 0 0 0
49443 - 0 0 0 0 0 0 0 0 0 0 0 0
49444 - 0 0 0 0 0 0 0 0 0 0 0 0
49445 - 0 0 0 0 0 0 0 0 0 0 0 0
49446 - 0 0 0 0 0 0 0 0 0 0 0 0
49447 - 0 0 0 0 0 0 0 0 0 0 0 0
49448 - 0 0 0 0 0 0 0 0 0 0 0 0
49449 - 0 0 0 0 0 0 0 0 0 0 0 0
49450 - 0 0 1 0 0 1 0 0 1 0 0 0
49451 - 0 0 0 0 0 0 0 0 0 0 0 0
49452 - 0 0 0 0 0 0 0 0 0 0 0 0
49453 - 0 0 0 0 0 0 0 0 0 0 0 0
49454 - 0 0 0 0 0 0 0 0 0 0 0 0
49455 - 0 0 0 0 0 0 0 0 0 0 0 0
49456 - 6 6 6 18 18 18 42 42 42 82 82 82
49457 - 26 26 26 2 2 6 2 2 6 2 2 6
49458 - 2 2 6 2 2 6 2 2 6 2 2 6
49459 - 2 2 6 2 2 6 2 2 6 14 14 14
49460 - 46 46 46 34 34 34 6 6 6 2 2 6
49461 - 42 42 42 78 78 78 42 42 42 18 18 18
49462 - 6 6 6 0 0 0 0 0 0 0 0 0
49463 - 0 0 0 0 0 0 0 0 0 0 0 0
49464 - 0 0 0 0 0 0 0 0 0 0 0 0
49465 - 0 0 0 0 0 0 0 0 0 0 0 0
49466 - 0 0 0 0 0 0 0 0 0 0 0 0
49467 - 0 0 0 0 0 0 0 0 0 0 0 0
49468 - 0 0 0 0 0 0 0 0 0 0 0 0
49469 - 0 0 0 0 0 0 0 0 0 0 0 0
49470 - 0 0 1 0 0 0 0 0 1 0 0 0
49471 - 0 0 0 0 0 0 0 0 0 0 0 0
49472 - 0 0 0 0 0 0 0 0 0 0 0 0
49473 - 0 0 0 0 0 0 0 0 0 0 0 0
49474 - 0 0 0 0 0 0 0 0 0 0 0 0
49475 - 0 0 0 0 0 0 0 0 0 0 0 0
49476 - 10 10 10 30 30 30 66 66 66 58 58 58
49477 - 2 2 6 2 2 6 2 2 6 2 2 6
49478 - 2 2 6 2 2 6 2 2 6 2 2 6
49479 - 2 2 6 2 2 6 2 2 6 26 26 26
49480 - 86 86 86 101 101 101 46 46 46 10 10 10
49481 - 2 2 6 58 58 58 70 70 70 34 34 34
49482 - 10 10 10 0 0 0 0 0 0 0 0 0
49483 - 0 0 0 0 0 0 0 0 0 0 0 0
49484 - 0 0 0 0 0 0 0 0 0 0 0 0
49485 - 0 0 0 0 0 0 0 0 0 0 0 0
49486 - 0 0 0 0 0 0 0 0 0 0 0 0
49487 - 0 0 0 0 0 0 0 0 0 0 0 0
49488 - 0 0 0 0 0 0 0 0 0 0 0 0
49489 - 0 0 0 0 0 0 0 0 0 0 0 0
49490 - 0 0 1 0 0 1 0 0 1 0 0 0
49491 - 0 0 0 0 0 0 0 0 0 0 0 0
49492 - 0 0 0 0 0 0 0 0 0 0 0 0
49493 - 0 0 0 0 0 0 0 0 0 0 0 0
49494 - 0 0 0 0 0 0 0 0 0 0 0 0
49495 - 0 0 0 0 0 0 0 0 0 0 0 0
49496 - 14 14 14 42 42 42 86 86 86 10 10 10
49497 - 2 2 6 2 2 6 2 2 6 2 2 6
49498 - 2 2 6 2 2 6 2 2 6 2 2 6
49499 - 2 2 6 2 2 6 2 2 6 30 30 30
49500 - 94 94 94 94 94 94 58 58 58 26 26 26
49501 - 2 2 6 6 6 6 78 78 78 54 54 54
49502 - 22 22 22 6 6 6 0 0 0 0 0 0
49503 - 0 0 0 0 0 0 0 0 0 0 0 0
49504 - 0 0 0 0 0 0 0 0 0 0 0 0
49505 - 0 0 0 0 0 0 0 0 0 0 0 0
49506 - 0 0 0 0 0 0 0 0 0 0 0 0
49507 - 0 0 0 0 0 0 0 0 0 0 0 0
49508 - 0 0 0 0 0 0 0 0 0 0 0 0
49509 - 0 0 0 0 0 0 0 0 0 0 0 0
49510 - 0 0 0 0 0 0 0 0 0 0 0 0
49511 - 0 0 0 0 0 0 0 0 0 0 0 0
49512 - 0 0 0 0 0 0 0 0 0 0 0 0
49513 - 0 0 0 0 0 0 0 0 0 0 0 0
49514 - 0 0 0 0 0 0 0 0 0 0 0 0
49515 - 0 0 0 0 0 0 0 0 0 6 6 6
49516 - 22 22 22 62 62 62 62 62 62 2 2 6
49517 - 2 2 6 2 2 6 2 2 6 2 2 6
49518 - 2 2 6 2 2 6 2 2 6 2 2 6
49519 - 2 2 6 2 2 6 2 2 6 26 26 26
49520 - 54 54 54 38 38 38 18 18 18 10 10 10
49521 - 2 2 6 2 2 6 34 34 34 82 82 82
49522 - 38 38 38 14 14 14 0 0 0 0 0 0
49523 - 0 0 0 0 0 0 0 0 0 0 0 0
49524 - 0 0 0 0 0 0 0 0 0 0 0 0
49525 - 0 0 0 0 0 0 0 0 0 0 0 0
49526 - 0 0 0 0 0 0 0 0 0 0 0 0
49527 - 0 0 0 0 0 0 0 0 0 0 0 0
49528 - 0 0 0 0 0 0 0 0 0 0 0 0
49529 - 0 0 0 0 0 0 0 0 0 0 0 0
49530 - 0 0 0 0 0 1 0 0 1 0 0 0
49531 - 0 0 0 0 0 0 0 0 0 0 0 0
49532 - 0 0 0 0 0 0 0 0 0 0 0 0
49533 - 0 0 0 0 0 0 0 0 0 0 0 0
49534 - 0 0 0 0 0 0 0 0 0 0 0 0
49535 - 0 0 0 0 0 0 0 0 0 6 6 6
49536 - 30 30 30 78 78 78 30 30 30 2 2 6
49537 - 2 2 6 2 2 6 2 2 6 2 2 6
49538 - 2 2 6 2 2 6 2 2 6 2 2 6
49539 - 2 2 6 2 2 6 2 2 6 10 10 10
49540 - 10 10 10 2 2 6 2 2 6 2 2 6
49541 - 2 2 6 2 2 6 2 2 6 78 78 78
49542 - 50 50 50 18 18 18 6 6 6 0 0 0
49543 - 0 0 0 0 0 0 0 0 0 0 0 0
49544 - 0 0 0 0 0 0 0 0 0 0 0 0
49545 - 0 0 0 0 0 0 0 0 0 0 0 0
49546 - 0 0 0 0 0 0 0 0 0 0 0 0
49547 - 0 0 0 0 0 0 0 0 0 0 0 0
49548 - 0 0 0 0 0 0 0 0 0 0 0 0
49549 - 0 0 0 0 0 0 0 0 0 0 0 0
49550 - 0 0 1 0 0 0 0 0 0 0 0 0
49551 - 0 0 0 0 0 0 0 0 0 0 0 0
49552 - 0 0 0 0 0 0 0 0 0 0 0 0
49553 - 0 0 0 0 0 0 0 0 0 0 0 0
49554 - 0 0 0 0 0 0 0 0 0 0 0 0
49555 - 0 0 0 0 0 0 0 0 0 10 10 10
49556 - 38 38 38 86 86 86 14 14 14 2 2 6
49557 - 2 2 6 2 2 6 2 2 6 2 2 6
49558 - 2 2 6 2 2 6 2 2 6 2 2 6
49559 - 2 2 6 2 2 6 2 2 6 2 2 6
49560 - 2 2 6 2 2 6 2 2 6 2 2 6
49561 - 2 2 6 2 2 6 2 2 6 54 54 54
49562 - 66 66 66 26 26 26 6 6 6 0 0 0
49563 - 0 0 0 0 0 0 0 0 0 0 0 0
49564 - 0 0 0 0 0 0 0 0 0 0 0 0
49565 - 0 0 0 0 0 0 0 0 0 0 0 0
49566 - 0 0 0 0 0 0 0 0 0 0 0 0
49567 - 0 0 0 0 0 0 0 0 0 0 0 0
49568 - 0 0 0 0 0 0 0 0 0 0 0 0
49569 - 0 0 0 0 0 0 0 0 0 0 0 0
49570 - 0 0 0 0 0 1 0 0 1 0 0 0
49571 - 0 0 0 0 0 0 0 0 0 0 0 0
49572 - 0 0 0 0 0 0 0 0 0 0 0 0
49573 - 0 0 0 0 0 0 0 0 0 0 0 0
49574 - 0 0 0 0 0 0 0 0 0 0 0 0
49575 - 0 0 0 0 0 0 0 0 0 14 14 14
49576 - 42 42 42 82 82 82 2 2 6 2 2 6
49577 - 2 2 6 6 6 6 10 10 10 2 2 6
49578 - 2 2 6 2 2 6 2 2 6 2 2 6
49579 - 2 2 6 2 2 6 2 2 6 6 6 6
49580 - 14 14 14 10 10 10 2 2 6 2 2 6
49581 - 2 2 6 2 2 6 2 2 6 18 18 18
49582 - 82 82 82 34 34 34 10 10 10 0 0 0
49583 - 0 0 0 0 0 0 0 0 0 0 0 0
49584 - 0 0 0 0 0 0 0 0 0 0 0 0
49585 - 0 0 0 0 0 0 0 0 0 0 0 0
49586 - 0 0 0 0 0 0 0 0 0 0 0 0
49587 - 0 0 0 0 0 0 0 0 0 0 0 0
49588 - 0 0 0 0 0 0 0 0 0 0 0 0
49589 - 0 0 0 0 0 0 0 0 0 0 0 0
49590 - 0 0 1 0 0 0 0 0 0 0 0 0
49591 - 0 0 0 0 0 0 0 0 0 0 0 0
49592 - 0 0 0 0 0 0 0 0 0 0 0 0
49593 - 0 0 0 0 0 0 0 0 0 0 0 0
49594 - 0 0 0 0 0 0 0 0 0 0 0 0
49595 - 0 0 0 0 0 0 0 0 0 14 14 14
49596 - 46 46 46 86 86 86 2 2 6 2 2 6
49597 - 6 6 6 6 6 6 22 22 22 34 34 34
49598 - 6 6 6 2 2 6 2 2 6 2 2 6
49599 - 2 2 6 2 2 6 18 18 18 34 34 34
49600 - 10 10 10 50 50 50 22 22 22 2 2 6
49601 - 2 2 6 2 2 6 2 2 6 10 10 10
49602 - 86 86 86 42 42 42 14 14 14 0 0 0
49603 - 0 0 0 0 0 0 0 0 0 0 0 0
49604 - 0 0 0 0 0 0 0 0 0 0 0 0
49605 - 0 0 0 0 0 0 0 0 0 0 0 0
49606 - 0 0 0 0 0 0 0 0 0 0 0 0
49607 - 0 0 0 0 0 0 0 0 0 0 0 0
49608 - 0 0 0 0 0 0 0 0 0 0 0 0
49609 - 0 0 0 0 0 0 0 0 0 0 0 0
49610 - 0 0 1 0 0 1 0 0 1 0 0 0
49611 - 0 0 0 0 0 0 0 0 0 0 0 0
49612 - 0 0 0 0 0 0 0 0 0 0 0 0
49613 - 0 0 0 0 0 0 0 0 0 0 0 0
49614 - 0 0 0 0 0 0 0 0 0 0 0 0
49615 - 0 0 0 0 0 0 0 0 0 14 14 14
49616 - 46 46 46 86 86 86 2 2 6 2 2 6
49617 - 38 38 38 116 116 116 94 94 94 22 22 22
49618 - 22 22 22 2 2 6 2 2 6 2 2 6
49619 - 14 14 14 86 86 86 138 138 138 162 162 162
49620 -154 154 154 38 38 38 26 26 26 6 6 6
49621 - 2 2 6 2 2 6 2 2 6 2 2 6
49622 - 86 86 86 46 46 46 14 14 14 0 0 0
49623 - 0 0 0 0 0 0 0 0 0 0 0 0
49624 - 0 0 0 0 0 0 0 0 0 0 0 0
49625 - 0 0 0 0 0 0 0 0 0 0 0 0
49626 - 0 0 0 0 0 0 0 0 0 0 0 0
49627 - 0 0 0 0 0 0 0 0 0 0 0 0
49628 - 0 0 0 0 0 0 0 0 0 0 0 0
49629 - 0 0 0 0 0 0 0 0 0 0 0 0
49630 - 0 0 0 0 0 0 0 0 0 0 0 0
49631 - 0 0 0 0 0 0 0 0 0 0 0 0
49632 - 0 0 0 0 0 0 0 0 0 0 0 0
49633 - 0 0 0 0 0 0 0 0 0 0 0 0
49634 - 0 0 0 0 0 0 0 0 0 0 0 0
49635 - 0 0 0 0 0 0 0 0 0 14 14 14
49636 - 46 46 46 86 86 86 2 2 6 14 14 14
49637 -134 134 134 198 198 198 195 195 195 116 116 116
49638 - 10 10 10 2 2 6 2 2 6 6 6 6
49639 -101 98 89 187 187 187 210 210 210 218 218 218
49640 -214 214 214 134 134 134 14 14 14 6 6 6
49641 - 2 2 6 2 2 6 2 2 6 2 2 6
49642 - 86 86 86 50 50 50 18 18 18 6 6 6
49643 - 0 0 0 0 0 0 0 0 0 0 0 0
49644 - 0 0 0 0 0 0 0 0 0 0 0 0
49645 - 0 0 0 0 0 0 0 0 0 0 0 0
49646 - 0 0 0 0 0 0 0 0 0 0 0 0
49647 - 0 0 0 0 0 0 0 0 0 0 0 0
49648 - 0 0 0 0 0 0 0 0 0 0 0 0
49649 - 0 0 0 0 0 0 0 0 1 0 0 0
49650 - 0 0 1 0 0 1 0 0 1 0 0 0
49651 - 0 0 0 0 0 0 0 0 0 0 0 0
49652 - 0 0 0 0 0 0 0 0 0 0 0 0
49653 - 0 0 0 0 0 0 0 0 0 0 0 0
49654 - 0 0 0 0 0 0 0 0 0 0 0 0
49655 - 0 0 0 0 0 0 0 0 0 14 14 14
49656 - 46 46 46 86 86 86 2 2 6 54 54 54
49657 -218 218 218 195 195 195 226 226 226 246 246 246
49658 - 58 58 58 2 2 6 2 2 6 30 30 30
49659 -210 210 210 253 253 253 174 174 174 123 123 123
49660 -221 221 221 234 234 234 74 74 74 2 2 6
49661 - 2 2 6 2 2 6 2 2 6 2 2 6
49662 - 70 70 70 58 58 58 22 22 22 6 6 6
49663 - 0 0 0 0 0 0 0 0 0 0 0 0
49664 - 0 0 0 0 0 0 0 0 0 0 0 0
49665 - 0 0 0 0 0 0 0 0 0 0 0 0
49666 - 0 0 0 0 0 0 0 0 0 0 0 0
49667 - 0 0 0 0 0 0 0 0 0 0 0 0
49668 - 0 0 0 0 0 0 0 0 0 0 0 0
49669 - 0 0 0 0 0 0 0 0 0 0 0 0
49670 - 0 0 0 0 0 0 0 0 0 0 0 0
49671 - 0 0 0 0 0 0 0 0 0 0 0 0
49672 - 0 0 0 0 0 0 0 0 0 0 0 0
49673 - 0 0 0 0 0 0 0 0 0 0 0 0
49674 - 0 0 0 0 0 0 0 0 0 0 0 0
49675 - 0 0 0 0 0 0 0 0 0 14 14 14
49676 - 46 46 46 82 82 82 2 2 6 106 106 106
49677 -170 170 170 26 26 26 86 86 86 226 226 226
49678 -123 123 123 10 10 10 14 14 14 46 46 46
49679 -231 231 231 190 190 190 6 6 6 70 70 70
49680 - 90 90 90 238 238 238 158 158 158 2 2 6
49681 - 2 2 6 2 2 6 2 2 6 2 2 6
49682 - 70 70 70 58 58 58 22 22 22 6 6 6
49683 - 0 0 0 0 0 0 0 0 0 0 0 0
49684 - 0 0 0 0 0 0 0 0 0 0 0 0
49685 - 0 0 0 0 0 0 0 0 0 0 0 0
49686 - 0 0 0 0 0 0 0 0 0 0 0 0
49687 - 0 0 0 0 0 0 0 0 0 0 0 0
49688 - 0 0 0 0 0 0 0 0 0 0 0 0
49689 - 0 0 0 0 0 0 0 0 1 0 0 0
49690 - 0 0 1 0 0 1 0 0 1 0 0 0
49691 - 0 0 0 0 0 0 0 0 0 0 0 0
49692 - 0 0 0 0 0 0 0 0 0 0 0 0
49693 - 0 0 0 0 0 0 0 0 0 0 0 0
49694 - 0 0 0 0 0 0 0 0 0 0 0 0
49695 - 0 0 0 0 0 0 0 0 0 14 14 14
49696 - 42 42 42 86 86 86 6 6 6 116 116 116
49697 -106 106 106 6 6 6 70 70 70 149 149 149
49698 -128 128 128 18 18 18 38 38 38 54 54 54
49699 -221 221 221 106 106 106 2 2 6 14 14 14
49700 - 46 46 46 190 190 190 198 198 198 2 2 6
49701 - 2 2 6 2 2 6 2 2 6 2 2 6
49702 - 74 74 74 62 62 62 22 22 22 6 6 6
49703 - 0 0 0 0 0 0 0 0 0 0 0 0
49704 - 0 0 0 0 0 0 0 0 0 0 0 0
49705 - 0 0 0 0 0 0 0 0 0 0 0 0
49706 - 0 0 0 0 0 0 0 0 0 0 0 0
49707 - 0 0 0 0 0 0 0 0 0 0 0 0
49708 - 0 0 0 0 0 0 0 0 0 0 0 0
49709 - 0 0 0 0 0 0 0 0 1 0 0 0
49710 - 0 0 1 0 0 0 0 0 1 0 0 0
49711 - 0 0 0 0 0 0 0 0 0 0 0 0
49712 - 0 0 0 0 0 0 0 0 0 0 0 0
49713 - 0 0 0 0 0 0 0 0 0 0 0 0
49714 - 0 0 0 0 0 0 0 0 0 0 0 0
49715 - 0 0 0 0 0 0 0 0 0 14 14 14
49716 - 42 42 42 94 94 94 14 14 14 101 101 101
49717 -128 128 128 2 2 6 18 18 18 116 116 116
49718 -118 98 46 121 92 8 121 92 8 98 78 10
49719 -162 162 162 106 106 106 2 2 6 2 2 6
49720 - 2 2 6 195 195 195 195 195 195 6 6 6
49721 - 2 2 6 2 2 6 2 2 6 2 2 6
49722 - 74 74 74 62 62 62 22 22 22 6 6 6
49723 - 0 0 0 0 0 0 0 0 0 0 0 0
49724 - 0 0 0 0 0 0 0 0 0 0 0 0
49725 - 0 0 0 0 0 0 0 0 0 0 0 0
49726 - 0 0 0 0 0 0 0 0 0 0 0 0
49727 - 0 0 0 0 0 0 0 0 0 0 0 0
49728 - 0 0 0 0 0 0 0 0 0 0 0 0
49729 - 0 0 0 0 0 0 0 0 1 0 0 1
49730 - 0 0 1 0 0 0 0 0 1 0 0 0
49731 - 0 0 0 0 0 0 0 0 0 0 0 0
49732 - 0 0 0 0 0 0 0 0 0 0 0 0
49733 - 0 0 0 0 0 0 0 0 0 0 0 0
49734 - 0 0 0 0 0 0 0 0 0 0 0 0
49735 - 0 0 0 0 0 0 0 0 0 10 10 10
49736 - 38 38 38 90 90 90 14 14 14 58 58 58
49737 -210 210 210 26 26 26 54 38 6 154 114 10
49738 -226 170 11 236 186 11 225 175 15 184 144 12
49739 -215 174 15 175 146 61 37 26 9 2 2 6
49740 - 70 70 70 246 246 246 138 138 138 2 2 6
49741 - 2 2 6 2 2 6 2 2 6 2 2 6
49742 - 70 70 70 66 66 66 26 26 26 6 6 6
49743 - 0 0 0 0 0 0 0 0 0 0 0 0
49744 - 0 0 0 0 0 0 0 0 0 0 0 0
49745 - 0 0 0 0 0 0 0 0 0 0 0 0
49746 - 0 0 0 0 0 0 0 0 0 0 0 0
49747 - 0 0 0 0 0 0 0 0 0 0 0 0
49748 - 0 0 0 0 0 0 0 0 0 0 0 0
49749 - 0 0 0 0 0 0 0 0 0 0 0 0
49750 - 0 0 0 0 0 0 0 0 0 0 0 0
49751 - 0 0 0 0 0 0 0 0 0 0 0 0
49752 - 0 0 0 0 0 0 0 0 0 0 0 0
49753 - 0 0 0 0 0 0 0 0 0 0 0 0
49754 - 0 0 0 0 0 0 0 0 0 0 0 0
49755 - 0 0 0 0 0 0 0 0 0 10 10 10
49756 - 38 38 38 86 86 86 14 14 14 10 10 10
49757 -195 195 195 188 164 115 192 133 9 225 175 15
49758 -239 182 13 234 190 10 232 195 16 232 200 30
49759 -245 207 45 241 208 19 232 195 16 184 144 12
49760 -218 194 134 211 206 186 42 42 42 2 2 6
49761 - 2 2 6 2 2 6 2 2 6 2 2 6
49762 - 50 50 50 74 74 74 30 30 30 6 6 6
49763 - 0 0 0 0 0 0 0 0 0 0 0 0
49764 - 0 0 0 0 0 0 0 0 0 0 0 0
49765 - 0 0 0 0 0 0 0 0 0 0 0 0
49766 - 0 0 0 0 0 0 0 0 0 0 0 0
49767 - 0 0 0 0 0 0 0 0 0 0 0 0
49768 - 0 0 0 0 0 0 0 0 0 0 0 0
49769 - 0 0 0 0 0 0 0 0 0 0 0 0
49770 - 0 0 0 0 0 0 0 0 0 0 0 0
49771 - 0 0 0 0 0 0 0 0 0 0 0 0
49772 - 0 0 0 0 0 0 0 0 0 0 0 0
49773 - 0 0 0 0 0 0 0 0 0 0 0 0
49774 - 0 0 0 0 0 0 0 0 0 0 0 0
49775 - 0 0 0 0 0 0 0 0 0 10 10 10
49776 - 34 34 34 86 86 86 14 14 14 2 2 6
49777 -121 87 25 192 133 9 219 162 10 239 182 13
49778 -236 186 11 232 195 16 241 208 19 244 214 54
49779 -246 218 60 246 218 38 246 215 20 241 208 19
49780 -241 208 19 226 184 13 121 87 25 2 2 6
49781 - 2 2 6 2 2 6 2 2 6 2 2 6
49782 - 50 50 50 82 82 82 34 34 34 10 10 10
49783 - 0 0 0 0 0 0 0 0 0 0 0 0
49784 - 0 0 0 0 0 0 0 0 0 0 0 0
49785 - 0 0 0 0 0 0 0 0 0 0 0 0
49786 - 0 0 0 0 0 0 0 0 0 0 0 0
49787 - 0 0 0 0 0 0 0 0 0 0 0 0
49788 - 0 0 0 0 0 0 0 0 0 0 0 0
49789 - 0 0 0 0 0 0 0 0 0 0 0 0
49790 - 0 0 0 0 0 0 0 0 0 0 0 0
49791 - 0 0 0 0 0 0 0 0 0 0 0 0
49792 - 0 0 0 0 0 0 0 0 0 0 0 0
49793 - 0 0 0 0 0 0 0 0 0 0 0 0
49794 - 0 0 0 0 0 0 0 0 0 0 0 0
49795 - 0 0 0 0 0 0 0 0 0 10 10 10
49796 - 34 34 34 82 82 82 30 30 30 61 42 6
49797 -180 123 7 206 145 10 230 174 11 239 182 13
49798 -234 190 10 238 202 15 241 208 19 246 218 74
49799 -246 218 38 246 215 20 246 215 20 246 215 20
49800 -226 184 13 215 174 15 184 144 12 6 6 6
49801 - 2 2 6 2 2 6 2 2 6 2 2 6
49802 - 26 26 26 94 94 94 42 42 42 14 14 14
49803 - 0 0 0 0 0 0 0 0 0 0 0 0
49804 - 0 0 0 0 0 0 0 0 0 0 0 0
49805 - 0 0 0 0 0 0 0 0 0 0 0 0
49806 - 0 0 0 0 0 0 0 0 0 0 0 0
49807 - 0 0 0 0 0 0 0 0 0 0 0 0
49808 - 0 0 0 0 0 0 0 0 0 0 0 0
49809 - 0 0 0 0 0 0 0 0 0 0 0 0
49810 - 0 0 0 0 0 0 0 0 0 0 0 0
49811 - 0 0 0 0 0 0 0 0 0 0 0 0
49812 - 0 0 0 0 0 0 0 0 0 0 0 0
49813 - 0 0 0 0 0 0 0 0 0 0 0 0
49814 - 0 0 0 0 0 0 0 0 0 0 0 0
49815 - 0 0 0 0 0 0 0 0 0 10 10 10
49816 - 30 30 30 78 78 78 50 50 50 104 69 6
49817 -192 133 9 216 158 10 236 178 12 236 186 11
49818 -232 195 16 241 208 19 244 214 54 245 215 43
49819 -246 215 20 246 215 20 241 208 19 198 155 10
49820 -200 144 11 216 158 10 156 118 10 2 2 6
49821 - 2 2 6 2 2 6 2 2 6 2 2 6
49822 - 6 6 6 90 90 90 54 54 54 18 18 18
49823 - 6 6 6 0 0 0 0 0 0 0 0 0
49824 - 0 0 0 0 0 0 0 0 0 0 0 0
49825 - 0 0 0 0 0 0 0 0 0 0 0 0
49826 - 0 0 0 0 0 0 0 0 0 0 0 0
49827 - 0 0 0 0 0 0 0 0 0 0 0 0
49828 - 0 0 0 0 0 0 0 0 0 0 0 0
49829 - 0 0 0 0 0 0 0 0 0 0 0 0
49830 - 0 0 0 0 0 0 0 0 0 0 0 0
49831 - 0 0 0 0 0 0 0 0 0 0 0 0
49832 - 0 0 0 0 0 0 0 0 0 0 0 0
49833 - 0 0 0 0 0 0 0 0 0 0 0 0
49834 - 0 0 0 0 0 0 0 0 0 0 0 0
49835 - 0 0 0 0 0 0 0 0 0 10 10 10
49836 - 30 30 30 78 78 78 46 46 46 22 22 22
49837 -137 92 6 210 162 10 239 182 13 238 190 10
49838 -238 202 15 241 208 19 246 215 20 246 215 20
49839 -241 208 19 203 166 17 185 133 11 210 150 10
49840 -216 158 10 210 150 10 102 78 10 2 2 6
49841 - 6 6 6 54 54 54 14 14 14 2 2 6
49842 - 2 2 6 62 62 62 74 74 74 30 30 30
49843 - 10 10 10 0 0 0 0 0 0 0 0 0
49844 - 0 0 0 0 0 0 0 0 0 0 0 0
49845 - 0 0 0 0 0 0 0 0 0 0 0 0
49846 - 0 0 0 0 0 0 0 0 0 0 0 0
49847 - 0 0 0 0 0 0 0 0 0 0 0 0
49848 - 0 0 0 0 0 0 0 0 0 0 0 0
49849 - 0 0 0 0 0 0 0 0 0 0 0 0
49850 - 0 0 0 0 0 0 0 0 0 0 0 0
49851 - 0 0 0 0 0 0 0 0 0 0 0 0
49852 - 0 0 0 0 0 0 0 0 0 0 0 0
49853 - 0 0 0 0 0 0 0 0 0 0 0 0
49854 - 0 0 0 0 0 0 0 0 0 0 0 0
49855 - 0 0 0 0 0 0 0 0 0 10 10 10
49856 - 34 34 34 78 78 78 50 50 50 6 6 6
49857 - 94 70 30 139 102 15 190 146 13 226 184 13
49858 -232 200 30 232 195 16 215 174 15 190 146 13
49859 -168 122 10 192 133 9 210 150 10 213 154 11
49860 -202 150 34 182 157 106 101 98 89 2 2 6
49861 - 2 2 6 78 78 78 116 116 116 58 58 58
49862 - 2 2 6 22 22 22 90 90 90 46 46 46
49863 - 18 18 18 6 6 6 0 0 0 0 0 0
49864 - 0 0 0 0 0 0 0 0 0 0 0 0
49865 - 0 0 0 0 0 0 0 0 0 0 0 0
49866 - 0 0 0 0 0 0 0 0 0 0 0 0
49867 - 0 0 0 0 0 0 0 0 0 0 0 0
49868 - 0 0 0 0 0 0 0 0 0 0 0 0
49869 - 0 0 0 0 0 0 0 0 0 0 0 0
49870 - 0 0 0 0 0 0 0 0 0 0 0 0
49871 - 0 0 0 0 0 0 0 0 0 0 0 0
49872 - 0 0 0 0 0 0 0 0 0 0 0 0
49873 - 0 0 0 0 0 0 0 0 0 0 0 0
49874 - 0 0 0 0 0 0 0 0 0 0 0 0
49875 - 0 0 0 0 0 0 0 0 0 10 10 10
49876 - 38 38 38 86 86 86 50 50 50 6 6 6
49877 -128 128 128 174 154 114 156 107 11 168 122 10
49878 -198 155 10 184 144 12 197 138 11 200 144 11
49879 -206 145 10 206 145 10 197 138 11 188 164 115
49880 -195 195 195 198 198 198 174 174 174 14 14 14
49881 - 2 2 6 22 22 22 116 116 116 116 116 116
49882 - 22 22 22 2 2 6 74 74 74 70 70 70
49883 - 30 30 30 10 10 10 0 0 0 0 0 0
49884 - 0 0 0 0 0 0 0 0 0 0 0 0
49885 - 0 0 0 0 0 0 0 0 0 0 0 0
49886 - 0 0 0 0 0 0 0 0 0 0 0 0
49887 - 0 0 0 0 0 0 0 0 0 0 0 0
49888 - 0 0 0 0 0 0 0 0 0 0 0 0
49889 - 0 0 0 0 0 0 0 0 0 0 0 0
49890 - 0 0 0 0 0 0 0 0 0 0 0 0
49891 - 0 0 0 0 0 0 0 0 0 0 0 0
49892 - 0 0 0 0 0 0 0 0 0 0 0 0
49893 - 0 0 0 0 0 0 0 0 0 0 0 0
49894 - 0 0 0 0 0 0 0 0 0 0 0 0
49895 - 0 0 0 0 0 0 6 6 6 18 18 18
49896 - 50 50 50 101 101 101 26 26 26 10 10 10
49897 -138 138 138 190 190 190 174 154 114 156 107 11
49898 -197 138 11 200 144 11 197 138 11 192 133 9
49899 -180 123 7 190 142 34 190 178 144 187 187 187
49900 -202 202 202 221 221 221 214 214 214 66 66 66
49901 - 2 2 6 2 2 6 50 50 50 62 62 62
49902 - 6 6 6 2 2 6 10 10 10 90 90 90
49903 - 50 50 50 18 18 18 6 6 6 0 0 0
49904 - 0 0 0 0 0 0 0 0 0 0 0 0
49905 - 0 0 0 0 0 0 0 0 0 0 0 0
49906 - 0 0 0 0 0 0 0 0 0 0 0 0
49907 - 0 0 0 0 0 0 0 0 0 0 0 0
49908 - 0 0 0 0 0 0 0 0 0 0 0 0
49909 - 0 0 0 0 0 0 0 0 0 0 0 0
49910 - 0 0 0 0 0 0 0 0 0 0 0 0
49911 - 0 0 0 0 0 0 0 0 0 0 0 0
49912 - 0 0 0 0 0 0 0 0 0 0 0 0
49913 - 0 0 0 0 0 0 0 0 0 0 0 0
49914 - 0 0 0 0 0 0 0 0 0 0 0 0
49915 - 0 0 0 0 0 0 10 10 10 34 34 34
49916 - 74 74 74 74 74 74 2 2 6 6 6 6
49917 -144 144 144 198 198 198 190 190 190 178 166 146
49918 -154 121 60 156 107 11 156 107 11 168 124 44
49919 -174 154 114 187 187 187 190 190 190 210 210 210
49920 -246 246 246 253 253 253 253 253 253 182 182 182
49921 - 6 6 6 2 2 6 2 2 6 2 2 6
49922 - 2 2 6 2 2 6 2 2 6 62 62 62
49923 - 74 74 74 34 34 34 14 14 14 0 0 0
49924 - 0 0 0 0 0 0 0 0 0 0 0 0
49925 - 0 0 0 0 0 0 0 0 0 0 0 0
49926 - 0 0 0 0 0 0 0 0 0 0 0 0
49927 - 0 0 0 0 0 0 0 0 0 0 0 0
49928 - 0 0 0 0 0 0 0 0 0 0 0 0
49929 - 0 0 0 0 0 0 0 0 0 0 0 0
49930 - 0 0 0 0 0 0 0 0 0 0 0 0
49931 - 0 0 0 0 0 0 0 0 0 0 0 0
49932 - 0 0 0 0 0 0 0 0 0 0 0 0
49933 - 0 0 0 0 0 0 0 0 0 0 0 0
49934 - 0 0 0 0 0 0 0 0 0 0 0 0
49935 - 0 0 0 10 10 10 22 22 22 54 54 54
49936 - 94 94 94 18 18 18 2 2 6 46 46 46
49937 -234 234 234 221 221 221 190 190 190 190 190 190
49938 -190 190 190 187 187 187 187 187 187 190 190 190
49939 -190 190 190 195 195 195 214 214 214 242 242 242
49940 -253 253 253 253 253 253 253 253 253 253 253 253
49941 - 82 82 82 2 2 6 2 2 6 2 2 6
49942 - 2 2 6 2 2 6 2 2 6 14 14 14
49943 - 86 86 86 54 54 54 22 22 22 6 6 6
49944 - 0 0 0 0 0 0 0 0 0 0 0 0
49945 - 0 0 0 0 0 0 0 0 0 0 0 0
49946 - 0 0 0 0 0 0 0 0 0 0 0 0
49947 - 0 0 0 0 0 0 0 0 0 0 0 0
49948 - 0 0 0 0 0 0 0 0 0 0 0 0
49949 - 0 0 0 0 0 0 0 0 0 0 0 0
49950 - 0 0 0 0 0 0 0 0 0 0 0 0
49951 - 0 0 0 0 0 0 0 0 0 0 0 0
49952 - 0 0 0 0 0 0 0 0 0 0 0 0
49953 - 0 0 0 0 0 0 0 0 0 0 0 0
49954 - 0 0 0 0 0 0 0 0 0 0 0 0
49955 - 6 6 6 18 18 18 46 46 46 90 90 90
49956 - 46 46 46 18 18 18 6 6 6 182 182 182
49957 -253 253 253 246 246 246 206 206 206 190 190 190
49958 -190 190 190 190 190 190 190 190 190 190 190 190
49959 -206 206 206 231 231 231 250 250 250 253 253 253
49960 -253 253 253 253 253 253 253 253 253 253 253 253
49961 -202 202 202 14 14 14 2 2 6 2 2 6
49962 - 2 2 6 2 2 6 2 2 6 2 2 6
49963 - 42 42 42 86 86 86 42 42 42 18 18 18
49964 - 6 6 6 0 0 0 0 0 0 0 0 0
49965 - 0 0 0 0 0 0 0 0 0 0 0 0
49966 - 0 0 0 0 0 0 0 0 0 0 0 0
49967 - 0 0 0 0 0 0 0 0 0 0 0 0
49968 - 0 0 0 0 0 0 0 0 0 0 0 0
49969 - 0 0 0 0 0 0 0 0 0 0 0 0
49970 - 0 0 0 0 0 0 0 0 0 0 0 0
49971 - 0 0 0 0 0 0 0 0 0 0 0 0
49972 - 0 0 0 0 0 0 0 0 0 0 0 0
49973 - 0 0 0 0 0 0 0 0 0 0 0 0
49974 - 0 0 0 0 0 0 0 0 0 6 6 6
49975 - 14 14 14 38 38 38 74 74 74 66 66 66
49976 - 2 2 6 6 6 6 90 90 90 250 250 250
49977 -253 253 253 253 253 253 238 238 238 198 198 198
49978 -190 190 190 190 190 190 195 195 195 221 221 221
49979 -246 246 246 253 253 253 253 253 253 253 253 253
49980 -253 253 253 253 253 253 253 253 253 253 253 253
49981 -253 253 253 82 82 82 2 2 6 2 2 6
49982 - 2 2 6 2 2 6 2 2 6 2 2 6
49983 - 2 2 6 78 78 78 70 70 70 34 34 34
49984 - 14 14 14 6 6 6 0 0 0 0 0 0
49985 - 0 0 0 0 0 0 0 0 0 0 0 0
49986 - 0 0 0 0 0 0 0 0 0 0 0 0
49987 - 0 0 0 0 0 0 0 0 0 0 0 0
49988 - 0 0 0 0 0 0 0 0 0 0 0 0
49989 - 0 0 0 0 0 0 0 0 0 0 0 0
49990 - 0 0 0 0 0 0 0 0 0 0 0 0
49991 - 0 0 0 0 0 0 0 0 0 0 0 0
49992 - 0 0 0 0 0 0 0 0 0 0 0 0
49993 - 0 0 0 0 0 0 0 0 0 0 0 0
49994 - 0 0 0 0 0 0 0 0 0 14 14 14
49995 - 34 34 34 66 66 66 78 78 78 6 6 6
49996 - 2 2 6 18 18 18 218 218 218 253 253 253
49997 -253 253 253 253 253 253 253 253 253 246 246 246
49998 -226 226 226 231 231 231 246 246 246 253 253 253
49999 -253 253 253 253 253 253 253 253 253 253 253 253
50000 -253 253 253 253 253 253 253 253 253 253 253 253
50001 -253 253 253 178 178 178 2 2 6 2 2 6
50002 - 2 2 6 2 2 6 2 2 6 2 2 6
50003 - 2 2 6 18 18 18 90 90 90 62 62 62
50004 - 30 30 30 10 10 10 0 0 0 0 0 0
50005 - 0 0 0 0 0 0 0 0 0 0 0 0
50006 - 0 0 0 0 0 0 0 0 0 0 0 0
50007 - 0 0 0 0 0 0 0 0 0 0 0 0
50008 - 0 0 0 0 0 0 0 0 0 0 0 0
50009 - 0 0 0 0 0 0 0 0 0 0 0 0
50010 - 0 0 0 0 0 0 0 0 0 0 0 0
50011 - 0 0 0 0 0 0 0 0 0 0 0 0
50012 - 0 0 0 0 0 0 0 0 0 0 0 0
50013 - 0 0 0 0 0 0 0 0 0 0 0 0
50014 - 0 0 0 0 0 0 10 10 10 26 26 26
50015 - 58 58 58 90 90 90 18 18 18 2 2 6
50016 - 2 2 6 110 110 110 253 253 253 253 253 253
50017 -253 253 253 253 253 253 253 253 253 253 253 253
50018 -250 250 250 253 253 253 253 253 253 253 253 253
50019 -253 253 253 253 253 253 253 253 253 253 253 253
50020 -253 253 253 253 253 253 253 253 253 253 253 253
50021 -253 253 253 231 231 231 18 18 18 2 2 6
50022 - 2 2 6 2 2 6 2 2 6 2 2 6
50023 - 2 2 6 2 2 6 18 18 18 94 94 94
50024 - 54 54 54 26 26 26 10 10 10 0 0 0
50025 - 0 0 0 0 0 0 0 0 0 0 0 0
50026 - 0 0 0 0 0 0 0 0 0 0 0 0
50027 - 0 0 0 0 0 0 0 0 0 0 0 0
50028 - 0 0 0 0 0 0 0 0 0 0 0 0
50029 - 0 0 0 0 0 0 0 0 0 0 0 0
50030 - 0 0 0 0 0 0 0 0 0 0 0 0
50031 - 0 0 0 0 0 0 0 0 0 0 0 0
50032 - 0 0 0 0 0 0 0 0 0 0 0 0
50033 - 0 0 0 0 0 0 0 0 0 0 0 0
50034 - 0 0 0 6 6 6 22 22 22 50 50 50
50035 - 90 90 90 26 26 26 2 2 6 2 2 6
50036 - 14 14 14 195 195 195 250 250 250 253 253 253
50037 -253 253 253 253 253 253 253 253 253 253 253 253
50038 -253 253 253 253 253 253 253 253 253 253 253 253
50039 -253 253 253 253 253 253 253 253 253 253 253 253
50040 -253 253 253 253 253 253 253 253 253 253 253 253
50041 -250 250 250 242 242 242 54 54 54 2 2 6
50042 - 2 2 6 2 2 6 2 2 6 2 2 6
50043 - 2 2 6 2 2 6 2 2 6 38 38 38
50044 - 86 86 86 50 50 50 22 22 22 6 6 6
50045 - 0 0 0 0 0 0 0 0 0 0 0 0
50046 - 0 0 0 0 0 0 0 0 0 0 0 0
50047 - 0 0 0 0 0 0 0 0 0 0 0 0
50048 - 0 0 0 0 0 0 0 0 0 0 0 0
50049 - 0 0 0 0 0 0 0 0 0 0 0 0
50050 - 0 0 0 0 0 0 0 0 0 0 0 0
50051 - 0 0 0 0 0 0 0 0 0 0 0 0
50052 - 0 0 0 0 0 0 0 0 0 0 0 0
50053 - 0 0 0 0 0 0 0 0 0 0 0 0
50054 - 6 6 6 14 14 14 38 38 38 82 82 82
50055 - 34 34 34 2 2 6 2 2 6 2 2 6
50056 - 42 42 42 195 195 195 246 246 246 253 253 253
50057 -253 253 253 253 253 253 253 253 253 250 250 250
50058 -242 242 242 242 242 242 250 250 250 253 253 253
50059 -253 253 253 253 253 253 253 253 253 253 253 253
50060 -253 253 253 250 250 250 246 246 246 238 238 238
50061 -226 226 226 231 231 231 101 101 101 6 6 6
50062 - 2 2 6 2 2 6 2 2 6 2 2 6
50063 - 2 2 6 2 2 6 2 2 6 2 2 6
50064 - 38 38 38 82 82 82 42 42 42 14 14 14
50065 - 6 6 6 0 0 0 0 0 0 0 0 0
50066 - 0 0 0 0 0 0 0 0 0 0 0 0
50067 - 0 0 0 0 0 0 0 0 0 0 0 0
50068 - 0 0 0 0 0 0 0 0 0 0 0 0
50069 - 0 0 0 0 0 0 0 0 0 0 0 0
50070 - 0 0 0 0 0 0 0 0 0 0 0 0
50071 - 0 0 0 0 0 0 0 0 0 0 0 0
50072 - 0 0 0 0 0 0 0 0 0 0 0 0
50073 - 0 0 0 0 0 0 0 0 0 0 0 0
50074 - 10 10 10 26 26 26 62 62 62 66 66 66
50075 - 2 2 6 2 2 6 2 2 6 6 6 6
50076 - 70 70 70 170 170 170 206 206 206 234 234 234
50077 -246 246 246 250 250 250 250 250 250 238 238 238
50078 -226 226 226 231 231 231 238 238 238 250 250 250
50079 -250 250 250 250 250 250 246 246 246 231 231 231
50080 -214 214 214 206 206 206 202 202 202 202 202 202
50081 -198 198 198 202 202 202 182 182 182 18 18 18
50082 - 2 2 6 2 2 6 2 2 6 2 2 6
50083 - 2 2 6 2 2 6 2 2 6 2 2 6
50084 - 2 2 6 62 62 62 66 66 66 30 30 30
50085 - 10 10 10 0 0 0 0 0 0 0 0 0
50086 - 0 0 0 0 0 0 0 0 0 0 0 0
50087 - 0 0 0 0 0 0 0 0 0 0 0 0
50088 - 0 0 0 0 0 0 0 0 0 0 0 0
50089 - 0 0 0 0 0 0 0 0 0 0 0 0
50090 - 0 0 0 0 0 0 0 0 0 0 0 0
50091 - 0 0 0 0 0 0 0 0 0 0 0 0
50092 - 0 0 0 0 0 0 0 0 0 0 0 0
50093 - 0 0 0 0 0 0 0 0 0 0 0 0
50094 - 14 14 14 42 42 42 82 82 82 18 18 18
50095 - 2 2 6 2 2 6 2 2 6 10 10 10
50096 - 94 94 94 182 182 182 218 218 218 242 242 242
50097 -250 250 250 253 253 253 253 253 253 250 250 250
50098 -234 234 234 253 253 253 253 253 253 253 253 253
50099 -253 253 253 253 253 253 253 253 253 246 246 246
50100 -238 238 238 226 226 226 210 210 210 202 202 202
50101 -195 195 195 195 195 195 210 210 210 158 158 158
50102 - 6 6 6 14 14 14 50 50 50 14 14 14
50103 - 2 2 6 2 2 6 2 2 6 2 2 6
50104 - 2 2 6 6 6 6 86 86 86 46 46 46
50105 - 18 18 18 6 6 6 0 0 0 0 0 0
50106 - 0 0 0 0 0 0 0 0 0 0 0 0
50107 - 0 0 0 0 0 0 0 0 0 0 0 0
50108 - 0 0 0 0 0 0 0 0 0 0 0 0
50109 - 0 0 0 0 0 0 0 0 0 0 0 0
50110 - 0 0 0 0 0 0 0 0 0 0 0 0
50111 - 0 0 0 0 0 0 0 0 0 0 0 0
50112 - 0 0 0 0 0 0 0 0 0 0 0 0
50113 - 0 0 0 0 0 0 0 0 0 6 6 6
50114 - 22 22 22 54 54 54 70 70 70 2 2 6
50115 - 2 2 6 10 10 10 2 2 6 22 22 22
50116 -166 166 166 231 231 231 250 250 250 253 253 253
50117 -253 253 253 253 253 253 253 253 253 250 250 250
50118 -242 242 242 253 253 253 253 253 253 253 253 253
50119 -253 253 253 253 253 253 253 253 253 253 253 253
50120 -253 253 253 253 253 253 253 253 253 246 246 246
50121 -231 231 231 206 206 206 198 198 198 226 226 226
50122 - 94 94 94 2 2 6 6 6 6 38 38 38
50123 - 30 30 30 2 2 6 2 2 6 2 2 6
50124 - 2 2 6 2 2 6 62 62 62 66 66 66
50125 - 26 26 26 10 10 10 0 0 0 0 0 0
50126 - 0 0 0 0 0 0 0 0 0 0 0 0
50127 - 0 0 0 0 0 0 0 0 0 0 0 0
50128 - 0 0 0 0 0 0 0 0 0 0 0 0
50129 - 0 0 0 0 0 0 0 0 0 0 0 0
50130 - 0 0 0 0 0 0 0 0 0 0 0 0
50131 - 0 0 0 0 0 0 0 0 0 0 0 0
50132 - 0 0 0 0 0 0 0 0 0 0 0 0
50133 - 0 0 0 0 0 0 0 0 0 10 10 10
50134 - 30 30 30 74 74 74 50 50 50 2 2 6
50135 - 26 26 26 26 26 26 2 2 6 106 106 106
50136 -238 238 238 253 253 253 253 253 253 253 253 253
50137 -253 253 253 253 253 253 253 253 253 253 253 253
50138 -253 253 253 253 253 253 253 253 253 253 253 253
50139 -253 253 253 253 253 253 253 253 253 253 253 253
50140 -253 253 253 253 253 253 253 253 253 253 253 253
50141 -253 253 253 246 246 246 218 218 218 202 202 202
50142 -210 210 210 14 14 14 2 2 6 2 2 6
50143 - 30 30 30 22 22 22 2 2 6 2 2 6
50144 - 2 2 6 2 2 6 18 18 18 86 86 86
50145 - 42 42 42 14 14 14 0 0 0 0 0 0
50146 - 0 0 0 0 0 0 0 0 0 0 0 0
50147 - 0 0 0 0 0 0 0 0 0 0 0 0
50148 - 0 0 0 0 0 0 0 0 0 0 0 0
50149 - 0 0 0 0 0 0 0 0 0 0 0 0
50150 - 0 0 0 0 0 0 0 0 0 0 0 0
50151 - 0 0 0 0 0 0 0 0 0 0 0 0
50152 - 0 0 0 0 0 0 0 0 0 0 0 0
50153 - 0 0 0 0 0 0 0 0 0 14 14 14
50154 - 42 42 42 90 90 90 22 22 22 2 2 6
50155 - 42 42 42 2 2 6 18 18 18 218 218 218
50156 -253 253 253 253 253 253 253 253 253 253 253 253
50157 -253 253 253 253 253 253 253 253 253 253 253 253
50158 -253 253 253 253 253 253 253 253 253 253 253 253
50159 -253 253 253 253 253 253 253 253 253 253 253 253
50160 -253 253 253 253 253 253 253 253 253 253 253 253
50161 -253 253 253 253 253 253 250 250 250 221 221 221
50162 -218 218 218 101 101 101 2 2 6 14 14 14
50163 - 18 18 18 38 38 38 10 10 10 2 2 6
50164 - 2 2 6 2 2 6 2 2 6 78 78 78
50165 - 58 58 58 22 22 22 6 6 6 0 0 0
50166 - 0 0 0 0 0 0 0 0 0 0 0 0
50167 - 0 0 0 0 0 0 0 0 0 0 0 0
50168 - 0 0 0 0 0 0 0 0 0 0 0 0
50169 - 0 0 0 0 0 0 0 0 0 0 0 0
50170 - 0 0 0 0 0 0 0 0 0 0 0 0
50171 - 0 0 0 0 0 0 0 0 0 0 0 0
50172 - 0 0 0 0 0 0 0 0 0 0 0 0
50173 - 0 0 0 0 0 0 6 6 6 18 18 18
50174 - 54 54 54 82 82 82 2 2 6 26 26 26
50175 - 22 22 22 2 2 6 123 123 123 253 253 253
50176 -253 253 253 253 253 253 253 253 253 253 253 253
50177 -253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 253 253 253 253 253 253
50179 -253 253 253 253 253 253 253 253 253 253 253 253
50180 -253 253 253 253 253 253 253 253 253 253 253 253
50181 -253 253 253 253 253 253 253 253 253 250 250 250
50182 -238 238 238 198 198 198 6 6 6 38 38 38
50183 - 58 58 58 26 26 26 38 38 38 2 2 6
50184 - 2 2 6 2 2 6 2 2 6 46 46 46
50185 - 78 78 78 30 30 30 10 10 10 0 0 0
50186 - 0 0 0 0 0 0 0 0 0 0 0 0
50187 - 0 0 0 0 0 0 0 0 0 0 0 0
50188 - 0 0 0 0 0 0 0 0 0 0 0 0
50189 - 0 0 0 0 0 0 0 0 0 0 0 0
50190 - 0 0 0 0 0 0 0 0 0 0 0 0
50191 - 0 0 0 0 0 0 0 0 0 0 0 0
50192 - 0 0 0 0 0 0 0 0 0 0 0 0
50193 - 0 0 0 0 0 0 10 10 10 30 30 30
50194 - 74 74 74 58 58 58 2 2 6 42 42 42
50195 - 2 2 6 22 22 22 231 231 231 253 253 253
50196 -253 253 253 253 253 253 253 253 253 253 253 253
50197 -253 253 253 253 253 253 253 253 253 250 250 250
50198 -253 253 253 253 253 253 253 253 253 253 253 253
50199 -253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 253 253 253 253 253 253
50201 -253 253 253 253 253 253 253 253 253 253 253 253
50202 -253 253 253 246 246 246 46 46 46 38 38 38
50203 - 42 42 42 14 14 14 38 38 38 14 14 14
50204 - 2 2 6 2 2 6 2 2 6 6 6 6
50205 - 86 86 86 46 46 46 14 14 14 0 0 0
50206 - 0 0 0 0 0 0 0 0 0 0 0 0
50207 - 0 0 0 0 0 0 0 0 0 0 0 0
50208 - 0 0 0 0 0 0 0 0 0 0 0 0
50209 - 0 0 0 0 0 0 0 0 0 0 0 0
50210 - 0 0 0 0 0 0 0 0 0 0 0 0
50211 - 0 0 0 0 0 0 0 0 0 0 0 0
50212 - 0 0 0 0 0 0 0 0 0 0 0 0
50213 - 0 0 0 6 6 6 14 14 14 42 42 42
50214 - 90 90 90 18 18 18 18 18 18 26 26 26
50215 - 2 2 6 116 116 116 253 253 253 253 253 253
50216 -253 253 253 253 253 253 253 253 253 253 253 253
50217 -253 253 253 253 253 253 250 250 250 238 238 238
50218 -253 253 253 253 253 253 253 253 253 253 253 253
50219 -253 253 253 253 253 253 253 253 253 253 253 253
50220 -253 253 253 253 253 253 253 253 253 253 253 253
50221 -253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 253 253 253 94 94 94 6 6 6
50223 - 2 2 6 2 2 6 10 10 10 34 34 34
50224 - 2 2 6 2 2 6 2 2 6 2 2 6
50225 - 74 74 74 58 58 58 22 22 22 6 6 6
50226 - 0 0 0 0 0 0 0 0 0 0 0 0
50227 - 0 0 0 0 0 0 0 0 0 0 0 0
50228 - 0 0 0 0 0 0 0 0 0 0 0 0
50229 - 0 0 0 0 0 0 0 0 0 0 0 0
50230 - 0 0 0 0 0 0 0 0 0 0 0 0
50231 - 0 0 0 0 0 0 0 0 0 0 0 0
50232 - 0 0 0 0 0 0 0 0 0 0 0 0
50233 - 0 0 0 10 10 10 26 26 26 66 66 66
50234 - 82 82 82 2 2 6 38 38 38 6 6 6
50235 - 14 14 14 210 210 210 253 253 253 253 253 253
50236 -253 253 253 253 253 253 253 253 253 253 253 253
50237 -253 253 253 253 253 253 246 246 246 242 242 242
50238 -253 253 253 253 253 253 253 253 253 253 253 253
50239 -253 253 253 253 253 253 253 253 253 253 253 253
50240 -253 253 253 253 253 253 253 253 253 253 253 253
50241 -253 253 253 253 253 253 253 253 253 253 253 253
50242 -253 253 253 253 253 253 144 144 144 2 2 6
50243 - 2 2 6 2 2 6 2 2 6 46 46 46
50244 - 2 2 6 2 2 6 2 2 6 2 2 6
50245 - 42 42 42 74 74 74 30 30 30 10 10 10
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 0 0 0 0 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 6 6 6 14 14 14 42 42 42 90 90 90
50254 - 26 26 26 6 6 6 42 42 42 2 2 6
50255 - 74 74 74 250 250 250 253 253 253 253 253 253
50256 -253 253 253 253 253 253 253 253 253 253 253 253
50257 -253 253 253 253 253 253 242 242 242 242 242 242
50258 -253 253 253 253 253 253 253 253 253 253 253 253
50259 -253 253 253 253 253 253 253 253 253 253 253 253
50260 -253 253 253 253 253 253 253 253 253 253 253 253
50261 -253 253 253 253 253 253 253 253 253 253 253 253
50262 -253 253 253 253 253 253 182 182 182 2 2 6
50263 - 2 2 6 2 2 6 2 2 6 46 46 46
50264 - 2 2 6 2 2 6 2 2 6 2 2 6
50265 - 10 10 10 86 86 86 38 38 38 10 10 10
50266 - 0 0 0 0 0 0 0 0 0 0 0 0
50267 - 0 0 0 0 0 0 0 0 0 0 0 0
50268 - 0 0 0 0 0 0 0 0 0 0 0 0
50269 - 0 0 0 0 0 0 0 0 0 0 0 0
50270 - 0 0 0 0 0 0 0 0 0 0 0 0
50271 - 0 0 0 0 0 0 0 0 0 0 0 0
50272 - 0 0 0 0 0 0 0 0 0 0 0 0
50273 - 10 10 10 26 26 26 66 66 66 82 82 82
50274 - 2 2 6 22 22 22 18 18 18 2 2 6
50275 -149 149 149 253 253 253 253 253 253 253 253 253
50276 -253 253 253 253 253 253 253 253 253 253 253 253
50277 -253 253 253 253 253 253 234 234 234 242 242 242
50278 -253 253 253 253 253 253 253 253 253 253 253 253
50279 -253 253 253 253 253 253 253 253 253 253 253 253
50280 -253 253 253 253 253 253 253 253 253 253 253 253
50281 -253 253 253 253 253 253 253 253 253 253 253 253
50282 -253 253 253 253 253 253 206 206 206 2 2 6
50283 - 2 2 6 2 2 6 2 2 6 38 38 38
50284 - 2 2 6 2 2 6 2 2 6 2 2 6
50285 - 6 6 6 86 86 86 46 46 46 14 14 14
50286 - 0 0 0 0 0 0 0 0 0 0 0 0
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 0 0 0
50289 - 0 0 0 0 0 0 0 0 0 0 0 0
50290 - 0 0 0 0 0 0 0 0 0 0 0 0
50291 - 0 0 0 0 0 0 0 0 0 0 0 0
50292 - 0 0 0 0 0 0 0 0 0 6 6 6
50293 - 18 18 18 46 46 46 86 86 86 18 18 18
50294 - 2 2 6 34 34 34 10 10 10 6 6 6
50295 -210 210 210 253 253 253 253 253 253 253 253 253
50296 -253 253 253 253 253 253 253 253 253 253 253 253
50297 -253 253 253 253 253 253 234 234 234 242 242 242
50298 -253 253 253 253 253 253 253 253 253 253 253 253
50299 -253 253 253 253 253 253 253 253 253 253 253 253
50300 -253 253 253 253 253 253 253 253 253 253 253 253
50301 -253 253 253 253 253 253 253 253 253 253 253 253
50302 -253 253 253 253 253 253 221 221 221 6 6 6
50303 - 2 2 6 2 2 6 6 6 6 30 30 30
50304 - 2 2 6 2 2 6 2 2 6 2 2 6
50305 - 2 2 6 82 82 82 54 54 54 18 18 18
50306 - 6 6 6 0 0 0 0 0 0 0 0 0
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 0 0 0
50309 - 0 0 0 0 0 0 0 0 0 0 0 0
50310 - 0 0 0 0 0 0 0 0 0 0 0 0
50311 - 0 0 0 0 0 0 0 0 0 0 0 0
50312 - 0 0 0 0 0 0 0 0 0 10 10 10
50313 - 26 26 26 66 66 66 62 62 62 2 2 6
50314 - 2 2 6 38 38 38 10 10 10 26 26 26
50315 -238 238 238 253 253 253 253 253 253 253 253 253
50316 -253 253 253 253 253 253 253 253 253 253 253 253
50317 -253 253 253 253 253 253 231 231 231 238 238 238
50318 -253 253 253 253 253 253 253 253 253 253 253 253
50319 -253 253 253 253 253 253 253 253 253 253 253 253
50320 -253 253 253 253 253 253 253 253 253 253 253 253
50321 -253 253 253 253 253 253 253 253 253 253 253 253
50322 -253 253 253 253 253 253 231 231 231 6 6 6
50323 - 2 2 6 2 2 6 10 10 10 30 30 30
50324 - 2 2 6 2 2 6 2 2 6 2 2 6
50325 - 2 2 6 66 66 66 58 58 58 22 22 22
50326 - 6 6 6 0 0 0 0 0 0 0 0 0
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 0 0 0
50329 - 0 0 0 0 0 0 0 0 0 0 0 0
50330 - 0 0 0 0 0 0 0 0 0 0 0 0
50331 - 0 0 0 0 0 0 0 0 0 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 10 10 10
50333 - 38 38 38 78 78 78 6 6 6 2 2 6
50334 - 2 2 6 46 46 46 14 14 14 42 42 42
50335 -246 246 246 253 253 253 253 253 253 253 253 253
50336 -253 253 253 253 253 253 253 253 253 253 253 253
50337 -253 253 253 253 253 253 231 231 231 242 242 242
50338 -253 253 253 253 253 253 253 253 253 253 253 253
50339 -253 253 253 253 253 253 253 253 253 253 253 253
50340 -253 253 253 253 253 253 253 253 253 253 253 253
50341 -253 253 253 253 253 253 253 253 253 253 253 253
50342 -253 253 253 253 253 253 234 234 234 10 10 10
50343 - 2 2 6 2 2 6 22 22 22 14 14 14
50344 - 2 2 6 2 2 6 2 2 6 2 2 6
50345 - 2 2 6 66 66 66 62 62 62 22 22 22
50346 - 6 6 6 0 0 0 0 0 0 0 0 0
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 0 0 0 0 0 0
50349 - 0 0 0 0 0 0 0 0 0 0 0 0
50350 - 0 0 0 0 0 0 0 0 0 0 0 0
50351 - 0 0 0 0 0 0 0 0 0 0 0 0
50352 - 0 0 0 0 0 0 6 6 6 18 18 18
50353 - 50 50 50 74 74 74 2 2 6 2 2 6
50354 - 14 14 14 70 70 70 34 34 34 62 62 62
50355 -250 250 250 253 253 253 253 253 253 253 253 253
50356 -253 253 253 253 253 253 253 253 253 253 253 253
50357 -253 253 253 253 253 253 231 231 231 246 246 246
50358 -253 253 253 253 253 253 253 253 253 253 253 253
50359 -253 253 253 253 253 253 253 253 253 253 253 253
50360 -253 253 253 253 253 253 253 253 253 253 253 253
50361 -253 253 253 253 253 253 253 253 253 253 253 253
50362 -253 253 253 253 253 253 234 234 234 14 14 14
50363 - 2 2 6 2 2 6 30 30 30 2 2 6
50364 - 2 2 6 2 2 6 2 2 6 2 2 6
50365 - 2 2 6 66 66 66 62 62 62 22 22 22
50366 - 6 6 6 0 0 0 0 0 0 0 0 0
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 0 0 0 0 0 0
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 0 0 0 0
50371 - 0 0 0 0 0 0 0 0 0 0 0 0
50372 - 0 0 0 0 0 0 6 6 6 18 18 18
50373 - 54 54 54 62 62 62 2 2 6 2 2 6
50374 - 2 2 6 30 30 30 46 46 46 70 70 70
50375 -250 250 250 253 253 253 253 253 253 253 253 253
50376 -253 253 253 253 253 253 253 253 253 253 253 253
50377 -253 253 253 253 253 253 231 231 231 246 246 246
50378 -253 253 253 253 253 253 253 253 253 253 253 253
50379 -253 253 253 253 253 253 253 253 253 253 253 253
50380 -253 253 253 253 253 253 253 253 253 253 253 253
50381 -253 253 253 253 253 253 253 253 253 253 253 253
50382 -253 253 253 253 253 253 226 226 226 10 10 10
50383 - 2 2 6 6 6 6 30 30 30 2 2 6
50384 - 2 2 6 2 2 6 2 2 6 2 2 6
50385 - 2 2 6 66 66 66 58 58 58 22 22 22
50386 - 6 6 6 0 0 0 0 0 0 0 0 0
50387 - 0 0 0 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 0 0 0 0 0 0 0 0 0
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 0 0 0 0 6 6 6 22 22 22
50393 - 58 58 58 62 62 62 2 2 6 2 2 6
50394 - 2 2 6 2 2 6 30 30 30 78 78 78
50395 -250 250 250 253 253 253 253 253 253 253 253 253
50396 -253 253 253 253 253 253 253 253 253 253 253 253
50397 -253 253 253 253 253 253 231 231 231 246 246 246
50398 -253 253 253 253 253 253 253 253 253 253 253 253
50399 -253 253 253 253 253 253 253 253 253 253 253 253
50400 -253 253 253 253 253 253 253 253 253 253 253 253
50401 -253 253 253 253 253 253 253 253 253 253 253 253
50402 -253 253 253 253 253 253 206 206 206 2 2 6
50403 - 22 22 22 34 34 34 18 14 6 22 22 22
50404 - 26 26 26 18 18 18 6 6 6 2 2 6
50405 - 2 2 6 82 82 82 54 54 54 18 18 18
50406 - 6 6 6 0 0 0 0 0 0 0 0 0
50407 - 0 0 0 0 0 0 0 0 0 0 0 0
50408 - 0 0 0 0 0 0 0 0 0 0 0 0
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 0 0 0 0
50411 - 0 0 0 0 0 0 0 0 0 0 0 0
50412 - 0 0 0 0 0 0 6 6 6 26 26 26
50413 - 62 62 62 106 106 106 74 54 14 185 133 11
50414 -210 162 10 121 92 8 6 6 6 62 62 62
50415 -238 238 238 253 253 253 253 253 253 253 253 253
50416 -253 253 253 253 253 253 253 253 253 253 253 253
50417 -253 253 253 253 253 253 231 231 231 246 246 246
50418 -253 253 253 253 253 253 253 253 253 253 253 253
50419 -253 253 253 253 253 253 253 253 253 253 253 253
50420 -253 253 253 253 253 253 253 253 253 253 253 253
50421 -253 253 253 253 253 253 253 253 253 253 253 253
50422 -253 253 253 253 253 253 158 158 158 18 18 18
50423 - 14 14 14 2 2 6 2 2 6 2 2 6
50424 - 6 6 6 18 18 18 66 66 66 38 38 38
50425 - 6 6 6 94 94 94 50 50 50 18 18 18
50426 - 6 6 6 0 0 0 0 0 0 0 0 0
50427 - 0 0 0 0 0 0 0 0 0 0 0 0
50428 - 0 0 0 0 0 0 0 0 0 0 0 0
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 0 0 0 0
50431 - 0 0 0 0 0 0 0 0 0 6 6 6
50432 - 10 10 10 10 10 10 18 18 18 38 38 38
50433 - 78 78 78 142 134 106 216 158 10 242 186 14
50434 -246 190 14 246 190 14 156 118 10 10 10 10
50435 - 90 90 90 238 238 238 253 253 253 253 253 253
50436 -253 253 253 253 253 253 253 253 253 253 253 253
50437 -253 253 253 253 253 253 231 231 231 250 250 250
50438 -253 253 253 253 253 253 253 253 253 253 253 253
50439 -253 253 253 253 253 253 253 253 253 253 253 253
50440 -253 253 253 253 253 253 253 253 253 253 253 253
50441 -253 253 253 253 253 253 253 253 253 246 230 190
50442 -238 204 91 238 204 91 181 142 44 37 26 9
50443 - 2 2 6 2 2 6 2 2 6 2 2 6
50444 - 2 2 6 2 2 6 38 38 38 46 46 46
50445 - 26 26 26 106 106 106 54 54 54 18 18 18
50446 - 6 6 6 0 0 0 0 0 0 0 0 0
50447 - 0 0 0 0 0 0 0 0 0 0 0 0
50448 - 0 0 0 0 0 0 0 0 0 0 0 0
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 0 0 0 0
50451 - 0 0 0 6 6 6 14 14 14 22 22 22
50452 - 30 30 30 38 38 38 50 50 50 70 70 70
50453 -106 106 106 190 142 34 226 170 11 242 186 14
50454 -246 190 14 246 190 14 246 190 14 154 114 10
50455 - 6 6 6 74 74 74 226 226 226 253 253 253
50456 -253 253 253 253 253 253 253 253 253 253 253 253
50457 -253 253 253 253 253 253 231 231 231 250 250 250
50458 -253 253 253 253 253 253 253 253 253 253 253 253
50459 -253 253 253 253 253 253 253 253 253 253 253 253
50460 -253 253 253 253 253 253 253 253 253 253 253 253
50461 -253 253 253 253 253 253 253 253 253 228 184 62
50462 -241 196 14 241 208 19 232 195 16 38 30 10
50463 - 2 2 6 2 2 6 2 2 6 2 2 6
50464 - 2 2 6 6 6 6 30 30 30 26 26 26
50465 -203 166 17 154 142 90 66 66 66 26 26 26
50466 - 6 6 6 0 0 0 0 0 0 0 0 0
50467 - 0 0 0 0 0 0 0 0 0 0 0 0
50468 - 0 0 0 0 0 0 0 0 0 0 0 0
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 6 6 6 18 18 18 38 38 38 58 58 58
50472 - 78 78 78 86 86 86 101 101 101 123 123 123
50473 -175 146 61 210 150 10 234 174 13 246 186 14
50474 -246 190 14 246 190 14 246 190 14 238 190 10
50475 -102 78 10 2 2 6 46 46 46 198 198 198
50476 -253 253 253 253 253 253 253 253 253 253 253 253
50477 -253 253 253 253 253 253 234 234 234 242 242 242
50478 -253 253 253 253 253 253 253 253 253 253 253 253
50479 -253 253 253 253 253 253 253 253 253 253 253 253
50480 -253 253 253 253 253 253 253 253 253 253 253 253
50481 -253 253 253 253 253 253 253 253 253 224 178 62
50482 -242 186 14 241 196 14 210 166 10 22 18 6
50483 - 2 2 6 2 2 6 2 2 6 2 2 6
50484 - 2 2 6 2 2 6 6 6 6 121 92 8
50485 -238 202 15 232 195 16 82 82 82 34 34 34
50486 - 10 10 10 0 0 0 0 0 0 0 0 0
50487 - 0 0 0 0 0 0 0 0 0 0 0 0
50488 - 0 0 0 0 0 0 0 0 0 0 0 0
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 14 14 14 38 38 38 70 70 70 154 122 46
50492 -190 142 34 200 144 11 197 138 11 197 138 11
50493 -213 154 11 226 170 11 242 186 14 246 190 14
50494 -246 190 14 246 190 14 246 190 14 246 190 14
50495 -225 175 15 46 32 6 2 2 6 22 22 22
50496 -158 158 158 250 250 250 253 253 253 253 253 253
50497 -253 253 253 253 253 253 253 253 253 253 253 253
50498 -253 253 253 253 253 253 253 253 253 253 253 253
50499 -253 253 253 253 253 253 253 253 253 253 253 253
50500 -253 253 253 253 253 253 253 253 253 253 253 253
50501 -253 253 253 250 250 250 242 242 242 224 178 62
50502 -239 182 13 236 186 11 213 154 11 46 32 6
50503 - 2 2 6 2 2 6 2 2 6 2 2 6
50504 - 2 2 6 2 2 6 61 42 6 225 175 15
50505 -238 190 10 236 186 11 112 100 78 42 42 42
50506 - 14 14 14 0 0 0 0 0 0 0 0 0
50507 - 0 0 0 0 0 0 0 0 0 0 0 0
50508 - 0 0 0 0 0 0 0 0 0 0 0 0
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 6 6 6
50511 - 22 22 22 54 54 54 154 122 46 213 154 11
50512 -226 170 11 230 174 11 226 170 11 226 170 11
50513 -236 178 12 242 186 14 246 190 14 246 190 14
50514 -246 190 14 246 190 14 246 190 14 246 190 14
50515 -241 196 14 184 144 12 10 10 10 2 2 6
50516 - 6 6 6 116 116 116 242 242 242 253 253 253
50517 -253 253 253 253 253 253 253 253 253 253 253 253
50518 -253 253 253 253 253 253 253 253 253 253 253 253
50519 -253 253 253 253 253 253 253 253 253 253 253 253
50520 -253 253 253 253 253 253 253 253 253 253 253 253
50521 -253 253 253 231 231 231 198 198 198 214 170 54
50522 -236 178 12 236 178 12 210 150 10 137 92 6
50523 - 18 14 6 2 2 6 2 2 6 2 2 6
50524 - 6 6 6 70 47 6 200 144 11 236 178 12
50525 -239 182 13 239 182 13 124 112 88 58 58 58
50526 - 22 22 22 6 6 6 0 0 0 0 0 0
50527 - 0 0 0 0 0 0 0 0 0 0 0 0
50528 - 0 0 0 0 0 0 0 0 0 0 0 0
50529 - 0 0 0 0 0 0 0 0 0 0 0 0
50530 - 0 0 0 0 0 0 0 0 0 10 10 10
50531 - 30 30 30 70 70 70 180 133 36 226 170 11
50532 -239 182 13 242 186 14 242 186 14 246 186 14
50533 -246 190 14 246 190 14 246 190 14 246 190 14
50534 -246 190 14 246 190 14 246 190 14 246 190 14
50535 -246 190 14 232 195 16 98 70 6 2 2 6
50536 - 2 2 6 2 2 6 66 66 66 221 221 221
50537 -253 253 253 253 253 253 253 253 253 253 253 253
50538 -253 253 253 253 253 253 253 253 253 253 253 253
50539 -253 253 253 253 253 253 253 253 253 253 253 253
50540 -253 253 253 253 253 253 253 253 253 253 253 253
50541 -253 253 253 206 206 206 198 198 198 214 166 58
50542 -230 174 11 230 174 11 216 158 10 192 133 9
50543 -163 110 8 116 81 8 102 78 10 116 81 8
50544 -167 114 7 197 138 11 226 170 11 239 182 13
50545 -242 186 14 242 186 14 162 146 94 78 78 78
50546 - 34 34 34 14 14 14 6 6 6 0 0 0
50547 - 0 0 0 0 0 0 0 0 0 0 0 0
50548 - 0 0 0 0 0 0 0 0 0 0 0 0
50549 - 0 0 0 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 6 6 6
50551 - 30 30 30 78 78 78 190 142 34 226 170 11
50552 -239 182 13 246 190 14 246 190 14 246 190 14
50553 -246 190 14 246 190 14 246 190 14 246 190 14
50554 -246 190 14 246 190 14 246 190 14 246 190 14
50555 -246 190 14 241 196 14 203 166 17 22 18 6
50556 - 2 2 6 2 2 6 2 2 6 38 38 38
50557 -218 218 218 253 253 253 253 253 253 253 253 253
50558 -253 253 253 253 253 253 253 253 253 253 253 253
50559 -253 253 253 253 253 253 253 253 253 253 253 253
50560 -253 253 253 253 253 253 253 253 253 253 253 253
50561 -250 250 250 206 206 206 198 198 198 202 162 69
50562 -226 170 11 236 178 12 224 166 10 210 150 10
50563 -200 144 11 197 138 11 192 133 9 197 138 11
50564 -210 150 10 226 170 11 242 186 14 246 190 14
50565 -246 190 14 246 186 14 225 175 15 124 112 88
50566 - 62 62 62 30 30 30 14 14 14 6 6 6
50567 - 0 0 0 0 0 0 0 0 0 0 0 0
50568 - 0 0 0 0 0 0 0 0 0 0 0 0
50569 - 0 0 0 0 0 0 0 0 0 0 0 0
50570 - 0 0 0 0 0 0 0 0 0 10 10 10
50571 - 30 30 30 78 78 78 174 135 50 224 166 10
50572 -239 182 13 246 190 14 246 190 14 246 190 14
50573 -246 190 14 246 190 14 246 190 14 246 190 14
50574 -246 190 14 246 190 14 246 190 14 246 190 14
50575 -246 190 14 246 190 14 241 196 14 139 102 15
50576 - 2 2 6 2 2 6 2 2 6 2 2 6
50577 - 78 78 78 250 250 250 253 253 253 253 253 253
50578 -253 253 253 253 253 253 253 253 253 253 253 253
50579 -253 253 253 253 253 253 253 253 253 253 253 253
50580 -253 253 253 253 253 253 253 253 253 253 253 253
50581 -250 250 250 214 214 214 198 198 198 190 150 46
50582 -219 162 10 236 178 12 234 174 13 224 166 10
50583 -216 158 10 213 154 11 213 154 11 216 158 10
50584 -226 170 11 239 182 13 246 190 14 246 190 14
50585 -246 190 14 246 190 14 242 186 14 206 162 42
50586 -101 101 101 58 58 58 30 30 30 14 14 14
50587 - 6 6 6 0 0 0 0 0 0 0 0 0
50588 - 0 0 0 0 0 0 0 0 0 0 0 0
50589 - 0 0 0 0 0 0 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 10 10 10
50591 - 30 30 30 74 74 74 174 135 50 216 158 10
50592 -236 178 12 246 190 14 246 190 14 246 190 14
50593 -246 190 14 246 190 14 246 190 14 246 190 14
50594 -246 190 14 246 190 14 246 190 14 246 190 14
50595 -246 190 14 246 190 14 241 196 14 226 184 13
50596 - 61 42 6 2 2 6 2 2 6 2 2 6
50597 - 22 22 22 238 238 238 253 253 253 253 253 253
50598 -253 253 253 253 253 253 253 253 253 253 253 253
50599 -253 253 253 253 253 253 253 253 253 253 253 253
50600 -253 253 253 253 253 253 253 253 253 253 253 253
50601 -253 253 253 226 226 226 187 187 187 180 133 36
50602 -216 158 10 236 178 12 239 182 13 236 178 12
50603 -230 174 11 226 170 11 226 170 11 230 174 11
50604 -236 178 12 242 186 14 246 190 14 246 190 14
50605 -246 190 14 246 190 14 246 186 14 239 182 13
50606 -206 162 42 106 106 106 66 66 66 34 34 34
50607 - 14 14 14 6 6 6 0 0 0 0 0 0
50608 - 0 0 0 0 0 0 0 0 0 0 0 0
50609 - 0 0 0 0 0 0 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 6 6 6
50611 - 26 26 26 70 70 70 163 133 67 213 154 11
50612 -236 178 12 246 190 14 246 190 14 246 190 14
50613 -246 190 14 246 190 14 246 190 14 246 190 14
50614 -246 190 14 246 190 14 246 190 14 246 190 14
50615 -246 190 14 246 190 14 246 190 14 241 196 14
50616 -190 146 13 18 14 6 2 2 6 2 2 6
50617 - 46 46 46 246 246 246 253 253 253 253 253 253
50618 -253 253 253 253 253 253 253 253 253 253 253 253
50619 -253 253 253 253 253 253 253 253 253 253 253 253
50620 -253 253 253 253 253 253 253 253 253 253 253 253
50621 -253 253 253 221 221 221 86 86 86 156 107 11
50622 -216 158 10 236 178 12 242 186 14 246 186 14
50623 -242 186 14 239 182 13 239 182 13 242 186 14
50624 -242 186 14 246 186 14 246 190 14 246 190 14
50625 -246 190 14 246 190 14 246 190 14 246 190 14
50626 -242 186 14 225 175 15 142 122 72 66 66 66
50627 - 30 30 30 10 10 10 0 0 0 0 0 0
50628 - 0 0 0 0 0 0 0 0 0 0 0 0
50629 - 0 0 0 0 0 0 0 0 0 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 6 6 6
50631 - 26 26 26 70 70 70 163 133 67 210 150 10
50632 -236 178 12 246 190 14 246 190 14 246 190 14
50633 -246 190 14 246 190 14 246 190 14 246 190 14
50634 -246 190 14 246 190 14 246 190 14 246 190 14
50635 -246 190 14 246 190 14 246 190 14 246 190 14
50636 -232 195 16 121 92 8 34 34 34 106 106 106
50637 -221 221 221 253 253 253 253 253 253 253 253 253
50638 -253 253 253 253 253 253 253 253 253 253 253 253
50639 -253 253 253 253 253 253 253 253 253 253 253 253
50640 -253 253 253 253 253 253 253 253 253 253 253 253
50641 -242 242 242 82 82 82 18 14 6 163 110 8
50642 -216 158 10 236 178 12 242 186 14 246 190 14
50643 -246 190 14 246 190 14 246 190 14 246 190 14
50644 -246 190 14 246 190 14 246 190 14 246 190 14
50645 -246 190 14 246 190 14 246 190 14 246 190 14
50646 -246 190 14 246 190 14 242 186 14 163 133 67
50647 - 46 46 46 18 18 18 6 6 6 0 0 0
50648 - 0 0 0 0 0 0 0 0 0 0 0 0
50649 - 0 0 0 0 0 0 0 0 0 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 10 10 10
50651 - 30 30 30 78 78 78 163 133 67 210 150 10
50652 -236 178 12 246 186 14 246 190 14 246 190 14
50653 -246 190 14 246 190 14 246 190 14 246 190 14
50654 -246 190 14 246 190 14 246 190 14 246 190 14
50655 -246 190 14 246 190 14 246 190 14 246 190 14
50656 -241 196 14 215 174 15 190 178 144 253 253 253
50657 -253 253 253 253 253 253 253 253 253 253 253 253
50658 -253 253 253 253 253 253 253 253 253 253 253 253
50659 -253 253 253 253 253 253 253 253 253 253 253 253
50660 -253 253 253 253 253 253 253 253 253 218 218 218
50661 - 58 58 58 2 2 6 22 18 6 167 114 7
50662 -216 158 10 236 178 12 246 186 14 246 190 14
50663 -246 190 14 246 190 14 246 190 14 246 190 14
50664 -246 190 14 246 190 14 246 190 14 246 190 14
50665 -246 190 14 246 190 14 246 190 14 246 190 14
50666 -246 190 14 246 186 14 242 186 14 190 150 46
50667 - 54 54 54 22 22 22 6 6 6 0 0 0
50668 - 0 0 0 0 0 0 0 0 0 0 0 0
50669 - 0 0 0 0 0 0 0 0 0 0 0 0
50670 - 0 0 0 0 0 0 0 0 0 14 14 14
50671 - 38 38 38 86 86 86 180 133 36 213 154 11
50672 -236 178 12 246 186 14 246 190 14 246 190 14
50673 -246 190 14 246 190 14 246 190 14 246 190 14
50674 -246 190 14 246 190 14 246 190 14 246 190 14
50675 -246 190 14 246 190 14 246 190 14 246 190 14
50676 -246 190 14 232 195 16 190 146 13 214 214 214
50677 -253 253 253 253 253 253 253 253 253 253 253 253
50678 -253 253 253 253 253 253 253 253 253 253 253 253
50679 -253 253 253 253 253 253 253 253 253 253 253 253
50680 -253 253 253 250 250 250 170 170 170 26 26 26
50681 - 2 2 6 2 2 6 37 26 9 163 110 8
50682 -219 162 10 239 182 13 246 186 14 246 190 14
50683 -246 190 14 246 190 14 246 190 14 246 190 14
50684 -246 190 14 246 190 14 246 190 14 246 190 14
50685 -246 190 14 246 190 14 246 190 14 246 190 14
50686 -246 186 14 236 178 12 224 166 10 142 122 72
50687 - 46 46 46 18 18 18 6 6 6 0 0 0
50688 - 0 0 0 0 0 0 0 0 0 0 0 0
50689 - 0 0 0 0 0 0 0 0 0 0 0 0
50690 - 0 0 0 0 0 0 6 6 6 18 18 18
50691 - 50 50 50 109 106 95 192 133 9 224 166 10
50692 -242 186 14 246 190 14 246 190 14 246 190 14
50693 -246 190 14 246 190 14 246 190 14 246 190 14
50694 -246 190 14 246 190 14 246 190 14 246 190 14
50695 -246 190 14 246 190 14 246 190 14 246 190 14
50696 -242 186 14 226 184 13 210 162 10 142 110 46
50697 -226 226 226 253 253 253 253 253 253 253 253 253
50698 -253 253 253 253 253 253 253 253 253 253 253 253
50699 -253 253 253 253 253 253 253 253 253 253 253 253
50700 -198 198 198 66 66 66 2 2 6 2 2 6
50701 - 2 2 6 2 2 6 50 34 6 156 107 11
50702 -219 162 10 239 182 13 246 186 14 246 190 14
50703 -246 190 14 246 190 14 246 190 14 246 190 14
50704 -246 190 14 246 190 14 246 190 14 246 190 14
50705 -246 190 14 246 190 14 246 190 14 242 186 14
50706 -234 174 13 213 154 11 154 122 46 66 66 66
50707 - 30 30 30 10 10 10 0 0 0 0 0 0
50708 - 0 0 0 0 0 0 0 0 0 0 0 0
50709 - 0 0 0 0 0 0 0 0 0 0 0 0
50710 - 0 0 0 0 0 0 6 6 6 22 22 22
50711 - 58 58 58 154 121 60 206 145 10 234 174 13
50712 -242 186 14 246 186 14 246 190 14 246 190 14
50713 -246 190 14 246 190 14 246 190 14 246 190 14
50714 -246 190 14 246 190 14 246 190 14 246 190 14
50715 -246 190 14 246 190 14 246 190 14 246 190 14
50716 -246 186 14 236 178 12 210 162 10 163 110 8
50717 - 61 42 6 138 138 138 218 218 218 250 250 250
50718 -253 253 253 253 253 253 253 253 253 250 250 250
50719 -242 242 242 210 210 210 144 144 144 66 66 66
50720 - 6 6 6 2 2 6 2 2 6 2 2 6
50721 - 2 2 6 2 2 6 61 42 6 163 110 8
50722 -216 158 10 236 178 12 246 190 14 246 190 14
50723 -246 190 14 246 190 14 246 190 14 246 190 14
50724 -246 190 14 246 190 14 246 190 14 246 190 14
50725 -246 190 14 239 182 13 230 174 11 216 158 10
50726 -190 142 34 124 112 88 70 70 70 38 38 38
50727 - 18 18 18 6 6 6 0 0 0 0 0 0
50728 - 0 0 0 0 0 0 0 0 0 0 0 0
50729 - 0 0 0 0 0 0 0 0 0 0 0 0
50730 - 0 0 0 0 0 0 6 6 6 22 22 22
50731 - 62 62 62 168 124 44 206 145 10 224 166 10
50732 -236 178 12 239 182 13 242 186 14 242 186 14
50733 -246 186 14 246 190 14 246 190 14 246 190 14
50734 -246 190 14 246 190 14 246 190 14 246 190 14
50735 -246 190 14 246 190 14 246 190 14 246 190 14
50736 -246 190 14 236 178 12 216 158 10 175 118 6
50737 - 80 54 7 2 2 6 6 6 6 30 30 30
50738 - 54 54 54 62 62 62 50 50 50 38 38 38
50739 - 14 14 14 2 2 6 2 2 6 2 2 6
50740 - 2 2 6 2 2 6 2 2 6 2 2 6
50741 - 2 2 6 6 6 6 80 54 7 167 114 7
50742 -213 154 11 236 178 12 246 190 14 246 190 14
50743 -246 190 14 246 190 14 246 190 14 246 190 14
50744 -246 190 14 242 186 14 239 182 13 239 182 13
50745 -230 174 11 210 150 10 174 135 50 124 112 88
50746 - 82 82 82 54 54 54 34 34 34 18 18 18
50747 - 6 6 6 0 0 0 0 0 0 0 0 0
50748 - 0 0 0 0 0 0 0 0 0 0 0 0
50749 - 0 0 0 0 0 0 0 0 0 0 0 0
50750 - 0 0 0 0 0 0 6 6 6 18 18 18
50751 - 50 50 50 158 118 36 192 133 9 200 144 11
50752 -216 158 10 219 162 10 224 166 10 226 170 11
50753 -230 174 11 236 178 12 239 182 13 239 182 13
50754 -242 186 14 246 186 14 246 190 14 246 190 14
50755 -246 190 14 246 190 14 246 190 14 246 190 14
50756 -246 186 14 230 174 11 210 150 10 163 110 8
50757 -104 69 6 10 10 10 2 2 6 2 2 6
50758 - 2 2 6 2 2 6 2 2 6 2 2 6
50759 - 2 2 6 2 2 6 2 2 6 2 2 6
50760 - 2 2 6 2 2 6 2 2 6 2 2 6
50761 - 2 2 6 6 6 6 91 60 6 167 114 7
50762 -206 145 10 230 174 11 242 186 14 246 190 14
50763 -246 190 14 246 190 14 246 186 14 242 186 14
50764 -239 182 13 230 174 11 224 166 10 213 154 11
50765 -180 133 36 124 112 88 86 86 86 58 58 58
50766 - 38 38 38 22 22 22 10 10 10 6 6 6
50767 - 0 0 0 0 0 0 0 0 0 0 0 0
50768 - 0 0 0 0 0 0 0 0 0 0 0 0
50769 - 0 0 0 0 0 0 0 0 0 0 0 0
50770 - 0 0 0 0 0 0 0 0 0 14 14 14
50771 - 34 34 34 70 70 70 138 110 50 158 118 36
50772 -167 114 7 180 123 7 192 133 9 197 138 11
50773 -200 144 11 206 145 10 213 154 11 219 162 10
50774 -224 166 10 230 174 11 239 182 13 242 186 14
50775 -246 186 14 246 186 14 246 186 14 246 186 14
50776 -239 182 13 216 158 10 185 133 11 152 99 6
50777 -104 69 6 18 14 6 2 2 6 2 2 6
50778 - 2 2 6 2 2 6 2 2 6 2 2 6
50779 - 2 2 6 2 2 6 2 2 6 2 2 6
50780 - 2 2 6 2 2 6 2 2 6 2 2 6
50781 - 2 2 6 6 6 6 80 54 7 152 99 6
50782 -192 133 9 219 162 10 236 178 12 239 182 13
50783 -246 186 14 242 186 14 239 182 13 236 178 12
50784 -224 166 10 206 145 10 192 133 9 154 121 60
50785 - 94 94 94 62 62 62 42 42 42 22 22 22
50786 - 14 14 14 6 6 6 0 0 0 0 0 0
50787 - 0 0 0 0 0 0 0 0 0 0 0 0
50788 - 0 0 0 0 0 0 0 0 0 0 0 0
50789 - 0 0 0 0 0 0 0 0 0 0 0 0
50790 - 0 0 0 0 0 0 0 0 0 6 6 6
50791 - 18 18 18 34 34 34 58 58 58 78 78 78
50792 -101 98 89 124 112 88 142 110 46 156 107 11
50793 -163 110 8 167 114 7 175 118 6 180 123 7
50794 -185 133 11 197 138 11 210 150 10 219 162 10
50795 -226 170 11 236 178 12 236 178 12 234 174 13
50796 -219 162 10 197 138 11 163 110 8 130 83 6
50797 - 91 60 6 10 10 10 2 2 6 2 2 6
50798 - 18 18 18 38 38 38 38 38 38 38 38 38
50799 - 38 38 38 38 38 38 38 38 38 38 38 38
50800 - 38 38 38 38 38 38 26 26 26 2 2 6
50801 - 2 2 6 6 6 6 70 47 6 137 92 6
50802 -175 118 6 200 144 11 219 162 10 230 174 11
50803 -234 174 13 230 174 11 219 162 10 210 150 10
50804 -192 133 9 163 110 8 124 112 88 82 82 82
50805 - 50 50 50 30 30 30 14 14 14 6 6 6
50806 - 0 0 0 0 0 0 0 0 0 0 0 0
50807 - 0 0 0 0 0 0 0 0 0 0 0 0
50808 - 0 0 0 0 0 0 0 0 0 0 0 0
50809 - 0 0 0 0 0 0 0 0 0 0 0 0
50810 - 0 0 0 0 0 0 0 0 0 0 0 0
50811 - 6 6 6 14 14 14 22 22 22 34 34 34
50812 - 42 42 42 58 58 58 74 74 74 86 86 86
50813 -101 98 89 122 102 70 130 98 46 121 87 25
50814 -137 92 6 152 99 6 163 110 8 180 123 7
50815 -185 133 11 197 138 11 206 145 10 200 144 11
50816 -180 123 7 156 107 11 130 83 6 104 69 6
50817 - 50 34 6 54 54 54 110 110 110 101 98 89
50818 - 86 86 86 82 82 82 78 78 78 78 78 78
50819 - 78 78 78 78 78 78 78 78 78 78 78 78
50820 - 78 78 78 82 82 82 86 86 86 94 94 94
50821 -106 106 106 101 101 101 86 66 34 124 80 6
50822 -156 107 11 180 123 7 192 133 9 200 144 11
50823 -206 145 10 200 144 11 192 133 9 175 118 6
50824 -139 102 15 109 106 95 70 70 70 42 42 42
50825 - 22 22 22 10 10 10 0 0 0 0 0 0
50826 - 0 0 0 0 0 0 0 0 0 0 0 0
50827 - 0 0 0 0 0 0 0 0 0 0 0 0
50828 - 0 0 0 0 0 0 0 0 0 0 0 0
50829 - 0 0 0 0 0 0 0 0 0 0 0 0
50830 - 0 0 0 0 0 0 0 0 0 0 0 0
50831 - 0 0 0 0 0 0 6 6 6 10 10 10
50832 - 14 14 14 22 22 22 30 30 30 38 38 38
50833 - 50 50 50 62 62 62 74 74 74 90 90 90
50834 -101 98 89 112 100 78 121 87 25 124 80 6
50835 -137 92 6 152 99 6 152 99 6 152 99 6
50836 -138 86 6 124 80 6 98 70 6 86 66 30
50837 -101 98 89 82 82 82 58 58 58 46 46 46
50838 - 38 38 38 34 34 34 34 34 34 34 34 34
50839 - 34 34 34 34 34 34 34 34 34 34 34 34
50840 - 34 34 34 34 34 34 38 38 38 42 42 42
50841 - 54 54 54 82 82 82 94 86 76 91 60 6
50842 -134 86 6 156 107 11 167 114 7 175 118 6
50843 -175 118 6 167 114 7 152 99 6 121 87 25
50844 -101 98 89 62 62 62 34 34 34 18 18 18
50845 - 6 6 6 0 0 0 0 0 0 0 0 0
50846 - 0 0 0 0 0 0 0 0 0 0 0 0
50847 - 0 0 0 0 0 0 0 0 0 0 0 0
50848 - 0 0 0 0 0 0 0 0 0 0 0 0
50849 - 0 0 0 0 0 0 0 0 0 0 0 0
50850 - 0 0 0 0 0 0 0 0 0 0 0 0
50851 - 0 0 0 0 0 0 0 0 0 0 0 0
50852 - 0 0 0 6 6 6 6 6 6 10 10 10
50853 - 18 18 18 22 22 22 30 30 30 42 42 42
50854 - 50 50 50 66 66 66 86 86 86 101 98 89
50855 -106 86 58 98 70 6 104 69 6 104 69 6
50856 -104 69 6 91 60 6 82 62 34 90 90 90
50857 - 62 62 62 38 38 38 22 22 22 14 14 14
50858 - 10 10 10 10 10 10 10 10 10 10 10 10
50859 - 10 10 10 10 10 10 6 6 6 10 10 10
50860 - 10 10 10 10 10 10 10 10 10 14 14 14
50861 - 22 22 22 42 42 42 70 70 70 89 81 66
50862 - 80 54 7 104 69 6 124 80 6 137 92 6
50863 -134 86 6 116 81 8 100 82 52 86 86 86
50864 - 58 58 58 30 30 30 14 14 14 6 6 6
50865 - 0 0 0 0 0 0 0 0 0 0 0 0
50866 - 0 0 0 0 0 0 0 0 0 0 0 0
50867 - 0 0 0 0 0 0 0 0 0 0 0 0
50868 - 0 0 0 0 0 0 0 0 0 0 0 0
50869 - 0 0 0 0 0 0 0 0 0 0 0 0
50870 - 0 0 0 0 0 0 0 0 0 0 0 0
50871 - 0 0 0 0 0 0 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 6 6 6 10 10 10 14 14 14
50874 - 18 18 18 26 26 26 38 38 38 54 54 54
50875 - 70 70 70 86 86 86 94 86 76 89 81 66
50876 - 89 81 66 86 86 86 74 74 74 50 50 50
50877 - 30 30 30 14 14 14 6 6 6 0 0 0
50878 - 0 0 0 0 0 0 0 0 0 0 0 0
50879 - 0 0 0 0 0 0 0 0 0 0 0 0
50880 - 0 0 0 0 0 0 0 0 0 0 0 0
50881 - 6 6 6 18 18 18 34 34 34 58 58 58
50882 - 82 82 82 89 81 66 89 81 66 89 81 66
50883 - 94 86 66 94 86 76 74 74 74 50 50 50
50884 - 26 26 26 14 14 14 6 6 6 0 0 0
50885 - 0 0 0 0 0 0 0 0 0 0 0 0
50886 - 0 0 0 0 0 0 0 0 0 0 0 0
50887 - 0 0 0 0 0 0 0 0 0 0 0 0
50888 - 0 0 0 0 0 0 0 0 0 0 0 0
50889 - 0 0 0 0 0 0 0 0 0 0 0 0
50890 - 0 0 0 0 0 0 0 0 0 0 0 0
50891 - 0 0 0 0 0 0 0 0 0 0 0 0
50892 - 0 0 0 0 0 0 0 0 0 0 0 0
50893 - 0 0 0 0 0 0 0 0 0 0 0 0
50894 - 6 6 6 6 6 6 14 14 14 18 18 18
50895 - 30 30 30 38 38 38 46 46 46 54 54 54
50896 - 50 50 50 42 42 42 30 30 30 18 18 18
50897 - 10 10 10 0 0 0 0 0 0 0 0 0
50898 - 0 0 0 0 0 0 0 0 0 0 0 0
50899 - 0 0 0 0 0 0 0 0 0 0 0 0
50900 - 0 0 0 0 0 0 0 0 0 0 0 0
50901 - 0 0 0 6 6 6 14 14 14 26 26 26
50902 - 38 38 38 50 50 50 58 58 58 58 58 58
50903 - 54 54 54 42 42 42 30 30 30 18 18 18
50904 - 10 10 10 0 0 0 0 0 0 0 0 0
50905 - 0 0 0 0 0 0 0 0 0 0 0 0
50906 - 0 0 0 0 0 0 0 0 0 0 0 0
50907 - 0 0 0 0 0 0 0 0 0 0 0 0
50908 - 0 0 0 0 0 0 0 0 0 0 0 0
50909 - 0 0 0 0 0 0 0 0 0 0 0 0
50910 - 0 0 0 0 0 0 0 0 0 0 0 0
50911 - 0 0 0 0 0 0 0 0 0 0 0 0
50912 - 0 0 0 0 0 0 0 0 0 0 0 0
50913 - 0 0 0 0 0 0 0 0 0 0 0 0
50914 - 0 0 0 0 0 0 0 0 0 6 6 6
50915 - 6 6 6 10 10 10 14 14 14 18 18 18
50916 - 18 18 18 14 14 14 10 10 10 6 6 6
50917 - 0 0 0 0 0 0 0 0 0 0 0 0
50918 - 0 0 0 0 0 0 0 0 0 0 0 0
50919 - 0 0 0 0 0 0 0 0 0 0 0 0
50920 - 0 0 0 0 0 0 0 0 0 0 0 0
50921 - 0 0 0 0 0 0 0 0 0 6 6 6
50922 - 14 14 14 18 18 18 22 22 22 22 22 22
50923 - 18 18 18 14 14 14 10 10 10 6 6 6
50924 - 0 0 0 0 0 0 0 0 0 0 0 0
50925 - 0 0 0 0 0 0 0 0 0 0 0 0
50926 - 0 0 0 0 0 0 0 0 0 0 0 0
50927 - 0 0 0 0 0 0 0 0 0 0 0 0
50928 - 0 0 0 0 0 0 0 0 0 0 0 0
50929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50942 +4 4 4 4 4 4
50943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50956 +4 4 4 4 4 4
50957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50970 +4 4 4 4 4 4
50971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50984 +4 4 4 4 4 4
50985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50998 +4 4 4 4 4 4
50999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51012 +4 4 4 4 4 4
51013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51018 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51022 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51023 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51024 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51026 +4 4 4 4 4 4
51027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51032 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51033 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51036 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51037 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51038 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51039 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51040 +4 4 4 4 4 4
51041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51045 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51046 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51047 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51050 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51051 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51052 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51053 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51054 +4 4 4 4 4 4
51055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51058 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51059 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51060 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51061 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51063 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51064 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51065 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51066 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51067 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51068 +4 4 4 4 4 4
51069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51072 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51073 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51074 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51075 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51076 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51077 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51078 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51079 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51080 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51081 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51082 +4 4 4 4 4 4
51083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51086 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51087 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51088 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51089 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51090 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51091 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51092 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51093 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51094 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51095 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51096 +4 4 4 4 4 4
51097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51099 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51100 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51101 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51102 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51103 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51104 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51105 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51106 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51107 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51108 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51109 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51110 +4 4 4 4 4 4
51111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51113 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51114 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51115 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51116 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51117 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51118 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51119 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51120 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51121 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51122 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51123 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51124 +4 4 4 4 4 4
51125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51127 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51128 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51129 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51130 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51131 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51132 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51133 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51134 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51135 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51136 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51137 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51138 +4 4 4 4 4 4
51139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51141 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51142 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51143 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51144 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51145 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51146 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51147 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51148 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51149 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51150 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51151 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51152 +4 4 4 4 4 4
51153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51154 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51155 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51156 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51157 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51158 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51159 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51160 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51161 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51162 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51163 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51164 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51165 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51166 +4 4 4 4 4 4
51167 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51168 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51169 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51170 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51171 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51172 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51173 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51174 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51175 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51176 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51177 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51178 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51179 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51180 +0 0 0 4 4 4
51181 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51182 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51183 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51184 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51185 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51186 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51187 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51188 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51189 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51190 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51191 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51192 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51193 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51194 +2 0 0 0 0 0
51195 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51196 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51197 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51198 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51199 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51200 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51201 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51202 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51203 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51204 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51205 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51206 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51207 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51208 +37 38 37 0 0 0
51209 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51210 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51211 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51212 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51213 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51214 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51215 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51216 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51217 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51218 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51219 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51220 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51221 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51222 +85 115 134 4 0 0
51223 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51224 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51225 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51226 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51227 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51228 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51229 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51230 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51231 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51232 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51233 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51234 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51235 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51236 +60 73 81 4 0 0
51237 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51238 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51239 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51240 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51241 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51242 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51243 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51244 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51245 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51246 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51247 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51248 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51249 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51250 +16 19 21 4 0 0
51251 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51252 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51253 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51254 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51255 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51256 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51257 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51258 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51259 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51260 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51261 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51262 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51263 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51264 +4 0 0 4 3 3
51265 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51266 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51267 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51269 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51270 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51271 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51272 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51273 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51274 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51275 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51276 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51277 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51278 +3 2 2 4 4 4
51279 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51280 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51281 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51282 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51283 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51284 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51285 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51286 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51287 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51288 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51289 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51290 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51291 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51292 +4 4 4 4 4 4
51293 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51294 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51295 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51296 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51297 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51298 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51299 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51300 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51301 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51302 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51303 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51304 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51305 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51306 +4 4 4 4 4 4
51307 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51308 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51309 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51310 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51311 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51312 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51313 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51314 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51315 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51316 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51317 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51318 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51319 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51320 +5 5 5 5 5 5
51321 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51322 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51323 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51324 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51325 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51326 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51327 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51328 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51329 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51330 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51331 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51332 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51333 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51334 +5 5 5 4 4 4
51335 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51336 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51337 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51338 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51339 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51340 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51341 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51342 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51343 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51344 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51345 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51346 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51348 +4 4 4 4 4 4
51349 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51350 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51351 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51352 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51353 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51354 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51355 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51356 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51357 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51358 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51359 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51360 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
51361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51362 +4 4 4 4 4 4
51363 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51364 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51365 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51366 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51367 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51368 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51369 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51370 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51371 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51372 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51373 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51376 +4 4 4 4 4 4
51377 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51378 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51379 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51380 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51381 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51382 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51383 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51384 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51385 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51386 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51387 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51390 +4 4 4 4 4 4
51391 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51392 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51393 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51394 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51395 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51396 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51397 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51398 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51399 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51400 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51401 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51404 +4 4 4 4 4 4
51405 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51406 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51407 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51408 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51409 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51410 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51411 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51412 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51413 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51414 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51415 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51418 +4 4 4 4 4 4
51419 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51420 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51421 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51422 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51423 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51424 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51425 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51426 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51427 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51428 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51429 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51432 +4 4 4 4 4 4
51433 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51434 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51435 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51436 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51437 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51438 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51439 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51440 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51441 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51442 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51443 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51446 +4 4 4 4 4 4
51447 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51448 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51449 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51450 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51451 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51452 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51453 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51454 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51455 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51456 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51457 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51460 +4 4 4 4 4 4
51461 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51462 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51463 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51464 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51465 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51466 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51467 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51468 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51469 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51470 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51471 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51474 +4 4 4 4 4 4
51475 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51476 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51477 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51478 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51479 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51480 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51481 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51482 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51483 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51484 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51485 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51488 +4 4 4 4 4 4
51489 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51490 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51491 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51492 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51493 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51494 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51495 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51496 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51497 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51498 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51499 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51502 +4 4 4 4 4 4
51503 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51504 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51505 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51506 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51507 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51508 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51509 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51510 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51511 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51512 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51513 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51516 +4 4 4 4 4 4
51517 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51518 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51519 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51520 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51521 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51522 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51523 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51524 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51525 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51526 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51527 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4
51531 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51532 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51533 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51534 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51535 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51536 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51537 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51538 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51539 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51540 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51541 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 4 4 4
51545 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51546 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51547 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51548 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51549 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51550 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51551 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51552 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51553 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51554 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51555 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4
51559 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51560 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51561 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51562 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51563 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51564 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51565 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51566 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51567 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51568 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51569 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4
51573 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51574 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51575 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51576 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51577 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51578 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51579 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51580 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51581 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51582 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51583 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4
51587 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51588 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51589 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51590 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51591 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51592 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51593 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51594 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51595 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51596 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51597 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4
51601 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51602 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51603 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51604 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51605 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51606 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51607 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51608 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51609 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51610 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51611 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51614 +4 4 4 4 4 4
51615 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51616 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51617 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51618 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51619 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51620 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51621 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51622 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51623 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51624 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51625 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51628 +4 4 4 4 4 4
51629 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51630 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51631 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51632 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51633 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51634 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51635 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51636 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51637 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51638 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51639 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51642 +4 4 4 4 4 4
51643 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51644 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51645 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51646 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51647 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51648 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51649 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51650 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51651 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51652 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51653 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51656 +4 4 4 4 4 4
51657 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51658 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51659 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51660 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51661 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51662 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51663 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51664 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51665 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51666 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51667 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51670 +4 4 4 4 4 4
51671 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51672 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51673 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51675 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51676 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51677 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51678 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51679 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51680 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51681 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51684 +4 4 4 4 4 4
51685 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51686 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51687 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51688 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51689 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51690 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51691 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51692 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51693 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51694 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51695 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51698 +4 4 4 4 4 4
51699 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51700 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51701 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51702 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51703 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51704 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51705 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51706 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51707 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51708 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51709 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51712 +4 4 4 4 4 4
51713 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51714 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51715 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51716 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51717 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51718 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51719 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51720 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51721 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51722 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51723 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51726 +4 4 4 4 4 4
51727 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51728 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51729 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51730 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51731 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51732 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51733 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51734 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51735 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51736 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51737 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51740 +4 4 4 4 4 4
51741 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51742 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51743 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51744 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51745 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51746 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51747 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51748 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51749 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51750 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51754 +4 4 4 4 4 4
51755 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51756 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51757 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51758 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51759 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51760 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51761 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51762 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51763 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51764 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51768 +4 4 4 4 4 4
51769 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51770 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51771 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51772 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51773 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51774 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51775 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51776 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51777 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51778 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51782 +4 4 4 4 4 4
51783 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51784 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51785 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51786 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51787 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51788 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51789 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51790 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51791 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51792 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51796 +4 4 4 4 4 4
51797 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51798 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51799 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51800 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51801 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51802 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51803 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51804 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51805 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51810 +4 4 4 4 4 4
51811 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51812 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51813 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51814 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51815 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51816 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51817 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51818 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51819 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51824 +4 4 4 4 4 4
51825 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51826 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51827 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51828 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51829 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51830 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51831 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51832 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51833 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51838 +4 4 4 4 4 4
51839 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51840 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51841 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51842 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51843 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51844 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51845 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51846 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51852 +4 4 4 4 4 4
51853 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51854 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51855 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51856 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51857 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51858 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51859 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51860 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51866 +4 4 4 4 4 4
51867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51868 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51869 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51870 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51871 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51872 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51873 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51874 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51880 +4 4 4 4 4 4
51881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51882 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51883 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51884 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51885 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51886 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51887 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51888 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51894 +4 4 4 4 4 4
51895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51896 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51897 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51898 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51899 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51900 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51901 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51902 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51908 +4 4 4 4 4 4
51909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51911 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51912 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51913 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51914 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51915 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51916 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51922 +4 4 4 4 4 4
51923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51926 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51927 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51928 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51929 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51936 +4 4 4 4 4 4
51937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51940 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51941 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51942 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51943 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51950 +4 4 4 4 4 4
51951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51954 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51955 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51956 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51957 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51964 +4 4 4 4 4 4
51965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51968 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51969 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51970 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51971 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51978 +4 4 4 4 4 4
51979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51983 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51984 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51985 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51992 +4 4 4 4 4 4
51993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51997 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51998 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51999 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52006 +4 4 4 4 4 4
52007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52011 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52012 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52013 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52020 +4 4 4 4 4 4
52021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52025 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52026 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52034 +4 4 4 4 4 4
52035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52039 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52040 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52048 +4 4 4 4 4 4
52049 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52050 index fe92eed..106e085 100644
52051 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52052 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52053 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52054 struct mb862xxfb_par *par = info->par;
52055
52056 if (info->var.bits_per_pixel == 32) {
52057 - info->fbops->fb_fillrect = cfb_fillrect;
52058 - info->fbops->fb_copyarea = cfb_copyarea;
52059 - info->fbops->fb_imageblit = cfb_imageblit;
52060 + pax_open_kernel();
52061 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52062 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52063 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52064 + pax_close_kernel();
52065 } else {
52066 outreg(disp, GC_L0EM, 3);
52067 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52068 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52069 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52070 + pax_open_kernel();
52071 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52072 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52073 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52074 + pax_close_kernel();
52075 }
52076 outreg(draw, GDC_REG_DRAW_BASE, 0);
52077 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52078 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52079 index ff22871..b129bed 100644
52080 --- a/drivers/video/nvidia/nvidia.c
52081 +++ b/drivers/video/nvidia/nvidia.c
52082 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52083 info->fix.line_length = (info->var.xres_virtual *
52084 info->var.bits_per_pixel) >> 3;
52085 if (info->var.accel_flags) {
52086 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52087 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52088 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52089 - info->fbops->fb_sync = nvidiafb_sync;
52090 + pax_open_kernel();
52091 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52092 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52093 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52094 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52095 + pax_close_kernel();
52096 info->pixmap.scan_align = 4;
52097 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52098 info->flags |= FBINFO_READS_FAST;
52099 NVResetGraphics(info);
52100 } else {
52101 - info->fbops->fb_imageblit = cfb_imageblit;
52102 - info->fbops->fb_fillrect = cfb_fillrect;
52103 - info->fbops->fb_copyarea = cfb_copyarea;
52104 - info->fbops->fb_sync = NULL;
52105 + pax_open_kernel();
52106 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52107 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52108 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52109 + *(void **)&info->fbops->fb_sync = NULL;
52110 + pax_close_kernel();
52111 info->pixmap.scan_align = 1;
52112 info->flags |= FBINFO_HWACCEL_DISABLED;
52113 info->flags &= ~FBINFO_READS_FAST;
52114 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52115 info->pixmap.size = 8 * 1024;
52116 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52117
52118 - if (!hwcur)
52119 - info->fbops->fb_cursor = NULL;
52120 + if (!hwcur) {
52121 + pax_open_kernel();
52122 + *(void **)&info->fbops->fb_cursor = NULL;
52123 + pax_close_kernel();
52124 + }
52125
52126 info->var.accel_flags = (!noaccel);
52127
52128 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52129 index 05c2dc3..ea1f391 100644
52130 --- a/drivers/video/s1d13xxxfb.c
52131 +++ b/drivers/video/s1d13xxxfb.c
52132 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52133
52134 switch(prod_id) {
52135 case S1D13506_PROD_ID: /* activate acceleration */
52136 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52137 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52138 + pax_open_kernel();
52139 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52140 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52141 + pax_close_kernel();
52142 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52143 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52144 break;
52145 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52146 index e188ada..aac63c8 100644
52147 --- a/drivers/video/smscufx.c
52148 +++ b/drivers/video/smscufx.c
52149 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52150 fb_deferred_io_cleanup(info);
52151 kfree(info->fbdefio);
52152 info->fbdefio = NULL;
52153 - info->fbops->fb_mmap = ufx_ops_mmap;
52154 + pax_open_kernel();
52155 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52156 + pax_close_kernel();
52157 }
52158
52159 pr_debug("released /dev/fb%d user=%d count=%d",
52160 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52161 index d2e5bc3..4cb05d1 100644
52162 --- a/drivers/video/udlfb.c
52163 +++ b/drivers/video/udlfb.c
52164 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52165 dlfb_urb_completion(urb);
52166
52167 error:
52168 - atomic_add(bytes_sent, &dev->bytes_sent);
52169 - atomic_add(bytes_identical, &dev->bytes_identical);
52170 - atomic_add(width*height*2, &dev->bytes_rendered);
52171 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52172 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52173 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52174 end_cycles = get_cycles();
52175 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52176 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52177 >> 10)), /* Kcycles */
52178 &dev->cpu_kcycles_used);
52179
52180 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52181 dlfb_urb_completion(urb);
52182
52183 error:
52184 - atomic_add(bytes_sent, &dev->bytes_sent);
52185 - atomic_add(bytes_identical, &dev->bytes_identical);
52186 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52187 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52188 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52189 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52190 end_cycles = get_cycles();
52191 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52192 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52193 >> 10)), /* Kcycles */
52194 &dev->cpu_kcycles_used);
52195 }
52196 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52197 fb_deferred_io_cleanup(info);
52198 kfree(info->fbdefio);
52199 info->fbdefio = NULL;
52200 - info->fbops->fb_mmap = dlfb_ops_mmap;
52201 + pax_open_kernel();
52202 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52203 + pax_close_kernel();
52204 }
52205
52206 pr_warn("released /dev/fb%d user=%d count=%d\n",
52207 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52208 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52209 struct dlfb_data *dev = fb_info->par;
52210 return snprintf(buf, PAGE_SIZE, "%u\n",
52211 - atomic_read(&dev->bytes_rendered));
52212 + atomic_read_unchecked(&dev->bytes_rendered));
52213 }
52214
52215 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52216 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52217 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52218 struct dlfb_data *dev = fb_info->par;
52219 return snprintf(buf, PAGE_SIZE, "%u\n",
52220 - atomic_read(&dev->bytes_identical));
52221 + atomic_read_unchecked(&dev->bytes_identical));
52222 }
52223
52224 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52225 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52226 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52227 struct dlfb_data *dev = fb_info->par;
52228 return snprintf(buf, PAGE_SIZE, "%u\n",
52229 - atomic_read(&dev->bytes_sent));
52230 + atomic_read_unchecked(&dev->bytes_sent));
52231 }
52232
52233 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52234 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52235 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52236 struct dlfb_data *dev = fb_info->par;
52237 return snprintf(buf, PAGE_SIZE, "%u\n",
52238 - atomic_read(&dev->cpu_kcycles_used));
52239 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52240 }
52241
52242 static ssize_t edid_show(
52243 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52244 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52245 struct dlfb_data *dev = fb_info->par;
52246
52247 - atomic_set(&dev->bytes_rendered, 0);
52248 - atomic_set(&dev->bytes_identical, 0);
52249 - atomic_set(&dev->bytes_sent, 0);
52250 - atomic_set(&dev->cpu_kcycles_used, 0);
52251 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52252 + atomic_set_unchecked(&dev->bytes_identical, 0);
52253 + atomic_set_unchecked(&dev->bytes_sent, 0);
52254 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52255
52256 return count;
52257 }
52258 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52259 index 7aec6f3..e3b2d55 100644
52260 --- a/drivers/video/uvesafb.c
52261 +++ b/drivers/video/uvesafb.c
52262 @@ -19,6 +19,7 @@
52263 #include <linux/io.h>
52264 #include <linux/mutex.h>
52265 #include <linux/slab.h>
52266 +#include <linux/moduleloader.h>
52267 #include <video/edid.h>
52268 #include <video/uvesafb.h>
52269 #ifdef CONFIG_X86
52270 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52271 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52272 par->pmi_setpal = par->ypan = 0;
52273 } else {
52274 +
52275 +#ifdef CONFIG_PAX_KERNEXEC
52276 +#ifdef CONFIG_MODULES
52277 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52278 +#endif
52279 + if (!par->pmi_code) {
52280 + par->pmi_setpal = par->ypan = 0;
52281 + return 0;
52282 + }
52283 +#endif
52284 +
52285 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52286 + task->t.regs.edi);
52287 +
52288 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52289 + pax_open_kernel();
52290 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52291 + pax_close_kernel();
52292 +
52293 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52294 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52295 +#else
52296 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52297 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52298 +#endif
52299 +
52300 printk(KERN_INFO "uvesafb: protected mode interface info at "
52301 "%04x:%04x\n",
52302 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52303 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52304 par->ypan = ypan;
52305
52306 if (par->pmi_setpal || par->ypan) {
52307 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52308 if (__supported_pte_mask & _PAGE_NX) {
52309 par->pmi_setpal = par->ypan = 0;
52310 printk(KERN_WARNING "uvesafb: NX protection is active, "
52311 "better not use the PMI.\n");
52312 - } else {
52313 + } else
52314 +#endif
52315 uvesafb_vbe_getpmi(task, par);
52316 - }
52317 }
52318 #else
52319 /* The protected mode interface is not available on non-x86. */
52320 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52321 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52322
52323 /* Disable blanking if the user requested so. */
52324 - if (!blank)
52325 - info->fbops->fb_blank = NULL;
52326 + if (!blank) {
52327 + pax_open_kernel();
52328 + *(void **)&info->fbops->fb_blank = NULL;
52329 + pax_close_kernel();
52330 + }
52331
52332 /*
52333 * Find out how much IO memory is required for the mode with
52334 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52335 info->flags = FBINFO_FLAG_DEFAULT |
52336 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52337
52338 - if (!par->ypan)
52339 - info->fbops->fb_pan_display = NULL;
52340 + if (!par->ypan) {
52341 + pax_open_kernel();
52342 + *(void **)&info->fbops->fb_pan_display = NULL;
52343 + pax_close_kernel();
52344 + }
52345 }
52346
52347 static void uvesafb_init_mtrr(struct fb_info *info)
52348 @@ -1796,6 +1826,11 @@ out:
52349 if (par->vbe_modes)
52350 kfree(par->vbe_modes);
52351
52352 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52353 + if (par->pmi_code)
52354 + module_free_exec(NULL, par->pmi_code);
52355 +#endif
52356 +
52357 framebuffer_release(info);
52358 return err;
52359 }
52360 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
52361 kfree(par->vbe_state_orig);
52362 if (par->vbe_state_saved)
52363 kfree(par->vbe_state_saved);
52364 +
52365 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52366 + if (par->pmi_code)
52367 + module_free_exec(NULL, par->pmi_code);
52368 +#endif
52369 +
52370 }
52371
52372 framebuffer_release(info);
52373 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52374 index bd83233..7d8a5aa 100644
52375 --- a/drivers/video/vesafb.c
52376 +++ b/drivers/video/vesafb.c
52377 @@ -9,6 +9,7 @@
52378 */
52379
52380 #include <linux/module.h>
52381 +#include <linux/moduleloader.h>
52382 #include <linux/kernel.h>
52383 #include <linux/errno.h>
52384 #include <linux/string.h>
52385 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
52386 static int vram_total; /* Set total amount of memory */
52387 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52388 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52389 -static void (*pmi_start)(void) __read_mostly;
52390 -static void (*pmi_pal) (void) __read_mostly;
52391 +static void (*pmi_start)(void) __read_only;
52392 +static void (*pmi_pal) (void) __read_only;
52393 static int depth __read_mostly;
52394 static int vga_compat __read_mostly;
52395 /* --------------------------------------------------------------------- */
52396 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
52397 unsigned int size_remap;
52398 unsigned int size_total;
52399 char *option = NULL;
52400 + void *pmi_code = NULL;
52401
52402 /* ignore error return of fb_get_options */
52403 fb_get_options("vesafb", &option);
52404 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
52405 size_remap = size_total;
52406 vesafb_fix.smem_len = size_remap;
52407
52408 -#ifndef __i386__
52409 - screen_info.vesapm_seg = 0;
52410 -#endif
52411 -
52412 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52413 printk(KERN_WARNING
52414 "vesafb: cannot reserve video memory at 0x%lx\n",
52415 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
52416 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52417 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52418
52419 +#ifdef __i386__
52420 +
52421 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52422 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52423 + if (!pmi_code)
52424 +#elif !defined(CONFIG_PAX_KERNEXEC)
52425 + if (0)
52426 +#endif
52427 +
52428 +#endif
52429 + screen_info.vesapm_seg = 0;
52430 +
52431 if (screen_info.vesapm_seg) {
52432 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52433 - screen_info.vesapm_seg,screen_info.vesapm_off);
52434 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52435 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52436 }
52437
52438 if (screen_info.vesapm_seg < 0xc000)
52439 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
52440
52441 if (ypan || pmi_setpal) {
52442 unsigned short *pmi_base;
52443 +
52444 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52445 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52446 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52447 +
52448 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52449 + pax_open_kernel();
52450 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52451 +#else
52452 + pmi_code = pmi_base;
52453 +#endif
52454 +
52455 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52456 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52457 +
52458 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52459 + pmi_start = ktva_ktla(pmi_start);
52460 + pmi_pal = ktva_ktla(pmi_pal);
52461 + pax_close_kernel();
52462 +#endif
52463 +
52464 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52465 if (pmi_base[3]) {
52466 printk(KERN_INFO "vesafb: pmi: ports = ");
52467 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
52468 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52469 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52470
52471 - if (!ypan)
52472 - info->fbops->fb_pan_display = NULL;
52473 + if (!ypan) {
52474 + pax_open_kernel();
52475 + *(void **)&info->fbops->fb_pan_display = NULL;
52476 + pax_close_kernel();
52477 + }
52478
52479 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52480 err = -ENOMEM;
52481 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
52482 info->node, info->fix.id);
52483 return 0;
52484 err:
52485 +
52486 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52487 + module_free_exec(NULL, pmi_code);
52488 +#endif
52489 +
52490 if (info->screen_base)
52491 iounmap(info->screen_base);
52492 framebuffer_release(info);
52493 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52494 index 88714ae..16c2e11 100644
52495 --- a/drivers/video/via/via_clock.h
52496 +++ b/drivers/video/via/via_clock.h
52497 @@ -56,7 +56,7 @@ struct via_clock {
52498
52499 void (*set_engine_pll_state)(u8 state);
52500 void (*set_engine_pll)(struct via_pll_config config);
52501 -};
52502 +} __no_const;
52503
52504
52505 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52506 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52507 index fef20db..d28b1ab 100644
52508 --- a/drivers/xen/xenfs/xenstored.c
52509 +++ b/drivers/xen/xenfs/xenstored.c
52510 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52511 static int xsd_kva_open(struct inode *inode, struct file *file)
52512 {
52513 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52514 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52515 + NULL);
52516 +#else
52517 xen_store_interface);
52518 +#endif
52519 +
52520 if (!file->private_data)
52521 return -ENOMEM;
52522 return 0;
52523 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52524 index 9ff073f..05cef23 100644
52525 --- a/fs/9p/vfs_addr.c
52526 +++ b/fs/9p/vfs_addr.c
52527 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52528
52529 retval = v9fs_file_write_internal(inode,
52530 v9inode->writeback_fid,
52531 - (__force const char __user *)buffer,
52532 + (const char __force_user *)buffer,
52533 len, &offset, 0);
52534 if (retval > 0)
52535 retval = 0;
52536 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52537 index 94de6d1..8d81256 100644
52538 --- a/fs/9p/vfs_inode.c
52539 +++ b/fs/9p/vfs_inode.c
52540 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52541 void
52542 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52543 {
52544 - char *s = nd_get_link(nd);
52545 + const char *s = nd_get_link(nd);
52546
52547 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52548 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52549 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52550 index 370b24c..ff0be7b 100644
52551 --- a/fs/Kconfig.binfmt
52552 +++ b/fs/Kconfig.binfmt
52553 @@ -103,7 +103,7 @@ config HAVE_AOUT
52554
52555 config BINFMT_AOUT
52556 tristate "Kernel support for a.out and ECOFF binaries"
52557 - depends on HAVE_AOUT
52558 + depends on HAVE_AOUT && BROKEN
52559 ---help---
52560 A.out (Assembler.OUTput) is a set of formats for libraries and
52561 executables used in the earliest versions of UNIX. Linux used
52562 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52563 index 789bc25..fafaeea 100644
52564 --- a/fs/afs/inode.c
52565 +++ b/fs/afs/inode.c
52566 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52567 struct afs_vnode *vnode;
52568 struct super_block *sb;
52569 struct inode *inode;
52570 - static atomic_t afs_autocell_ino;
52571 + static atomic_unchecked_t afs_autocell_ino;
52572
52573 _enter("{%x:%u},%*.*s,",
52574 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52575 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52576 data.fid.unique = 0;
52577 data.fid.vnode = 0;
52578
52579 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52580 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52581 afs_iget5_autocell_test, afs_iget5_set,
52582 &data);
52583 if (!inode) {
52584 diff --git a/fs/aio.c b/fs/aio.c
52585 index 067e3d3..634a850 100644
52586 --- a/fs/aio.c
52587 +++ b/fs/aio.c
52588 @@ -280,7 +280,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52589 size += sizeof(struct io_event) * nr_events;
52590
52591 nr_pages = PFN_UP(size);
52592 - if (nr_pages < 0)
52593 + if (nr_pages <= 0)
52594 return -EINVAL;
52595
52596 file = anon_inode_getfile_private("[aio]", &aio_ring_fops, ctx, O_RDWR);
52597 diff --git a/fs/attr.c b/fs/attr.c
52598 index 1449adb..a2038c2 100644
52599 --- a/fs/attr.c
52600 +++ b/fs/attr.c
52601 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52602 unsigned long limit;
52603
52604 limit = rlimit(RLIMIT_FSIZE);
52605 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52606 if (limit != RLIM_INFINITY && offset > limit)
52607 goto out_sig;
52608 if (offset > inode->i_sb->s_maxbytes)
52609 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52610 index 689e40d..515cac5 100644
52611 --- a/fs/autofs4/waitq.c
52612 +++ b/fs/autofs4/waitq.c
52613 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52614 {
52615 unsigned long sigpipe, flags;
52616 mm_segment_t fs;
52617 - const char *data = (const char *)addr;
52618 + const char __user *data = (const char __force_user *)addr;
52619 ssize_t wr = 0;
52620
52621 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52622 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52623 return 1;
52624 }
52625
52626 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52627 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52628 +#endif
52629 +
52630 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52631 enum autofs_notify notify)
52632 {
52633 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52634
52635 /* If this is a direct mount request create a dummy name */
52636 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52637 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52638 + /* this name does get written to userland via autofs4_write() */
52639 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52640 +#else
52641 qstr.len = sprintf(name, "%p", dentry);
52642 +#endif
52643 else {
52644 qstr.len = autofs4_getpath(sbi, dentry, &name);
52645 if (!qstr.len) {
52646 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52647 index 2722387..56059b5 100644
52648 --- a/fs/befs/endian.h
52649 +++ b/fs/befs/endian.h
52650 @@ -11,7 +11,7 @@
52651
52652 #include <asm/byteorder.h>
52653
52654 -static inline u64
52655 +static inline u64 __intentional_overflow(-1)
52656 fs64_to_cpu(const struct super_block *sb, fs64 n)
52657 {
52658 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52659 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52660 return (__force fs64)cpu_to_be64(n);
52661 }
52662
52663 -static inline u32
52664 +static inline u32 __intentional_overflow(-1)
52665 fs32_to_cpu(const struct super_block *sb, fs32 n)
52666 {
52667 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52668 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
52669 return (__force fs32)cpu_to_be32(n);
52670 }
52671
52672 -static inline u16
52673 +static inline u16 __intentional_overflow(-1)
52674 fs16_to_cpu(const struct super_block *sb, fs16 n)
52675 {
52676 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52677 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52678 index e9c75e2..1baece1 100644
52679 --- a/fs/befs/linuxvfs.c
52680 +++ b/fs/befs/linuxvfs.c
52681 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52682 {
52683 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52684 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52685 - char *link = nd_get_link(nd);
52686 + const char *link = nd_get_link(nd);
52687 if (!IS_ERR(link))
52688 kfree(link);
52689 }
52690 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52691 index 89dec7f..361b0d75 100644
52692 --- a/fs/binfmt_aout.c
52693 +++ b/fs/binfmt_aout.c
52694 @@ -16,6 +16,7 @@
52695 #include <linux/string.h>
52696 #include <linux/fs.h>
52697 #include <linux/file.h>
52698 +#include <linux/security.h>
52699 #include <linux/stat.h>
52700 #include <linux/fcntl.h>
52701 #include <linux/ptrace.h>
52702 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52703 #endif
52704 # define START_STACK(u) ((void __user *)u.start_stack)
52705
52706 + memset(&dump, 0, sizeof(dump));
52707 +
52708 fs = get_fs();
52709 set_fs(KERNEL_DS);
52710 has_dumped = 1;
52711 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52712
52713 /* If the size of the dump file exceeds the rlimit, then see what would happen
52714 if we wrote the stack, but not the data area. */
52715 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52716 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52717 dump.u_dsize = 0;
52718
52719 /* Make sure we have enough room to write the stack and data areas. */
52720 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52721 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52722 dump.u_ssize = 0;
52723
52724 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52725 rlim = rlimit(RLIMIT_DATA);
52726 if (rlim >= RLIM_INFINITY)
52727 rlim = ~0;
52728 +
52729 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52730 if (ex.a_data + ex.a_bss > rlim)
52731 return -ENOMEM;
52732
52733 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52734
52735 install_exec_creds(bprm);
52736
52737 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52738 + current->mm->pax_flags = 0UL;
52739 +#endif
52740 +
52741 +#ifdef CONFIG_PAX_PAGEEXEC
52742 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52743 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52744 +
52745 +#ifdef CONFIG_PAX_EMUTRAMP
52746 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52747 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52748 +#endif
52749 +
52750 +#ifdef CONFIG_PAX_MPROTECT
52751 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52752 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52753 +#endif
52754 +
52755 + }
52756 +#endif
52757 +
52758 if (N_MAGIC(ex) == OMAGIC) {
52759 unsigned long text_addr, map_size;
52760 loff_t pos;
52761 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52762 }
52763
52764 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52765 - PROT_READ | PROT_WRITE | PROT_EXEC,
52766 + PROT_READ | PROT_WRITE,
52767 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52768 fd_offset + ex.a_text);
52769 if (error != N_DATADDR(ex)) {
52770 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52771 index 4c94a79..f428019 100644
52772 --- a/fs/binfmt_elf.c
52773 +++ b/fs/binfmt_elf.c
52774 @@ -34,6 +34,7 @@
52775 #include <linux/utsname.h>
52776 #include <linux/coredump.h>
52777 #include <linux/sched.h>
52778 +#include <linux/xattr.h>
52779 #include <asm/uaccess.h>
52780 #include <asm/param.h>
52781 #include <asm/page.h>
52782 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52783 #define elf_core_dump NULL
52784 #endif
52785
52786 +#ifdef CONFIG_PAX_MPROTECT
52787 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52788 +#endif
52789 +
52790 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52791 +static void elf_handle_mmap(struct file *file);
52792 +#endif
52793 +
52794 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52795 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52796 #else
52797 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52798 .load_binary = load_elf_binary,
52799 .load_shlib = load_elf_library,
52800 .core_dump = elf_core_dump,
52801 +
52802 +#ifdef CONFIG_PAX_MPROTECT
52803 + .handle_mprotect= elf_handle_mprotect,
52804 +#endif
52805 +
52806 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52807 + .handle_mmap = elf_handle_mmap,
52808 +#endif
52809 +
52810 .min_coredump = ELF_EXEC_PAGESIZE,
52811 };
52812
52813 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52814
52815 static int set_brk(unsigned long start, unsigned long end)
52816 {
52817 + unsigned long e = end;
52818 +
52819 start = ELF_PAGEALIGN(start);
52820 end = ELF_PAGEALIGN(end);
52821 if (end > start) {
52822 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52823 if (BAD_ADDR(addr))
52824 return addr;
52825 }
52826 - current->mm->start_brk = current->mm->brk = end;
52827 + current->mm->start_brk = current->mm->brk = e;
52828 return 0;
52829 }
52830
52831 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52832 elf_addr_t __user *u_rand_bytes;
52833 const char *k_platform = ELF_PLATFORM;
52834 const char *k_base_platform = ELF_BASE_PLATFORM;
52835 - unsigned char k_rand_bytes[16];
52836 + u32 k_rand_bytes[4];
52837 int items;
52838 elf_addr_t *elf_info;
52839 int ei_index = 0;
52840 const struct cred *cred = current_cred();
52841 struct vm_area_struct *vma;
52842 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52843
52844 /*
52845 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52846 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52847 * Generate 16 random bytes for userspace PRNG seeding.
52848 */
52849 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52850 - u_rand_bytes = (elf_addr_t __user *)
52851 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52852 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52853 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52854 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52855 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52856 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52857 + u_rand_bytes = (elf_addr_t __user *) p;
52858 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52859 return -EFAULT;
52860
52861 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52862 return -EFAULT;
52863 current->mm->env_end = p;
52864
52865 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52866 +
52867 /* Put the elf_info on the stack in the right place. */
52868 sp = (elf_addr_t __user *)envp + 1;
52869 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52870 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52871 return -EFAULT;
52872 return 0;
52873 }
52874 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52875 an ELF header */
52876
52877 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52878 - struct file *interpreter, unsigned long *interp_map_addr,
52879 - unsigned long no_base)
52880 + struct file *interpreter, unsigned long no_base)
52881 {
52882 struct elf_phdr *elf_phdata;
52883 struct elf_phdr *eppnt;
52884 - unsigned long load_addr = 0;
52885 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52886 int load_addr_set = 0;
52887 unsigned long last_bss = 0, elf_bss = 0;
52888 - unsigned long error = ~0UL;
52889 + unsigned long error = -EINVAL;
52890 unsigned long total_size;
52891 int retval, i, size;
52892
52893 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52894 goto out_close;
52895 }
52896
52897 +#ifdef CONFIG_PAX_SEGMEXEC
52898 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52899 + pax_task_size = SEGMEXEC_TASK_SIZE;
52900 +#endif
52901 +
52902 eppnt = elf_phdata;
52903 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52904 if (eppnt->p_type == PT_LOAD) {
52905 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52906 map_addr = elf_map(interpreter, load_addr + vaddr,
52907 eppnt, elf_prot, elf_type, total_size);
52908 total_size = 0;
52909 - if (!*interp_map_addr)
52910 - *interp_map_addr = map_addr;
52911 error = map_addr;
52912 if (BAD_ADDR(map_addr))
52913 goto out_close;
52914 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52915 k = load_addr + eppnt->p_vaddr;
52916 if (BAD_ADDR(k) ||
52917 eppnt->p_filesz > eppnt->p_memsz ||
52918 - eppnt->p_memsz > TASK_SIZE ||
52919 - TASK_SIZE - eppnt->p_memsz < k) {
52920 + eppnt->p_memsz > pax_task_size ||
52921 + pax_task_size - eppnt->p_memsz < k) {
52922 error = -ENOMEM;
52923 goto out_close;
52924 }
52925 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52926 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52927
52928 /* Map the last of the bss segment */
52929 - error = vm_brk(elf_bss, last_bss - elf_bss);
52930 - if (BAD_ADDR(error))
52931 - goto out_close;
52932 + if (last_bss > elf_bss) {
52933 + error = vm_brk(elf_bss, last_bss - elf_bss);
52934 + if (BAD_ADDR(error))
52935 + goto out_close;
52936 + }
52937 }
52938
52939 error = load_addr;
52940 @@ -538,6 +569,315 @@ out:
52941 return error;
52942 }
52943
52944 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52945 +#ifdef CONFIG_PAX_SOFTMODE
52946 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52947 +{
52948 + unsigned long pax_flags = 0UL;
52949 +
52950 +#ifdef CONFIG_PAX_PAGEEXEC
52951 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52952 + pax_flags |= MF_PAX_PAGEEXEC;
52953 +#endif
52954 +
52955 +#ifdef CONFIG_PAX_SEGMEXEC
52956 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52957 + pax_flags |= MF_PAX_SEGMEXEC;
52958 +#endif
52959 +
52960 +#ifdef CONFIG_PAX_EMUTRAMP
52961 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52962 + pax_flags |= MF_PAX_EMUTRAMP;
52963 +#endif
52964 +
52965 +#ifdef CONFIG_PAX_MPROTECT
52966 + if (elf_phdata->p_flags & PF_MPROTECT)
52967 + pax_flags |= MF_PAX_MPROTECT;
52968 +#endif
52969 +
52970 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52971 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52972 + pax_flags |= MF_PAX_RANDMMAP;
52973 +#endif
52974 +
52975 + return pax_flags;
52976 +}
52977 +#endif
52978 +
52979 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52980 +{
52981 + unsigned long pax_flags = 0UL;
52982 +
52983 +#ifdef CONFIG_PAX_PAGEEXEC
52984 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52985 + pax_flags |= MF_PAX_PAGEEXEC;
52986 +#endif
52987 +
52988 +#ifdef CONFIG_PAX_SEGMEXEC
52989 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52990 + pax_flags |= MF_PAX_SEGMEXEC;
52991 +#endif
52992 +
52993 +#ifdef CONFIG_PAX_EMUTRAMP
52994 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52995 + pax_flags |= MF_PAX_EMUTRAMP;
52996 +#endif
52997 +
52998 +#ifdef CONFIG_PAX_MPROTECT
52999 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53000 + pax_flags |= MF_PAX_MPROTECT;
53001 +#endif
53002 +
53003 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53004 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53005 + pax_flags |= MF_PAX_RANDMMAP;
53006 +#endif
53007 +
53008 + return pax_flags;
53009 +}
53010 +#endif
53011 +
53012 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53013 +#ifdef CONFIG_PAX_SOFTMODE
53014 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53015 +{
53016 + unsigned long pax_flags = 0UL;
53017 +
53018 +#ifdef CONFIG_PAX_PAGEEXEC
53019 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53020 + pax_flags |= MF_PAX_PAGEEXEC;
53021 +#endif
53022 +
53023 +#ifdef CONFIG_PAX_SEGMEXEC
53024 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53025 + pax_flags |= MF_PAX_SEGMEXEC;
53026 +#endif
53027 +
53028 +#ifdef CONFIG_PAX_EMUTRAMP
53029 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53030 + pax_flags |= MF_PAX_EMUTRAMP;
53031 +#endif
53032 +
53033 +#ifdef CONFIG_PAX_MPROTECT
53034 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53035 + pax_flags |= MF_PAX_MPROTECT;
53036 +#endif
53037 +
53038 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53039 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53040 + pax_flags |= MF_PAX_RANDMMAP;
53041 +#endif
53042 +
53043 + return pax_flags;
53044 +}
53045 +#endif
53046 +
53047 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53048 +{
53049 + unsigned long pax_flags = 0UL;
53050 +
53051 +#ifdef CONFIG_PAX_PAGEEXEC
53052 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53053 + pax_flags |= MF_PAX_PAGEEXEC;
53054 +#endif
53055 +
53056 +#ifdef CONFIG_PAX_SEGMEXEC
53057 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53058 + pax_flags |= MF_PAX_SEGMEXEC;
53059 +#endif
53060 +
53061 +#ifdef CONFIG_PAX_EMUTRAMP
53062 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53063 + pax_flags |= MF_PAX_EMUTRAMP;
53064 +#endif
53065 +
53066 +#ifdef CONFIG_PAX_MPROTECT
53067 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53068 + pax_flags |= MF_PAX_MPROTECT;
53069 +#endif
53070 +
53071 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53072 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53073 + pax_flags |= MF_PAX_RANDMMAP;
53074 +#endif
53075 +
53076 + return pax_flags;
53077 +}
53078 +#endif
53079 +
53080 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53081 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53082 +{
53083 + unsigned long pax_flags = 0UL;
53084 +
53085 +#ifdef CONFIG_PAX_EI_PAX
53086 +
53087 +#ifdef CONFIG_PAX_PAGEEXEC
53088 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53089 + pax_flags |= MF_PAX_PAGEEXEC;
53090 +#endif
53091 +
53092 +#ifdef CONFIG_PAX_SEGMEXEC
53093 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53094 + pax_flags |= MF_PAX_SEGMEXEC;
53095 +#endif
53096 +
53097 +#ifdef CONFIG_PAX_EMUTRAMP
53098 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53099 + pax_flags |= MF_PAX_EMUTRAMP;
53100 +#endif
53101 +
53102 +#ifdef CONFIG_PAX_MPROTECT
53103 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53104 + pax_flags |= MF_PAX_MPROTECT;
53105 +#endif
53106 +
53107 +#ifdef CONFIG_PAX_ASLR
53108 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53109 + pax_flags |= MF_PAX_RANDMMAP;
53110 +#endif
53111 +
53112 +#else
53113 +
53114 +#ifdef CONFIG_PAX_PAGEEXEC
53115 + pax_flags |= MF_PAX_PAGEEXEC;
53116 +#endif
53117 +
53118 +#ifdef CONFIG_PAX_SEGMEXEC
53119 + pax_flags |= MF_PAX_SEGMEXEC;
53120 +#endif
53121 +
53122 +#ifdef CONFIG_PAX_MPROTECT
53123 + pax_flags |= MF_PAX_MPROTECT;
53124 +#endif
53125 +
53126 +#ifdef CONFIG_PAX_RANDMMAP
53127 + if (randomize_va_space)
53128 + pax_flags |= MF_PAX_RANDMMAP;
53129 +#endif
53130 +
53131 +#endif
53132 +
53133 + return pax_flags;
53134 +}
53135 +
53136 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53137 +{
53138 +
53139 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53140 + unsigned long i;
53141 +
53142 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53143 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53144 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53145 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53146 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53147 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53148 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53149 + return ~0UL;
53150 +
53151 +#ifdef CONFIG_PAX_SOFTMODE
53152 + if (pax_softmode)
53153 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53154 + else
53155 +#endif
53156 +
53157 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53158 + break;
53159 + }
53160 +#endif
53161 +
53162 + return ~0UL;
53163 +}
53164 +
53165 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53166 +{
53167 +
53168 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53169 + ssize_t xattr_size, i;
53170 + unsigned char xattr_value[sizeof("pemrs") - 1];
53171 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53172 +
53173 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53174 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53175 + return ~0UL;
53176 +
53177 + for (i = 0; i < xattr_size; i++)
53178 + switch (xattr_value[i]) {
53179 + default:
53180 + return ~0UL;
53181 +
53182 +#define parse_flag(option1, option2, flag) \
53183 + case option1: \
53184 + if (pax_flags_hardmode & MF_PAX_##flag) \
53185 + return ~0UL; \
53186 + pax_flags_hardmode |= MF_PAX_##flag; \
53187 + break; \
53188 + case option2: \
53189 + if (pax_flags_softmode & MF_PAX_##flag) \
53190 + return ~0UL; \
53191 + pax_flags_softmode |= MF_PAX_##flag; \
53192 + break;
53193 +
53194 + parse_flag('p', 'P', PAGEEXEC);
53195 + parse_flag('e', 'E', EMUTRAMP);
53196 + parse_flag('m', 'M', MPROTECT);
53197 + parse_flag('r', 'R', RANDMMAP);
53198 + parse_flag('s', 'S', SEGMEXEC);
53199 +
53200 +#undef parse_flag
53201 + }
53202 +
53203 + if (pax_flags_hardmode & pax_flags_softmode)
53204 + return ~0UL;
53205 +
53206 +#ifdef CONFIG_PAX_SOFTMODE
53207 + if (pax_softmode)
53208 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53209 + else
53210 +#endif
53211 +
53212 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53213 +#else
53214 + return ~0UL;
53215 +#endif
53216 +
53217 +}
53218 +
53219 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53220 +{
53221 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53222 +
53223 + pax_flags = pax_parse_ei_pax(elf_ex);
53224 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53225 + xattr_pax_flags = pax_parse_xattr_pax(file);
53226 +
53227 + if (pt_pax_flags == ~0UL)
53228 + pt_pax_flags = xattr_pax_flags;
53229 + else if (xattr_pax_flags == ~0UL)
53230 + xattr_pax_flags = pt_pax_flags;
53231 + if (pt_pax_flags != xattr_pax_flags)
53232 + return -EINVAL;
53233 + if (pt_pax_flags != ~0UL)
53234 + pax_flags = pt_pax_flags;
53235 +
53236 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53237 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53238 + if ((__supported_pte_mask & _PAGE_NX))
53239 + pax_flags &= ~MF_PAX_SEGMEXEC;
53240 + else
53241 + pax_flags &= ~MF_PAX_PAGEEXEC;
53242 + }
53243 +#endif
53244 +
53245 + if (0 > pax_check_flags(&pax_flags))
53246 + return -EINVAL;
53247 +
53248 + current->mm->pax_flags = pax_flags;
53249 + return 0;
53250 +}
53251 +#endif
53252 +
53253 /*
53254 * These are the functions used to load ELF style executables and shared
53255 * libraries. There is no binary dependent code anywhere else.
53256 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53257 {
53258 unsigned int random_variable = 0;
53259
53260 +#ifdef CONFIG_PAX_RANDUSTACK
53261 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53262 + return stack_top - current->mm->delta_stack;
53263 +#endif
53264 +
53265 if ((current->flags & PF_RANDOMIZE) &&
53266 !(current->personality & ADDR_NO_RANDOMIZE)) {
53267 random_variable = get_random_int() & STACK_RND_MASK;
53268 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53269 unsigned long load_addr = 0, load_bias = 0;
53270 int load_addr_set = 0;
53271 char * elf_interpreter = NULL;
53272 - unsigned long error;
53273 + unsigned long error = 0;
53274 struct elf_phdr *elf_ppnt, *elf_phdata;
53275 unsigned long elf_bss, elf_brk;
53276 int retval, i;
53277 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53278 unsigned long start_code, end_code, start_data, end_data;
53279 unsigned long reloc_func_desc __maybe_unused = 0;
53280 int executable_stack = EXSTACK_DEFAULT;
53281 - unsigned long def_flags = 0;
53282 struct pt_regs *regs = current_pt_regs();
53283 struct {
53284 struct elfhdr elf_ex;
53285 struct elfhdr interp_elf_ex;
53286 } *loc;
53287 + unsigned long pax_task_size = TASK_SIZE;
53288
53289 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53290 if (!loc) {
53291 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
53292 goto out_free_dentry;
53293
53294 /* OK, This is the point of no return */
53295 - current->mm->def_flags = def_flags;
53296 +
53297 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53298 + current->mm->pax_flags = 0UL;
53299 +#endif
53300 +
53301 +#ifdef CONFIG_PAX_DLRESOLVE
53302 + current->mm->call_dl_resolve = 0UL;
53303 +#endif
53304 +
53305 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53306 + current->mm->call_syscall = 0UL;
53307 +#endif
53308 +
53309 +#ifdef CONFIG_PAX_ASLR
53310 + current->mm->delta_mmap = 0UL;
53311 + current->mm->delta_stack = 0UL;
53312 +#endif
53313 +
53314 + current->mm->def_flags = 0;
53315 +
53316 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53317 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53318 + send_sig(SIGKILL, current, 0);
53319 + goto out_free_dentry;
53320 + }
53321 +#endif
53322 +
53323 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53324 + pax_set_initial_flags(bprm);
53325 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53326 + if (pax_set_initial_flags_func)
53327 + (pax_set_initial_flags_func)(bprm);
53328 +#endif
53329 +
53330 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53331 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53332 + current->mm->context.user_cs_limit = PAGE_SIZE;
53333 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53334 + }
53335 +#endif
53336 +
53337 +#ifdef CONFIG_PAX_SEGMEXEC
53338 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53339 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53340 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53341 + pax_task_size = SEGMEXEC_TASK_SIZE;
53342 + current->mm->def_flags |= VM_NOHUGEPAGE;
53343 + }
53344 +#endif
53345 +
53346 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53347 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53348 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53349 + put_cpu();
53350 + }
53351 +#endif
53352
53353 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53354 may depend on the personality. */
53355 SET_PERSONALITY(loc->elf_ex);
53356 +
53357 +#ifdef CONFIG_PAX_ASLR
53358 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53359 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53360 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53361 + }
53362 +#endif
53363 +
53364 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53365 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53366 + executable_stack = EXSTACK_DISABLE_X;
53367 + current->personality &= ~READ_IMPLIES_EXEC;
53368 + } else
53369 +#endif
53370 +
53371 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53372 current->personality |= READ_IMPLIES_EXEC;
53373
53374 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53375 #else
53376 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53377 #endif
53378 +
53379 +#ifdef CONFIG_PAX_RANDMMAP
53380 + /* PaX: randomize base address at the default exe base if requested */
53381 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53382 +#ifdef CONFIG_SPARC64
53383 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53384 +#else
53385 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53386 +#endif
53387 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53388 + elf_flags |= MAP_FIXED;
53389 + }
53390 +#endif
53391 +
53392 }
53393
53394 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53395 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53396 * allowed task size. Note that p_filesz must always be
53397 * <= p_memsz so it is only necessary to check p_memsz.
53398 */
53399 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53400 - elf_ppnt->p_memsz > TASK_SIZE ||
53401 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53402 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53403 + elf_ppnt->p_memsz > pax_task_size ||
53404 + pax_task_size - elf_ppnt->p_memsz < k) {
53405 /* set_brk can never work. Avoid overflows. */
53406 send_sig(SIGKILL, current, 0);
53407 retval = -EINVAL;
53408 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53409 goto out_free_dentry;
53410 }
53411 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53412 - send_sig(SIGSEGV, current, 0);
53413 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53414 - goto out_free_dentry;
53415 + /*
53416 + * This bss-zeroing can fail if the ELF
53417 + * file specifies odd protections. So
53418 + * we don't check the return value
53419 + */
53420 }
53421
53422 +#ifdef CONFIG_PAX_RANDMMAP
53423 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53424 + unsigned long start, size, flags;
53425 + vm_flags_t vm_flags;
53426 +
53427 + start = ELF_PAGEALIGN(elf_brk);
53428 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53429 + flags = MAP_FIXED | MAP_PRIVATE;
53430 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53431 +
53432 + down_write(&current->mm->mmap_sem);
53433 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53434 + retval = -ENOMEM;
53435 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53436 +// if (current->personality & ADDR_NO_RANDOMIZE)
53437 +// vm_flags |= VM_READ | VM_MAYREAD;
53438 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53439 + retval = IS_ERR_VALUE(start) ? start : 0;
53440 + }
53441 + up_write(&current->mm->mmap_sem);
53442 + if (retval == 0)
53443 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53444 + if (retval < 0) {
53445 + send_sig(SIGKILL, current, 0);
53446 + goto out_free_dentry;
53447 + }
53448 + }
53449 +#endif
53450 +
53451 if (elf_interpreter) {
53452 - unsigned long interp_map_addr = 0;
53453 -
53454 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53455 interpreter,
53456 - &interp_map_addr,
53457 load_bias);
53458 if (!IS_ERR((void *)elf_entry)) {
53459 /*
53460 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53461 * Decide what to dump of a segment, part, all or none.
53462 */
53463 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53464 - unsigned long mm_flags)
53465 + unsigned long mm_flags, long signr)
53466 {
53467 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53468
53469 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53470 if (vma->vm_file == NULL)
53471 return 0;
53472
53473 - if (FILTER(MAPPED_PRIVATE))
53474 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53475 goto whole;
53476
53477 /*
53478 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53479 {
53480 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53481 int i = 0;
53482 - do
53483 + do {
53484 i += 2;
53485 - while (auxv[i - 2] != AT_NULL);
53486 + } while (auxv[i - 2] != AT_NULL);
53487 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53488 }
53489
53490 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53491 {
53492 mm_segment_t old_fs = get_fs();
53493 set_fs(KERNEL_DS);
53494 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53495 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53496 set_fs(old_fs);
53497 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53498 }
53499 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53500 }
53501
53502 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53503 - unsigned long mm_flags)
53504 + struct coredump_params *cprm)
53505 {
53506 struct vm_area_struct *vma;
53507 size_t size = 0;
53508
53509 for (vma = first_vma(current, gate_vma); vma != NULL;
53510 vma = next_vma(vma, gate_vma))
53511 - size += vma_dump_size(vma, mm_flags);
53512 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53513 return size;
53514 }
53515
53516 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53517
53518 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53519
53520 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53521 + offset += elf_core_vma_data_size(gate_vma, cprm);
53522 offset += elf_core_extra_data_size();
53523 e_shoff = offset;
53524
53525 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53526 offset = dataoff;
53527
53528 size += sizeof(*elf);
53529 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53530 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53531 goto end_coredump;
53532
53533 size += sizeof(*phdr4note);
53534 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53535 if (size > cprm->limit
53536 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53537 goto end_coredump;
53538 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53539 phdr.p_offset = offset;
53540 phdr.p_vaddr = vma->vm_start;
53541 phdr.p_paddr = 0;
53542 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53543 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53544 phdr.p_memsz = vma->vm_end - vma->vm_start;
53545 offset += phdr.p_filesz;
53546 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53547 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53548 phdr.p_align = ELF_EXEC_PAGESIZE;
53549
53550 size += sizeof(phdr);
53551 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53552 if (size > cprm->limit
53553 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53554 goto end_coredump;
53555 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53556 unsigned long addr;
53557 unsigned long end;
53558
53559 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53560 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53561
53562 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53563 struct page *page;
53564 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53565 page = get_dump_page(addr);
53566 if (page) {
53567 void *kaddr = kmap(page);
53568 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53569 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53570 !dump_write(cprm->file, kaddr,
53571 PAGE_SIZE);
53572 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53573
53574 if (e_phnum == PN_XNUM) {
53575 size += sizeof(*shdr4extnum);
53576 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53577 if (size > cprm->limit
53578 || !dump_write(cprm->file, shdr4extnum,
53579 sizeof(*shdr4extnum)))
53580 @@ -2235,6 +2697,167 @@ out:
53581
53582 #endif /* CONFIG_ELF_CORE */
53583
53584 +#ifdef CONFIG_PAX_MPROTECT
53585 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53586 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53587 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53588 + *
53589 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53590 + * basis because we want to allow the common case and not the special ones.
53591 + */
53592 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53593 +{
53594 + struct elfhdr elf_h;
53595 + struct elf_phdr elf_p;
53596 + unsigned long i;
53597 + unsigned long oldflags;
53598 + bool is_textrel_rw, is_textrel_rx, is_relro;
53599 +
53600 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53601 + return;
53602 +
53603 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53604 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53605 +
53606 +#ifdef CONFIG_PAX_ELFRELOCS
53607 + /* possible TEXTREL */
53608 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53609 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53610 +#else
53611 + is_textrel_rw = false;
53612 + is_textrel_rx = false;
53613 +#endif
53614 +
53615 + /* possible RELRO */
53616 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53617 +
53618 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53619 + return;
53620 +
53621 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53622 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53623 +
53624 +#ifdef CONFIG_PAX_ETEXECRELOCS
53625 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53626 +#else
53627 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53628 +#endif
53629 +
53630 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53631 + !elf_check_arch(&elf_h) ||
53632 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53633 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53634 + return;
53635 +
53636 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53637 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53638 + return;
53639 + switch (elf_p.p_type) {
53640 + case PT_DYNAMIC:
53641 + if (!is_textrel_rw && !is_textrel_rx)
53642 + continue;
53643 + i = 0UL;
53644 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53645 + elf_dyn dyn;
53646 +
53647 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53648 + break;
53649 + if (dyn.d_tag == DT_NULL)
53650 + break;
53651 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53652 + gr_log_textrel(vma);
53653 + if (is_textrel_rw)
53654 + vma->vm_flags |= VM_MAYWRITE;
53655 + else
53656 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53657 + vma->vm_flags &= ~VM_MAYWRITE;
53658 + break;
53659 + }
53660 + i++;
53661 + }
53662 + is_textrel_rw = false;
53663 + is_textrel_rx = false;
53664 + continue;
53665 +
53666 + case PT_GNU_RELRO:
53667 + if (!is_relro)
53668 + continue;
53669 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53670 + vma->vm_flags &= ~VM_MAYWRITE;
53671 + is_relro = false;
53672 + continue;
53673 +
53674 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53675 + case PT_PAX_FLAGS: {
53676 + const char *msg_mprotect = "", *msg_emutramp = "";
53677 + char *buffer_lib, *buffer_exe;
53678 +
53679 + if (elf_p.p_flags & PF_NOMPROTECT)
53680 + msg_mprotect = "MPROTECT disabled";
53681 +
53682 +#ifdef CONFIG_PAX_EMUTRAMP
53683 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53684 + msg_emutramp = "EMUTRAMP enabled";
53685 +#endif
53686 +
53687 + if (!msg_mprotect[0] && !msg_emutramp[0])
53688 + continue;
53689 +
53690 + if (!printk_ratelimit())
53691 + continue;
53692 +
53693 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53694 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53695 + if (buffer_lib && buffer_exe) {
53696 + char *path_lib, *path_exe;
53697 +
53698 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53699 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53700 +
53701 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53702 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53703 +
53704 + }
53705 + free_page((unsigned long)buffer_exe);
53706 + free_page((unsigned long)buffer_lib);
53707 + continue;
53708 + }
53709 +#endif
53710 +
53711 + }
53712 + }
53713 +}
53714 +#endif
53715 +
53716 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53717 +
53718 +extern int grsec_enable_log_rwxmaps;
53719 +
53720 +static void elf_handle_mmap(struct file *file)
53721 +{
53722 + struct elfhdr elf_h;
53723 + struct elf_phdr elf_p;
53724 + unsigned long i;
53725 +
53726 + if (!grsec_enable_log_rwxmaps)
53727 + return;
53728 +
53729 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53730 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53731 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53732 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53733 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53734 + return;
53735 +
53736 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53737 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53738 + return;
53739 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53740 + gr_log_ptgnustack(file);
53741 + }
53742 +}
53743 +#endif
53744 +
53745 static int __init init_elf_binfmt(void)
53746 {
53747 register_binfmt(&elf_format);
53748 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53749 index d50bbe5..af3b649 100644
53750 --- a/fs/binfmt_flat.c
53751 +++ b/fs/binfmt_flat.c
53752 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53753 realdatastart = (unsigned long) -ENOMEM;
53754 printk("Unable to allocate RAM for process data, errno %d\n",
53755 (int)-realdatastart);
53756 + down_write(&current->mm->mmap_sem);
53757 vm_munmap(textpos, text_len);
53758 + up_write(&current->mm->mmap_sem);
53759 ret = realdatastart;
53760 goto err;
53761 }
53762 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53763 }
53764 if (IS_ERR_VALUE(result)) {
53765 printk("Unable to read data+bss, errno %d\n", (int)-result);
53766 + down_write(&current->mm->mmap_sem);
53767 vm_munmap(textpos, text_len);
53768 vm_munmap(realdatastart, len);
53769 + up_write(&current->mm->mmap_sem);
53770 ret = result;
53771 goto err;
53772 }
53773 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53774 }
53775 if (IS_ERR_VALUE(result)) {
53776 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53777 + down_write(&current->mm->mmap_sem);
53778 vm_munmap(textpos, text_len + data_len + extra +
53779 MAX_SHARED_LIBS * sizeof(unsigned long));
53780 + up_write(&current->mm->mmap_sem);
53781 ret = result;
53782 goto err;
53783 }
53784 diff --git a/fs/bio.c b/fs/bio.c
53785 index ea5035d..a2932eb 100644
53786 --- a/fs/bio.c
53787 +++ b/fs/bio.c
53788 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53789 /*
53790 * Overflow, abort
53791 */
53792 - if (end < start)
53793 + if (end < start || end - start > INT_MAX - nr_pages)
53794 return ERR_PTR(-EINVAL);
53795
53796 nr_pages += end - start;
53797 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53798 /*
53799 * Overflow, abort
53800 */
53801 - if (end < start)
53802 + if (end < start || end - start > INT_MAX - nr_pages)
53803 return ERR_PTR(-EINVAL);
53804
53805 nr_pages += end - start;
53806 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53807 const int read = bio_data_dir(bio) == READ;
53808 struct bio_map_data *bmd = bio->bi_private;
53809 int i;
53810 - char *p = bmd->sgvecs[0].iov_base;
53811 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53812
53813 bio_for_each_segment_all(bvec, bio, i) {
53814 char *addr = page_address(bvec->bv_page);
53815 diff --git a/fs/block_dev.c b/fs/block_dev.c
53816 index 1e86823..8e34695 100644
53817 --- a/fs/block_dev.c
53818 +++ b/fs/block_dev.c
53819 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53820 else if (bdev->bd_contains == bdev)
53821 return true; /* is a whole device which isn't held */
53822
53823 - else if (whole->bd_holder == bd_may_claim)
53824 + else if (whole->bd_holder == (void *)bd_may_claim)
53825 return true; /* is a partition of a device that is being partitioned */
53826 else if (whole->bd_holder != NULL)
53827 return false; /* is a partition of a held device */
53828 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53829 index 61b5bcd..7eeede8 100644
53830 --- a/fs/btrfs/ctree.c
53831 +++ b/fs/btrfs/ctree.c
53832 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53833 free_extent_buffer(buf);
53834 add_root_to_dirty_list(root);
53835 } else {
53836 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53837 - parent_start = parent->start;
53838 - else
53839 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53840 + if (parent)
53841 + parent_start = parent->start;
53842 + else
53843 + parent_start = 0;
53844 + } else
53845 parent_start = 0;
53846
53847 WARN_ON(trans->transid != btrfs_header_generation(parent));
53848 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53849 index cbd9523..5cca781 100644
53850 --- a/fs/btrfs/delayed-inode.c
53851 +++ b/fs/btrfs/delayed-inode.c
53852 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53853
53854 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53855 {
53856 - int seq = atomic_inc_return(&delayed_root->items_seq);
53857 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53858 if ((atomic_dec_return(&delayed_root->items) <
53859 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53860 waitqueue_active(&delayed_root->wait))
53861 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53862 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53863 int seq, int count)
53864 {
53865 - int val = atomic_read(&delayed_root->items_seq);
53866 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53867
53868 if (val < seq || val >= seq + count)
53869 return 1;
53870 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53871 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53872 return;
53873
53874 - seq = atomic_read(&delayed_root->items_seq);
53875 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53876
53877 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53878 int ret;
53879 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53880 index a4b38f9..f86a509 100644
53881 --- a/fs/btrfs/delayed-inode.h
53882 +++ b/fs/btrfs/delayed-inode.h
53883 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53884 */
53885 struct list_head prepare_list;
53886 atomic_t items; /* for delayed items */
53887 - atomic_t items_seq; /* for delayed items */
53888 + atomic_unchecked_t items_seq; /* for delayed items */
53889 int nodes; /* for delayed nodes */
53890 wait_queue_head_t wait;
53891 };
53892 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53893 struct btrfs_delayed_root *delayed_root)
53894 {
53895 atomic_set(&delayed_root->items, 0);
53896 - atomic_set(&delayed_root->items_seq, 0);
53897 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53898 delayed_root->nodes = 0;
53899 spin_lock_init(&delayed_root->lock);
53900 init_waitqueue_head(&delayed_root->wait);
53901 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53902 index 9d46f60..a8f09eb 100644
53903 --- a/fs/btrfs/ioctl.c
53904 +++ b/fs/btrfs/ioctl.c
53905 @@ -3464,9 +3464,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53906 for (i = 0; i < num_types; i++) {
53907 struct btrfs_space_info *tmp;
53908
53909 + /* Don't copy in more than we allocated */
53910 if (!slot_count)
53911 break;
53912
53913 + slot_count--;
53914 +
53915 info = NULL;
53916 rcu_read_lock();
53917 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53918 @@ -3488,10 +3491,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53919 memcpy(dest, &space, sizeof(space));
53920 dest++;
53921 space_args.total_spaces++;
53922 - slot_count--;
53923 }
53924 - if (!slot_count)
53925 - break;
53926 }
53927 up_read(&info->groups_sem);
53928 }
53929 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53930 index e913328..a34fb36 100644
53931 --- a/fs/btrfs/super.c
53932 +++ b/fs/btrfs/super.c
53933 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53934 function, line, errstr);
53935 return;
53936 }
53937 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53938 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53939 /* Wake up anybody who may be waiting on this transaction */
53940 wake_up(&root->fs_info->transaction_wait);
53941 wake_up(&root->fs_info->transaction_blocked_wait);
53942 diff --git a/fs/buffer.c b/fs/buffer.c
53943 index 6024877..7bd000a 100644
53944 --- a/fs/buffer.c
53945 +++ b/fs/buffer.c
53946 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
53947 bh_cachep = kmem_cache_create("buffer_head",
53948 sizeof(struct buffer_head), 0,
53949 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53950 - SLAB_MEM_SPREAD),
53951 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53952 NULL);
53953
53954 /*
53955 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53956 index 622f469..e8d2d55 100644
53957 --- a/fs/cachefiles/bind.c
53958 +++ b/fs/cachefiles/bind.c
53959 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53960 args);
53961
53962 /* start by checking things over */
53963 - ASSERT(cache->fstop_percent >= 0 &&
53964 - cache->fstop_percent < cache->fcull_percent &&
53965 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53966 cache->fcull_percent < cache->frun_percent &&
53967 cache->frun_percent < 100);
53968
53969 - ASSERT(cache->bstop_percent >= 0 &&
53970 - cache->bstop_percent < cache->bcull_percent &&
53971 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53972 cache->bcull_percent < cache->brun_percent &&
53973 cache->brun_percent < 100);
53974
53975 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53976 index 0a1467b..6a53245 100644
53977 --- a/fs/cachefiles/daemon.c
53978 +++ b/fs/cachefiles/daemon.c
53979 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53980 if (n > buflen)
53981 return -EMSGSIZE;
53982
53983 - if (copy_to_user(_buffer, buffer, n) != 0)
53984 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53985 return -EFAULT;
53986
53987 return n;
53988 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53989 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53990 return -EIO;
53991
53992 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53993 + if (datalen > PAGE_SIZE - 1)
53994 return -EOPNOTSUPP;
53995
53996 /* drag the command string into the kernel so we can parse it */
53997 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53998 if (args[0] != '%' || args[1] != '\0')
53999 return -EINVAL;
54000
54001 - if (fstop < 0 || fstop >= cache->fcull_percent)
54002 + if (fstop >= cache->fcull_percent)
54003 return cachefiles_daemon_range_error(cache, args);
54004
54005 cache->fstop_percent = fstop;
54006 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54007 if (args[0] != '%' || args[1] != '\0')
54008 return -EINVAL;
54009
54010 - if (bstop < 0 || bstop >= cache->bcull_percent)
54011 + if (bstop >= cache->bcull_percent)
54012 return cachefiles_daemon_range_error(cache, args);
54013
54014 cache->bstop_percent = bstop;
54015 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54016 index 5349473..d6c0b93 100644
54017 --- a/fs/cachefiles/internal.h
54018 +++ b/fs/cachefiles/internal.h
54019 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54020 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54021 struct rb_root active_nodes; /* active nodes (can't be culled) */
54022 rwlock_t active_lock; /* lock for active_nodes */
54023 - atomic_t gravecounter; /* graveyard uniquifier */
54024 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54025 unsigned frun_percent; /* when to stop culling (% files) */
54026 unsigned fcull_percent; /* when to start culling (% files) */
54027 unsigned fstop_percent; /* when to stop allocating (% files) */
54028 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54029 * proc.c
54030 */
54031 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54032 -extern atomic_t cachefiles_lookup_histogram[HZ];
54033 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54034 -extern atomic_t cachefiles_create_histogram[HZ];
54035 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54036 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54037 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54038
54039 extern int __init cachefiles_proc_init(void);
54040 extern void cachefiles_proc_cleanup(void);
54041 static inline
54042 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54043 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54044 {
54045 unsigned long jif = jiffies - start_jif;
54046 if (jif >= HZ)
54047 jif = HZ - 1;
54048 - atomic_inc(&histogram[jif]);
54049 + atomic_inc_unchecked(&histogram[jif]);
54050 }
54051
54052 #else
54053 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54054 index f4a08d7..5aa4599 100644
54055 --- a/fs/cachefiles/namei.c
54056 +++ b/fs/cachefiles/namei.c
54057 @@ -317,7 +317,7 @@ try_again:
54058 /* first step is to make up a grave dentry in the graveyard */
54059 sprintf(nbuffer, "%08x%08x",
54060 (uint32_t) get_seconds(),
54061 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54062 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54063
54064 /* do the multiway lock magic */
54065 trap = lock_rename(cache->graveyard, dir);
54066 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54067 index eccd339..4c1d995 100644
54068 --- a/fs/cachefiles/proc.c
54069 +++ b/fs/cachefiles/proc.c
54070 @@ -14,9 +14,9 @@
54071 #include <linux/seq_file.h>
54072 #include "internal.h"
54073
54074 -atomic_t cachefiles_lookup_histogram[HZ];
54075 -atomic_t cachefiles_mkdir_histogram[HZ];
54076 -atomic_t cachefiles_create_histogram[HZ];
54077 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54078 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54079 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54080
54081 /*
54082 * display the latency histogram
54083 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54084 return 0;
54085 default:
54086 index = (unsigned long) v - 3;
54087 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54088 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54089 - z = atomic_read(&cachefiles_create_histogram[index]);
54090 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54091 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54092 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54093 if (x == 0 && y == 0 && z == 0)
54094 return 0;
54095
54096 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54097 index ebaff36..7e3ea26 100644
54098 --- a/fs/cachefiles/rdwr.c
54099 +++ b/fs/cachefiles/rdwr.c
54100 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54101 old_fs = get_fs();
54102 set_fs(KERNEL_DS);
54103 ret = file->f_op->write(
54104 - file, (const void __user *) data, len, &pos);
54105 + file, (const void __force_user *) data, len, &pos);
54106 set_fs(old_fs);
54107 kunmap(page);
54108 file_end_write(file);
54109 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54110 index 868b61d..58835a5 100644
54111 --- a/fs/ceph/dir.c
54112 +++ b/fs/ceph/dir.c
54113 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54114 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54115 struct ceph_mds_client *mdsc = fsc->mdsc;
54116 unsigned frag = fpos_frag(ctx->pos);
54117 - int off = fpos_off(ctx->pos);
54118 + unsigned int off = fpos_off(ctx->pos);
54119 int err;
54120 u32 ftype;
54121 struct ceph_mds_reply_info_parsed *rinfo;
54122 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54123 index 6a0951e..03fac6d 100644
54124 --- a/fs/ceph/super.c
54125 +++ b/fs/ceph/super.c
54126 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54127 /*
54128 * construct our own bdi so we can control readahead, etc.
54129 */
54130 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54131 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54132
54133 static int ceph_register_bdi(struct super_block *sb,
54134 struct ceph_fs_client *fsc)
54135 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54136 default_backing_dev_info.ra_pages;
54137
54138 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54139 - atomic_long_inc_return(&bdi_seq));
54140 + atomic_long_inc_return_unchecked(&bdi_seq));
54141 if (!err)
54142 sb->s_bdi = &fsc->backing_dev_info;
54143 return err;
54144 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54145 index f3ac415..3d2420c 100644
54146 --- a/fs/cifs/cifs_debug.c
54147 +++ b/fs/cifs/cifs_debug.c
54148 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54149
54150 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54151 #ifdef CONFIG_CIFS_STATS2
54152 - atomic_set(&totBufAllocCount, 0);
54153 - atomic_set(&totSmBufAllocCount, 0);
54154 + atomic_set_unchecked(&totBufAllocCount, 0);
54155 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54156 #endif /* CONFIG_CIFS_STATS2 */
54157 spin_lock(&cifs_tcp_ses_lock);
54158 list_for_each(tmp1, &cifs_tcp_ses_list) {
54159 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54160 tcon = list_entry(tmp3,
54161 struct cifs_tcon,
54162 tcon_list);
54163 - atomic_set(&tcon->num_smbs_sent, 0);
54164 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54165 if (server->ops->clear_stats)
54166 server->ops->clear_stats(tcon);
54167 }
54168 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54169 smBufAllocCount.counter, cifs_min_small);
54170 #ifdef CONFIG_CIFS_STATS2
54171 seq_printf(m, "Total Large %d Small %d Allocations\n",
54172 - atomic_read(&totBufAllocCount),
54173 - atomic_read(&totSmBufAllocCount));
54174 + atomic_read_unchecked(&totBufAllocCount),
54175 + atomic_read_unchecked(&totSmBufAllocCount));
54176 #endif /* CONFIG_CIFS_STATS2 */
54177
54178 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54179 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54180 if (tcon->need_reconnect)
54181 seq_puts(m, "\tDISCONNECTED ");
54182 seq_printf(m, "\nSMBs: %d",
54183 - atomic_read(&tcon->num_smbs_sent));
54184 + atomic_read_unchecked(&tcon->num_smbs_sent));
54185 if (server->ops->print_stats)
54186 server->ops->print_stats(m, tcon);
54187 }
54188 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54189 index 77fc5e1..e3d13e6 100644
54190 --- a/fs/cifs/cifsfs.c
54191 +++ b/fs/cifs/cifsfs.c
54192 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54193 */
54194 cifs_req_cachep = kmem_cache_create("cifs_request",
54195 CIFSMaxBufSize + max_hdr_size, 0,
54196 - SLAB_HWCACHE_ALIGN, NULL);
54197 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54198 if (cifs_req_cachep == NULL)
54199 return -ENOMEM;
54200
54201 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54202 efficient to alloc 1 per page off the slab compared to 17K (5page)
54203 alloc of large cifs buffers even when page debugging is on */
54204 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54205 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54206 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54207 NULL);
54208 if (cifs_sm_req_cachep == NULL) {
54209 mempool_destroy(cifs_req_poolp);
54210 @@ -1168,8 +1168,8 @@ init_cifs(void)
54211 atomic_set(&bufAllocCount, 0);
54212 atomic_set(&smBufAllocCount, 0);
54213 #ifdef CONFIG_CIFS_STATS2
54214 - atomic_set(&totBufAllocCount, 0);
54215 - atomic_set(&totSmBufAllocCount, 0);
54216 + atomic_set_unchecked(&totBufAllocCount, 0);
54217 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54218 #endif /* CONFIG_CIFS_STATS2 */
54219
54220 atomic_set(&midCount, 0);
54221 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54222 index 52b6f6c..68db1f4 100644
54223 --- a/fs/cifs/cifsglob.h
54224 +++ b/fs/cifs/cifsglob.h
54225 @@ -758,35 +758,35 @@ struct cifs_tcon {
54226 __u16 Flags; /* optional support bits */
54227 enum statusEnum tidStatus;
54228 #ifdef CONFIG_CIFS_STATS
54229 - atomic_t num_smbs_sent;
54230 + atomic_unchecked_t num_smbs_sent;
54231 union {
54232 struct {
54233 - atomic_t num_writes;
54234 - atomic_t num_reads;
54235 - atomic_t num_flushes;
54236 - atomic_t num_oplock_brks;
54237 - atomic_t num_opens;
54238 - atomic_t num_closes;
54239 - atomic_t num_deletes;
54240 - atomic_t num_mkdirs;
54241 - atomic_t num_posixopens;
54242 - atomic_t num_posixmkdirs;
54243 - atomic_t num_rmdirs;
54244 - atomic_t num_renames;
54245 - atomic_t num_t2renames;
54246 - atomic_t num_ffirst;
54247 - atomic_t num_fnext;
54248 - atomic_t num_fclose;
54249 - atomic_t num_hardlinks;
54250 - atomic_t num_symlinks;
54251 - atomic_t num_locks;
54252 - atomic_t num_acl_get;
54253 - atomic_t num_acl_set;
54254 + atomic_unchecked_t num_writes;
54255 + atomic_unchecked_t num_reads;
54256 + atomic_unchecked_t num_flushes;
54257 + atomic_unchecked_t num_oplock_brks;
54258 + atomic_unchecked_t num_opens;
54259 + atomic_unchecked_t num_closes;
54260 + atomic_unchecked_t num_deletes;
54261 + atomic_unchecked_t num_mkdirs;
54262 + atomic_unchecked_t num_posixopens;
54263 + atomic_unchecked_t num_posixmkdirs;
54264 + atomic_unchecked_t num_rmdirs;
54265 + atomic_unchecked_t num_renames;
54266 + atomic_unchecked_t num_t2renames;
54267 + atomic_unchecked_t num_ffirst;
54268 + atomic_unchecked_t num_fnext;
54269 + atomic_unchecked_t num_fclose;
54270 + atomic_unchecked_t num_hardlinks;
54271 + atomic_unchecked_t num_symlinks;
54272 + atomic_unchecked_t num_locks;
54273 + atomic_unchecked_t num_acl_get;
54274 + atomic_unchecked_t num_acl_set;
54275 } cifs_stats;
54276 #ifdef CONFIG_CIFS_SMB2
54277 struct {
54278 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54279 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54280 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54281 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54282 } smb2_stats;
54283 #endif /* CONFIG_CIFS_SMB2 */
54284 } stats;
54285 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
54286 }
54287
54288 #ifdef CONFIG_CIFS_STATS
54289 -#define cifs_stats_inc atomic_inc
54290 +#define cifs_stats_inc atomic_inc_unchecked
54291
54292 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54293 unsigned int bytes)
54294 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54295 /* Various Debug counters */
54296 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54297 #ifdef CONFIG_CIFS_STATS2
54298 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54299 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54300 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54301 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54302 #endif
54303 GLOBAL_EXTERN atomic_t smBufAllocCount;
54304 GLOBAL_EXTERN atomic_t midCount;
54305 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54306 index 7e36ceb..109252f 100644
54307 --- a/fs/cifs/link.c
54308 +++ b/fs/cifs/link.c
54309 @@ -624,7 +624,7 @@ symlink_exit:
54310
54311 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54312 {
54313 - char *p = nd_get_link(nd);
54314 + const char *p = nd_get_link(nd);
54315 if (!IS_ERR(p))
54316 kfree(p);
54317 }
54318 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54319 index 138a011..cf9e13a 100644
54320 --- a/fs/cifs/misc.c
54321 +++ b/fs/cifs/misc.c
54322 @@ -170,7 +170,7 @@ cifs_buf_get(void)
54323 memset(ret_buf, 0, buf_size + 3);
54324 atomic_inc(&bufAllocCount);
54325 #ifdef CONFIG_CIFS_STATS2
54326 - atomic_inc(&totBufAllocCount);
54327 + atomic_inc_unchecked(&totBufAllocCount);
54328 #endif /* CONFIG_CIFS_STATS2 */
54329 }
54330
54331 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
54332 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54333 atomic_inc(&smBufAllocCount);
54334 #ifdef CONFIG_CIFS_STATS2
54335 - atomic_inc(&totSmBufAllocCount);
54336 + atomic_inc_unchecked(&totSmBufAllocCount);
54337 #endif /* CONFIG_CIFS_STATS2 */
54338
54339 }
54340 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54341 index 8233b17..2b83e95 100644
54342 --- a/fs/cifs/smb1ops.c
54343 +++ b/fs/cifs/smb1ops.c
54344 @@ -590,27 +590,27 @@ static void
54345 cifs_clear_stats(struct cifs_tcon *tcon)
54346 {
54347 #ifdef CONFIG_CIFS_STATS
54348 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54349 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54350 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54351 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54352 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54353 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54354 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54355 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54356 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54357 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54358 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54359 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54360 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54361 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54362 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54363 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54364 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54365 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54366 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54367 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54368 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54369 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54370 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54371 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54372 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54373 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54374 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54375 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54376 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54377 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54378 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54379 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54380 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54381 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54382 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54383 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54384 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54385 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54386 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54387 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54388 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54389 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54390 #endif
54391 }
54392
54393 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54394 {
54395 #ifdef CONFIG_CIFS_STATS
54396 seq_printf(m, " Oplocks breaks: %d",
54397 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54398 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54399 seq_printf(m, "\nReads: %d Bytes: %llu",
54400 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54401 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54402 (long long)(tcon->bytes_read));
54403 seq_printf(m, "\nWrites: %d Bytes: %llu",
54404 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54405 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54406 (long long)(tcon->bytes_written));
54407 seq_printf(m, "\nFlushes: %d",
54408 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54409 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54410 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54411 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54412 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54413 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54414 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54415 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54416 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54417 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54418 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54419 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54420 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54421 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54422 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54423 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54424 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54425 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54426 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54427 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54428 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54429 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54430 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54431 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54432 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54433 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54434 seq_printf(m, "\nRenames: %d T2 Renames %d",
54435 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54436 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54437 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54438 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54439 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54440 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54441 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54442 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54443 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54444 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54445 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54446 #endif
54447 }
54448
54449 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54450 index 861b332..5506392 100644
54451 --- a/fs/cifs/smb2ops.c
54452 +++ b/fs/cifs/smb2ops.c
54453 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54454 #ifdef CONFIG_CIFS_STATS
54455 int i;
54456 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54457 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54458 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54459 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54460 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54461 }
54462 #endif
54463 }
54464 @@ -311,65 +311,65 @@ static void
54465 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54466 {
54467 #ifdef CONFIG_CIFS_STATS
54468 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54469 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54470 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54471 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54472 seq_printf(m, "\nNegotiates: %d sent %d failed",
54473 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54474 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54475 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54476 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54477 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54478 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54479 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54480 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54481 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54482 seq_printf(m, "\nLogoffs: %d sent %d failed",
54483 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54484 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54485 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54486 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54487 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54488 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54489 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54490 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54491 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54492 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54493 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54494 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54495 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54496 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54497 seq_printf(m, "\nCreates: %d sent %d failed",
54498 - atomic_read(&sent[SMB2_CREATE_HE]),
54499 - atomic_read(&failed[SMB2_CREATE_HE]));
54500 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54501 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54502 seq_printf(m, "\nCloses: %d sent %d failed",
54503 - atomic_read(&sent[SMB2_CLOSE_HE]),
54504 - atomic_read(&failed[SMB2_CLOSE_HE]));
54505 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54506 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54507 seq_printf(m, "\nFlushes: %d sent %d failed",
54508 - atomic_read(&sent[SMB2_FLUSH_HE]),
54509 - atomic_read(&failed[SMB2_FLUSH_HE]));
54510 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54511 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54512 seq_printf(m, "\nReads: %d sent %d failed",
54513 - atomic_read(&sent[SMB2_READ_HE]),
54514 - atomic_read(&failed[SMB2_READ_HE]));
54515 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54516 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54517 seq_printf(m, "\nWrites: %d sent %d failed",
54518 - atomic_read(&sent[SMB2_WRITE_HE]),
54519 - atomic_read(&failed[SMB2_WRITE_HE]));
54520 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54521 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54522 seq_printf(m, "\nLocks: %d sent %d failed",
54523 - atomic_read(&sent[SMB2_LOCK_HE]),
54524 - atomic_read(&failed[SMB2_LOCK_HE]));
54525 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54526 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54527 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54528 - atomic_read(&sent[SMB2_IOCTL_HE]),
54529 - atomic_read(&failed[SMB2_IOCTL_HE]));
54530 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54531 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54532 seq_printf(m, "\nCancels: %d sent %d failed",
54533 - atomic_read(&sent[SMB2_CANCEL_HE]),
54534 - atomic_read(&failed[SMB2_CANCEL_HE]));
54535 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54536 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54537 seq_printf(m, "\nEchos: %d sent %d failed",
54538 - atomic_read(&sent[SMB2_ECHO_HE]),
54539 - atomic_read(&failed[SMB2_ECHO_HE]));
54540 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54541 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54542 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54543 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54544 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54545 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54546 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54547 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54548 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54549 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54550 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54551 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54552 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54553 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54554 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54555 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54556 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54557 seq_printf(m, "\nSetInfos: %d sent %d failed",
54558 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54559 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54560 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54561 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54562 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54563 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54564 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54565 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54566 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54567 #endif
54568 }
54569
54570 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54571 index edccb52..16bc6db 100644
54572 --- a/fs/cifs/smb2pdu.c
54573 +++ b/fs/cifs/smb2pdu.c
54574 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54575 default:
54576 cifs_dbg(VFS, "info level %u isn't supported\n",
54577 srch_inf->info_level);
54578 - rc = -EINVAL;
54579 - goto qdir_exit;
54580 + return -EINVAL;
54581 }
54582
54583 req->FileIndex = cpu_to_le32(index);
54584 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54585 index 1da168c..8bc7ff6 100644
54586 --- a/fs/coda/cache.c
54587 +++ b/fs/coda/cache.c
54588 @@ -24,7 +24,7 @@
54589 #include "coda_linux.h"
54590 #include "coda_cache.h"
54591
54592 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54593 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54594
54595 /* replace or extend an acl cache hit */
54596 void coda_cache_enter(struct inode *inode, int mask)
54597 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54598 struct coda_inode_info *cii = ITOC(inode);
54599
54600 spin_lock(&cii->c_lock);
54601 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54602 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54603 if (!uid_eq(cii->c_uid, current_fsuid())) {
54604 cii->c_uid = current_fsuid();
54605 cii->c_cached_perm = mask;
54606 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54607 {
54608 struct coda_inode_info *cii = ITOC(inode);
54609 spin_lock(&cii->c_lock);
54610 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54611 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54612 spin_unlock(&cii->c_lock);
54613 }
54614
54615 /* remove all acl caches */
54616 void coda_cache_clear_all(struct super_block *sb)
54617 {
54618 - atomic_inc(&permission_epoch);
54619 + atomic_inc_unchecked(&permission_epoch);
54620 }
54621
54622
54623 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54624 spin_lock(&cii->c_lock);
54625 hit = (mask & cii->c_cached_perm) == mask &&
54626 uid_eq(cii->c_uid, current_fsuid()) &&
54627 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54628 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54629 spin_unlock(&cii->c_lock);
54630
54631 return hit;
54632 diff --git a/fs/compat.c b/fs/compat.c
54633 index 6af20de..fec3fbb 100644
54634 --- a/fs/compat.c
54635 +++ b/fs/compat.c
54636 @@ -54,7 +54,7 @@
54637 #include <asm/ioctls.h>
54638 #include "internal.h"
54639
54640 -int compat_log = 1;
54641 +int compat_log = 0;
54642
54643 int compat_printk(const char *fmt, ...)
54644 {
54645 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54646
54647 set_fs(KERNEL_DS);
54648 /* The __user pointer cast is valid because of the set_fs() */
54649 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54650 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54651 set_fs(oldfs);
54652 /* truncating is ok because it's a user address */
54653 if (!ret)
54654 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54655 goto out;
54656
54657 ret = -EINVAL;
54658 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54659 + if (nr_segs > UIO_MAXIOV)
54660 goto out;
54661 if (nr_segs > fast_segs) {
54662 ret = -ENOMEM;
54663 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54664 struct compat_readdir_callback {
54665 struct dir_context ctx;
54666 struct compat_old_linux_dirent __user *dirent;
54667 + struct file * file;
54668 int result;
54669 };
54670
54671 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54672 buf->result = -EOVERFLOW;
54673 return -EOVERFLOW;
54674 }
54675 +
54676 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54677 + return 0;
54678 +
54679 buf->result++;
54680 dirent = buf->dirent;
54681 if (!access_ok(VERIFY_WRITE, dirent,
54682 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54683 if (!f.file)
54684 return -EBADF;
54685
54686 + buf.file = f.file;
54687 error = iterate_dir(f.file, &buf.ctx);
54688 if (buf.result)
54689 error = buf.result;
54690 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54691 struct dir_context ctx;
54692 struct compat_linux_dirent __user *current_dir;
54693 struct compat_linux_dirent __user *previous;
54694 + struct file * file;
54695 int count;
54696 int error;
54697 };
54698 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54699 buf->error = -EOVERFLOW;
54700 return -EOVERFLOW;
54701 }
54702 +
54703 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54704 + return 0;
54705 +
54706 dirent = buf->previous;
54707 if (dirent) {
54708 if (__put_user(offset, &dirent->d_off))
54709 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54710 if (!f.file)
54711 return -EBADF;
54712
54713 + buf.file = f.file;
54714 error = iterate_dir(f.file, &buf.ctx);
54715 if (error >= 0)
54716 error = buf.error;
54717 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54718 struct dir_context ctx;
54719 struct linux_dirent64 __user *current_dir;
54720 struct linux_dirent64 __user *previous;
54721 + struct file * file;
54722 int count;
54723 int error;
54724 };
54725 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54726 buf->error = -EINVAL; /* only used if we fail.. */
54727 if (reclen > buf->count)
54728 return -EINVAL;
54729 +
54730 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54731 + return 0;
54732 +
54733 dirent = buf->previous;
54734
54735 if (dirent) {
54736 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54737 if (!f.file)
54738 return -EBADF;
54739
54740 + buf.file = f.file;
54741 error = iterate_dir(f.file, &buf.ctx);
54742 if (error >= 0)
54743 error = buf.error;
54744 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54745 index a81147e..20bf2b5 100644
54746 --- a/fs/compat_binfmt_elf.c
54747 +++ b/fs/compat_binfmt_elf.c
54748 @@ -30,11 +30,13 @@
54749 #undef elf_phdr
54750 #undef elf_shdr
54751 #undef elf_note
54752 +#undef elf_dyn
54753 #undef elf_addr_t
54754 #define elfhdr elf32_hdr
54755 #define elf_phdr elf32_phdr
54756 #define elf_shdr elf32_shdr
54757 #define elf_note elf32_note
54758 +#define elf_dyn Elf32_Dyn
54759 #define elf_addr_t Elf32_Addr
54760
54761 /*
54762 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54763 index 5d19acf..9ab093b 100644
54764 --- a/fs/compat_ioctl.c
54765 +++ b/fs/compat_ioctl.c
54766 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54767 return -EFAULT;
54768 if (__get_user(udata, &ss32->iomem_base))
54769 return -EFAULT;
54770 - ss.iomem_base = compat_ptr(udata);
54771 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54772 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54773 __get_user(ss.port_high, &ss32->port_high))
54774 return -EFAULT;
54775 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54776 for (i = 0; i < nmsgs; i++) {
54777 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54778 return -EFAULT;
54779 - if (get_user(datap, &umsgs[i].buf) ||
54780 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54781 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54782 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54783 return -EFAULT;
54784 }
54785 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54786 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54787 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54788 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54789 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54790 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54791 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54792 return -EFAULT;
54793
54794 return ioctl_preallocate(file, p);
54795 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54796 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54797 {
54798 unsigned int a, b;
54799 - a = *(unsigned int *)p;
54800 - b = *(unsigned int *)q;
54801 + a = *(const unsigned int *)p;
54802 + b = *(const unsigned int *)q;
54803 if (a > b)
54804 return 1;
54805 if (a < b)
54806 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54807 index 511d415..319d0e5 100644
54808 --- a/fs/configfs/dir.c
54809 +++ b/fs/configfs/dir.c
54810 @@ -1558,7 +1558,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54811 }
54812 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54813 struct configfs_dirent *next;
54814 - const char *name;
54815 + const unsigned char * name;
54816 + char d_name[sizeof(next->s_dentry->d_iname)];
54817 int len;
54818 struct inode *inode = NULL;
54819
54820 @@ -1567,7 +1568,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54821 continue;
54822
54823 name = configfs_get_name(next);
54824 - len = strlen(name);
54825 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54826 + len = next->s_dentry->d_name.len;
54827 + memcpy(d_name, name, len);
54828 + name = d_name;
54829 + } else
54830 + len = strlen(name);
54831
54832 /*
54833 * We'll have a dentry and an inode for
54834 diff --git a/fs/coredump.c b/fs/coredump.c
54835 index 9bdeca1..2247b92 100644
54836 --- a/fs/coredump.c
54837 +++ b/fs/coredump.c
54838 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
54839 struct pipe_inode_info *pipe = file->private_data;
54840
54841 pipe_lock(pipe);
54842 - pipe->readers++;
54843 - pipe->writers--;
54844 + atomic_inc(&pipe->readers);
54845 + atomic_dec(&pipe->writers);
54846 wake_up_interruptible_sync(&pipe->wait);
54847 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54848 pipe_unlock(pipe);
54849 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
54850 * We actually want wait_event_freezable() but then we need
54851 * to clear TIF_SIGPENDING and improve dump_interrupted().
54852 */
54853 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54854 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54855
54856 pipe_lock(pipe);
54857 - pipe->readers--;
54858 - pipe->writers++;
54859 + atomic_dec(&pipe->readers);
54860 + atomic_inc(&pipe->writers);
54861 pipe_unlock(pipe);
54862 }
54863
54864 @@ -499,7 +499,8 @@ void do_coredump(siginfo_t *siginfo)
54865 struct files_struct *displaced;
54866 bool need_nonrelative = false;
54867 bool core_dumped = false;
54868 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54869 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54870 + long signr = siginfo->si_signo;
54871 struct coredump_params cprm = {
54872 .siginfo = siginfo,
54873 .regs = signal_pt_regs(),
54874 @@ -512,7 +513,10 @@ void do_coredump(siginfo_t *siginfo)
54875 .mm_flags = mm->flags,
54876 };
54877
54878 - audit_core_dumps(siginfo->si_signo);
54879 + audit_core_dumps(signr);
54880 +
54881 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54882 + gr_handle_brute_attach(cprm.mm_flags);
54883
54884 binfmt = mm->binfmt;
54885 if (!binfmt || !binfmt->core_dump)
54886 @@ -536,7 +540,7 @@ void do_coredump(siginfo_t *siginfo)
54887 need_nonrelative = true;
54888 }
54889
54890 - retval = coredump_wait(siginfo->si_signo, &core_state);
54891 + retval = coredump_wait(signr, &core_state);
54892 if (retval < 0)
54893 goto fail_creds;
54894
54895 @@ -579,7 +583,7 @@ void do_coredump(siginfo_t *siginfo)
54896 }
54897 cprm.limit = RLIM_INFINITY;
54898
54899 - dump_count = atomic_inc_return(&core_dump_count);
54900 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54901 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54902 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54903 task_tgid_vnr(current), current->comm);
54904 @@ -611,6 +615,8 @@ void do_coredump(siginfo_t *siginfo)
54905 } else {
54906 struct inode *inode;
54907
54908 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54909 +
54910 if (cprm.limit < binfmt->min_coredump)
54911 goto fail_unlock;
54912
54913 @@ -669,7 +675,7 @@ close_fail:
54914 filp_close(cprm.file, NULL);
54915 fail_dropcount:
54916 if (ispipe)
54917 - atomic_dec(&core_dump_count);
54918 + atomic_dec_unchecked(&core_dump_count);
54919 fail_unlock:
54920 kfree(cn.corename);
54921 coredump_finish(mm, core_dumped);
54922 @@ -689,7 +695,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54923 {
54924 return !dump_interrupted() &&
54925 access_ok(VERIFY_READ, addr, nr) &&
54926 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54927 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54928 }
54929 EXPORT_SYMBOL(dump_write);
54930
54931 diff --git a/fs/dcache.c b/fs/dcache.c
54932 index 89f9671..5977a84 100644
54933 --- a/fs/dcache.c
54934 +++ b/fs/dcache.c
54935 @@ -2893,6 +2893,7 @@ static int prepend_path(const struct path *path,
54936 restart:
54937 bptr = *buffer;
54938 blen = *buflen;
54939 + error = 0;
54940 dentry = path->dentry;
54941 vfsmnt = path->mnt;
54942 mnt = real_mount(vfsmnt);
54943 @@ -3432,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
54944 mempages -= reserve;
54945
54946 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54947 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54948 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54949 + SLAB_NO_SANITIZE, NULL);
54950
54951 dcache_init();
54952 inode_init();
54953 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54954 index c7c83ff..bda9461 100644
54955 --- a/fs/debugfs/inode.c
54956 +++ b/fs/debugfs/inode.c
54957 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54958 */
54959 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54960 {
54961 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54962 + return __create_file(name, S_IFDIR | S_IRWXU,
54963 +#else
54964 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54965 +#endif
54966 parent, NULL, NULL);
54967 }
54968 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54969 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54970 index 67e9b63..a9adb68 100644
54971 --- a/fs/ecryptfs/inode.c
54972 +++ b/fs/ecryptfs/inode.c
54973 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54974 old_fs = get_fs();
54975 set_fs(get_ds());
54976 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54977 - (char __user *)lower_buf,
54978 + (char __force_user *)lower_buf,
54979 PATH_MAX);
54980 set_fs(old_fs);
54981 if (rc < 0)
54982 @@ -706,7 +706,7 @@ out:
54983 static void
54984 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54985 {
54986 - char *buf = nd_get_link(nd);
54987 + const char *buf = nd_get_link(nd);
54988 if (!IS_ERR(buf)) {
54989 /* Free the char* */
54990 kfree(buf);
54991 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54992 index e4141f2..d8263e8 100644
54993 --- a/fs/ecryptfs/miscdev.c
54994 +++ b/fs/ecryptfs/miscdev.c
54995 @@ -304,7 +304,7 @@ check_list:
54996 goto out_unlock_msg_ctx;
54997 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54998 if (msg_ctx->msg) {
54999 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55000 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55001 goto out_unlock_msg_ctx;
55002 i += packet_length_size;
55003 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55004 diff --git a/fs/exec.c b/fs/exec.c
55005 index bb8afc1..2f5087e 100644
55006 --- a/fs/exec.c
55007 +++ b/fs/exec.c
55008 @@ -55,8 +55,20 @@
55009 #include <linux/pipe_fs_i.h>
55010 #include <linux/oom.h>
55011 #include <linux/compat.h>
55012 +#include <linux/random.h>
55013 +#include <linux/seq_file.h>
55014 +#include <linux/coredump.h>
55015 +#include <linux/mman.h>
55016 +
55017 +#ifdef CONFIG_PAX_REFCOUNT
55018 +#include <linux/kallsyms.h>
55019 +#include <linux/kdebug.h>
55020 +#endif
55021 +
55022 +#include <trace/events/fs.h>
55023
55024 #include <asm/uaccess.h>
55025 +#include <asm/sections.h>
55026 #include <asm/mmu_context.h>
55027 #include <asm/tlb.h>
55028
55029 @@ -66,19 +78,34 @@
55030
55031 #include <trace/events/sched.h>
55032
55033 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55034 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55035 +{
55036 + 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");
55037 +}
55038 +#endif
55039 +
55040 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55041 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55042 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55043 +#endif
55044 +
55045 int suid_dumpable = 0;
55046
55047 static LIST_HEAD(formats);
55048 static DEFINE_RWLOCK(binfmt_lock);
55049
55050 +extern int gr_process_kernel_exec_ban(void);
55051 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55052 +
55053 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55054 {
55055 BUG_ON(!fmt);
55056 if (WARN_ON(!fmt->load_binary))
55057 return;
55058 write_lock(&binfmt_lock);
55059 - insert ? list_add(&fmt->lh, &formats) :
55060 - list_add_tail(&fmt->lh, &formats);
55061 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55062 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55063 write_unlock(&binfmt_lock);
55064 }
55065
55066 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55067 void unregister_binfmt(struct linux_binfmt * fmt)
55068 {
55069 write_lock(&binfmt_lock);
55070 - list_del(&fmt->lh);
55071 + pax_list_del((struct list_head *)&fmt->lh);
55072 write_unlock(&binfmt_lock);
55073 }
55074
55075 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55076 int write)
55077 {
55078 struct page *page;
55079 - int ret;
55080
55081 -#ifdef CONFIG_STACK_GROWSUP
55082 - if (write) {
55083 - ret = expand_downwards(bprm->vma, pos);
55084 - if (ret < 0)
55085 - return NULL;
55086 - }
55087 -#endif
55088 - ret = get_user_pages(current, bprm->mm, pos,
55089 - 1, write, 1, &page, NULL);
55090 - if (ret <= 0)
55091 + if (0 > expand_downwards(bprm->vma, pos))
55092 + return NULL;
55093 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55094 return NULL;
55095
55096 if (write) {
55097 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55098 if (size <= ARG_MAX)
55099 return page;
55100
55101 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55102 + // only allow 512KB for argv+env on suid/sgid binaries
55103 + // to prevent easy ASLR exhaustion
55104 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55105 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55106 + (size > (512 * 1024))) {
55107 + put_page(page);
55108 + return NULL;
55109 + }
55110 +#endif
55111 +
55112 /*
55113 * Limit to 1/4-th the stack size for the argv+env strings.
55114 * This ensures that:
55115 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55116 vma->vm_end = STACK_TOP_MAX;
55117 vma->vm_start = vma->vm_end - PAGE_SIZE;
55118 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55119 +
55120 +#ifdef CONFIG_PAX_SEGMEXEC
55121 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55122 +#endif
55123 +
55124 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55125 INIT_LIST_HEAD(&vma->anon_vma_chain);
55126
55127 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55128 mm->stack_vm = mm->total_vm = 1;
55129 up_write(&mm->mmap_sem);
55130 bprm->p = vma->vm_end - sizeof(void *);
55131 +
55132 +#ifdef CONFIG_PAX_RANDUSTACK
55133 + if (randomize_va_space)
55134 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55135 +#endif
55136 +
55137 return 0;
55138 err:
55139 up_write(&mm->mmap_sem);
55140 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55141 } ptr;
55142 };
55143
55144 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55145 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55146 {
55147 const char __user *native;
55148
55149 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55150 compat_uptr_t compat;
55151
55152 if (get_user(compat, argv.ptr.compat + nr))
55153 - return ERR_PTR(-EFAULT);
55154 + return (const char __force_user *)ERR_PTR(-EFAULT);
55155
55156 return compat_ptr(compat);
55157 }
55158 #endif
55159
55160 if (get_user(native, argv.ptr.native + nr))
55161 - return ERR_PTR(-EFAULT);
55162 + return (const char __force_user *)ERR_PTR(-EFAULT);
55163
55164 return native;
55165 }
55166 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55167 if (!p)
55168 break;
55169
55170 - if (IS_ERR(p))
55171 + if (IS_ERR((const char __force_kernel *)p))
55172 return -EFAULT;
55173
55174 if (i >= max)
55175 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55176
55177 ret = -EFAULT;
55178 str = get_user_arg_ptr(argv, argc);
55179 - if (IS_ERR(str))
55180 + if (IS_ERR((const char __force_kernel *)str))
55181 goto out;
55182
55183 len = strnlen_user(str, MAX_ARG_STRLEN);
55184 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55185 int r;
55186 mm_segment_t oldfs = get_fs();
55187 struct user_arg_ptr argv = {
55188 - .ptr.native = (const char __user *const __user *)__argv,
55189 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55190 };
55191
55192 set_fs(KERNEL_DS);
55193 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55194 unsigned long new_end = old_end - shift;
55195 struct mmu_gather tlb;
55196
55197 - BUG_ON(new_start > new_end);
55198 + if (new_start >= new_end || new_start < mmap_min_addr)
55199 + return -ENOMEM;
55200
55201 /*
55202 * ensure there are no vmas between where we want to go
55203 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55204 if (vma != find_vma(mm, new_start))
55205 return -EFAULT;
55206
55207 +#ifdef CONFIG_PAX_SEGMEXEC
55208 + BUG_ON(pax_find_mirror_vma(vma));
55209 +#endif
55210 +
55211 /*
55212 * cover the whole range: [new_start, old_end)
55213 */
55214 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55215 stack_top = arch_align_stack(stack_top);
55216 stack_top = PAGE_ALIGN(stack_top);
55217
55218 - if (unlikely(stack_top < mmap_min_addr) ||
55219 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55220 - return -ENOMEM;
55221 -
55222 stack_shift = vma->vm_end - stack_top;
55223
55224 bprm->p -= stack_shift;
55225 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55226 bprm->exec -= stack_shift;
55227
55228 down_write(&mm->mmap_sem);
55229 +
55230 + /* Move stack pages down in memory. */
55231 + if (stack_shift) {
55232 + ret = shift_arg_pages(vma, stack_shift);
55233 + if (ret)
55234 + goto out_unlock;
55235 + }
55236 +
55237 vm_flags = VM_STACK_FLAGS;
55238
55239 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55240 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55241 + vm_flags &= ~VM_EXEC;
55242 +
55243 +#ifdef CONFIG_PAX_MPROTECT
55244 + if (mm->pax_flags & MF_PAX_MPROTECT)
55245 + vm_flags &= ~VM_MAYEXEC;
55246 +#endif
55247 +
55248 + }
55249 +#endif
55250 +
55251 /*
55252 * Adjust stack execute permissions; explicitly enable for
55253 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55254 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55255 goto out_unlock;
55256 BUG_ON(prev != vma);
55257
55258 - /* Move stack pages down in memory. */
55259 - if (stack_shift) {
55260 - ret = shift_arg_pages(vma, stack_shift);
55261 - if (ret)
55262 - goto out_unlock;
55263 - }
55264 -
55265 /* mprotect_fixup is overkill to remove the temporary stack flags */
55266 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55267
55268 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55269 #endif
55270 current->mm->start_stack = bprm->p;
55271 ret = expand_stack(vma, stack_base);
55272 +
55273 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55274 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55275 + unsigned long size;
55276 + vm_flags_t vm_flags;
55277 +
55278 + size = STACK_TOP - vma->vm_end;
55279 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55280 +
55281 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55282 +
55283 +#ifdef CONFIG_X86
55284 + if (!ret) {
55285 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55286 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55287 + }
55288 +#endif
55289 +
55290 + }
55291 +#endif
55292 +
55293 if (ret)
55294 ret = -EFAULT;
55295
55296 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
55297
55298 fsnotify_open(file);
55299
55300 + trace_open_exec(name);
55301 +
55302 err = deny_write_access(file);
55303 if (err)
55304 goto exit;
55305 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
55306 old_fs = get_fs();
55307 set_fs(get_ds());
55308 /* The cast to a user pointer is valid due to the set_fs() */
55309 - result = vfs_read(file, (void __user *)addr, count, &pos);
55310 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55311 set_fs(old_fs);
55312 return result;
55313 }
55314 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55315 }
55316 rcu_read_unlock();
55317
55318 - if (p->fs->users > n_fs) {
55319 + if (atomic_read(&p->fs->users) > n_fs) {
55320 bprm->unsafe |= LSM_UNSAFE_SHARE;
55321 } else {
55322 res = -EAGAIN;
55323 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
55324 return ret;
55325 }
55326
55327 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55328 +static DEFINE_PER_CPU(u64, exec_counter);
55329 +static int __init init_exec_counters(void)
55330 +{
55331 + unsigned int cpu;
55332 +
55333 + for_each_possible_cpu(cpu) {
55334 + per_cpu(exec_counter, cpu) = (u64)cpu;
55335 + }
55336 +
55337 + return 0;
55338 +}
55339 +early_initcall(init_exec_counters);
55340 +static inline void increment_exec_counter(void)
55341 +{
55342 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55343 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55344 +}
55345 +#else
55346 +static inline void increment_exec_counter(void) {}
55347 +#endif
55348 +
55349 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55350 + struct user_arg_ptr argv);
55351 +
55352 /*
55353 * sys_execve() executes a new program.
55354 */
55355 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
55356 struct user_arg_ptr argv,
55357 struct user_arg_ptr envp)
55358 {
55359 +#ifdef CONFIG_GRKERNSEC
55360 + struct file *old_exec_file;
55361 + struct acl_subject_label *old_acl;
55362 + struct rlimit old_rlim[RLIM_NLIMITS];
55363 +#endif
55364 struct linux_binprm *bprm;
55365 struct file *file;
55366 struct files_struct *displaced;
55367 bool clear_in_exec;
55368 int retval;
55369
55370 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55371 +
55372 /*
55373 * We move the actual failure in case of RLIMIT_NPROC excess from
55374 * set*uid() to execve() because too many poorly written programs
55375 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
55376 if (IS_ERR(file))
55377 goto out_unmark;
55378
55379 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55380 + retval = -EPERM;
55381 + goto out_file;
55382 + }
55383 +
55384 sched_exec();
55385
55386 bprm->file = file;
55387 bprm->filename = filename;
55388 bprm->interp = filename;
55389
55390 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55391 + retval = -EACCES;
55392 + goto out_file;
55393 + }
55394 +
55395 retval = bprm_mm_init(bprm);
55396 if (retval)
55397 goto out_file;
55398 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
55399 if (retval < 0)
55400 goto out;
55401
55402 +#ifdef CONFIG_GRKERNSEC
55403 + old_acl = current->acl;
55404 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55405 + old_exec_file = current->exec_file;
55406 + get_file(file);
55407 + current->exec_file = file;
55408 +#endif
55409 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55410 + /* limit suid stack to 8MB
55411 + * we saved the old limits above and will restore them if this exec fails
55412 + */
55413 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55414 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55415 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55416 +#endif
55417 +
55418 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55419 + retval = -EPERM;
55420 + goto out_fail;
55421 + }
55422 +
55423 + if (!gr_tpe_allow(file)) {
55424 + retval = -EACCES;
55425 + goto out_fail;
55426 + }
55427 +
55428 + if (gr_check_crash_exec(file)) {
55429 + retval = -EACCES;
55430 + goto out_fail;
55431 + }
55432 +
55433 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55434 + bprm->unsafe);
55435 + if (retval < 0)
55436 + goto out_fail;
55437 +
55438 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55439 if (retval < 0)
55440 - goto out;
55441 + goto out_fail;
55442
55443 bprm->exec = bprm->p;
55444 retval = copy_strings(bprm->envc, envp, bprm);
55445 if (retval < 0)
55446 - goto out;
55447 + goto out_fail;
55448
55449 retval = copy_strings(bprm->argc, argv, bprm);
55450 if (retval < 0)
55451 - goto out;
55452 + goto out_fail;
55453 +
55454 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55455 +
55456 + gr_handle_exec_args(bprm, argv);
55457
55458 retval = exec_binprm(bprm);
55459 if (retval < 0)
55460 - goto out;
55461 + goto out_fail;
55462 +#ifdef CONFIG_GRKERNSEC
55463 + if (old_exec_file)
55464 + fput(old_exec_file);
55465 +#endif
55466
55467 /* execve succeeded */
55468 +
55469 + increment_exec_counter();
55470 current->fs->in_exec = 0;
55471 current->in_execve = 0;
55472 acct_update_integrals(current);
55473 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
55474 put_files_struct(displaced);
55475 return retval;
55476
55477 +out_fail:
55478 +#ifdef CONFIG_GRKERNSEC
55479 + current->acl = old_acl;
55480 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55481 + fput(current->exec_file);
55482 + current->exec_file = old_exec_file;
55483 +#endif
55484 +
55485 out:
55486 if (bprm->mm) {
55487 acct_arg_size(bprm, 0);
55488 @@ -1706,3 +1880,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55489 return error;
55490 }
55491 #endif
55492 +
55493 +int pax_check_flags(unsigned long *flags)
55494 +{
55495 + int retval = 0;
55496 +
55497 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55498 + if (*flags & MF_PAX_SEGMEXEC)
55499 + {
55500 + *flags &= ~MF_PAX_SEGMEXEC;
55501 + retval = -EINVAL;
55502 + }
55503 +#endif
55504 +
55505 + if ((*flags & MF_PAX_PAGEEXEC)
55506 +
55507 +#ifdef CONFIG_PAX_PAGEEXEC
55508 + && (*flags & MF_PAX_SEGMEXEC)
55509 +#endif
55510 +
55511 + )
55512 + {
55513 + *flags &= ~MF_PAX_PAGEEXEC;
55514 + retval = -EINVAL;
55515 + }
55516 +
55517 + if ((*flags & MF_PAX_MPROTECT)
55518 +
55519 +#ifdef CONFIG_PAX_MPROTECT
55520 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55521 +#endif
55522 +
55523 + )
55524 + {
55525 + *flags &= ~MF_PAX_MPROTECT;
55526 + retval = -EINVAL;
55527 + }
55528 +
55529 + if ((*flags & MF_PAX_EMUTRAMP)
55530 +
55531 +#ifdef CONFIG_PAX_EMUTRAMP
55532 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55533 +#endif
55534 +
55535 + )
55536 + {
55537 + *flags &= ~MF_PAX_EMUTRAMP;
55538 + retval = -EINVAL;
55539 + }
55540 +
55541 + return retval;
55542 +}
55543 +
55544 +EXPORT_SYMBOL(pax_check_flags);
55545 +
55546 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55547 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55548 +{
55549 + char *pathname = d_path(path, buf, buflen);
55550 +
55551 + if (IS_ERR(pathname))
55552 + goto toolong;
55553 +
55554 + pathname = mangle_path(buf, pathname, "\t\n\\");
55555 + if (!pathname)
55556 + goto toolong;
55557 +
55558 + *pathname = 0;
55559 + return buf;
55560 +
55561 +toolong:
55562 + return "<path too long>";
55563 +}
55564 +EXPORT_SYMBOL(pax_get_path);
55565 +
55566 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55567 +{
55568 + struct task_struct *tsk = current;
55569 + struct mm_struct *mm = current->mm;
55570 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55571 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55572 + char *path_exec = NULL;
55573 + char *path_fault = NULL;
55574 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55575 + siginfo_t info = { };
55576 +
55577 + if (buffer_exec && buffer_fault) {
55578 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55579 +
55580 + down_read(&mm->mmap_sem);
55581 + vma = mm->mmap;
55582 + while (vma && (!vma_exec || !vma_fault)) {
55583 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55584 + vma_exec = vma;
55585 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55586 + vma_fault = vma;
55587 + vma = vma->vm_next;
55588 + }
55589 + if (vma_exec)
55590 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55591 + if (vma_fault) {
55592 + start = vma_fault->vm_start;
55593 + end = vma_fault->vm_end;
55594 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55595 + if (vma_fault->vm_file)
55596 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55597 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55598 + path_fault = "<heap>";
55599 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55600 + path_fault = "<stack>";
55601 + else
55602 + path_fault = "<anonymous mapping>";
55603 + }
55604 + up_read(&mm->mmap_sem);
55605 + }
55606 + if (tsk->signal->curr_ip)
55607 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55608 + else
55609 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55610 + 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),
55611 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55612 + free_page((unsigned long)buffer_exec);
55613 + free_page((unsigned long)buffer_fault);
55614 + pax_report_insns(regs, pc, sp);
55615 + info.si_signo = SIGKILL;
55616 + info.si_errno = 0;
55617 + info.si_code = SI_KERNEL;
55618 + info.si_pid = 0;
55619 + info.si_uid = 0;
55620 + do_coredump(&info);
55621 +}
55622 +#endif
55623 +
55624 +#ifdef CONFIG_PAX_REFCOUNT
55625 +void pax_report_refcount_overflow(struct pt_regs *regs)
55626 +{
55627 + if (current->signal->curr_ip)
55628 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55629 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55630 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55631 + else
55632 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55633 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55634 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55635 + preempt_disable();
55636 + show_regs(regs);
55637 + preempt_enable();
55638 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55639 +}
55640 +#endif
55641 +
55642 +#ifdef CONFIG_PAX_USERCOPY
55643 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55644 +static noinline int check_stack_object(const void *obj, unsigned long len)
55645 +{
55646 + const void * const stack = task_stack_page(current);
55647 + const void * const stackend = stack + THREAD_SIZE;
55648 +
55649 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55650 + const void *frame = NULL;
55651 + const void *oldframe;
55652 +#endif
55653 +
55654 + if (obj + len < obj)
55655 + return -1;
55656 +
55657 + if (obj + len <= stack || stackend <= obj)
55658 + return 0;
55659 +
55660 + if (obj < stack || stackend < obj + len)
55661 + return -1;
55662 +
55663 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55664 + oldframe = __builtin_frame_address(1);
55665 + if (oldframe)
55666 + frame = __builtin_frame_address(2);
55667 + /*
55668 + low ----------------------------------------------> high
55669 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55670 + ^----------------^
55671 + allow copies only within here
55672 + */
55673 + while (stack <= frame && frame < stackend) {
55674 + /* if obj + len extends past the last frame, this
55675 + check won't pass and the next frame will be 0,
55676 + causing us to bail out and correctly report
55677 + the copy as invalid
55678 + */
55679 + if (obj + len <= frame)
55680 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55681 + oldframe = frame;
55682 + frame = *(const void * const *)frame;
55683 + }
55684 + return -1;
55685 +#else
55686 + return 1;
55687 +#endif
55688 +}
55689 +
55690 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55691 +{
55692 + if (current->signal->curr_ip)
55693 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55694 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55695 + else
55696 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55697 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55698 + dump_stack();
55699 + gr_handle_kernel_exploit();
55700 + do_group_exit(SIGKILL);
55701 +}
55702 +#endif
55703 +
55704 +#ifdef CONFIG_PAX_USERCOPY
55705 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55706 +{
55707 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55708 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55709 +#ifdef CONFIG_MODULES
55710 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55711 +#else
55712 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55713 +#endif
55714 +
55715 +#else
55716 + unsigned long textlow = (unsigned long)_stext;
55717 + unsigned long texthigh = (unsigned long)_etext;
55718 +
55719 +#ifdef CONFIG_X86_64
55720 + /* check against linear mapping as well */
55721 + if (high > (unsigned long)__va(__pa(textlow)) &&
55722 + low <= (unsigned long)__va(__pa(texthigh)))
55723 + return true;
55724 +#endif
55725 +
55726 +#endif
55727 +
55728 + if (high <= textlow || low > texthigh)
55729 + return false;
55730 + else
55731 + return true;
55732 +}
55733 +#endif
55734 +
55735 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55736 +{
55737 +
55738 +#ifdef CONFIG_PAX_USERCOPY
55739 + const char *type;
55740 +
55741 + if (!n)
55742 + return;
55743 +
55744 + type = check_heap_object(ptr, n);
55745 + if (!type) {
55746 + int ret = check_stack_object(ptr, n);
55747 + if (ret == 1 || ret == 2)
55748 + return;
55749 + if (ret == 0) {
55750 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55751 + type = "<kernel text>";
55752 + else
55753 + return;
55754 + } else
55755 + type = "<process stack>";
55756 + }
55757 +
55758 + pax_report_usercopy(ptr, n, to_user, type);
55759 +#endif
55760 +
55761 +}
55762 +EXPORT_SYMBOL(__check_object_size);
55763 +
55764 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55765 +void pax_track_stack(void)
55766 +{
55767 + unsigned long sp = (unsigned long)&sp;
55768 + if (sp < current_thread_info()->lowest_stack &&
55769 + sp > (unsigned long)task_stack_page(current))
55770 + current_thread_info()->lowest_stack = sp;
55771 +}
55772 +EXPORT_SYMBOL(pax_track_stack);
55773 +#endif
55774 +
55775 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55776 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55777 +{
55778 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55779 + dump_stack();
55780 + do_group_exit(SIGKILL);
55781 +}
55782 +EXPORT_SYMBOL(report_size_overflow);
55783 +#endif
55784 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55785 index 9f9992b..8b59411 100644
55786 --- a/fs/ext2/balloc.c
55787 +++ b/fs/ext2/balloc.c
55788 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55789
55790 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55791 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55792 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55793 + if (free_blocks < root_blocks + 1 &&
55794 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55795 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55796 - !in_group_p (sbi->s_resgid))) {
55797 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55798 return 0;
55799 }
55800 return 1;
55801 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
55802 index 2d7557d..14e38f94 100644
55803 --- a/fs/ext2/xattr.c
55804 +++ b/fs/ext2/xattr.c
55805 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
55806 struct buffer_head *bh = NULL;
55807 struct ext2_xattr_entry *entry;
55808 char *end;
55809 - size_t rest = buffer_size;
55810 + size_t rest = buffer_size, total_size = 0;
55811 int error;
55812
55813 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
55814 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
55815 buffer += size;
55816 }
55817 rest -= size;
55818 + total_size += size;
55819 }
55820 }
55821 - error = buffer_size - rest; /* total size */
55822 + error = total_size;
55823
55824 cleanup:
55825 brelse(bh);
55826 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55827 index 22548f5..41521d8 100644
55828 --- a/fs/ext3/balloc.c
55829 +++ b/fs/ext3/balloc.c
55830 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55831
55832 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55833 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55834 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55835 + if (free_blocks < root_blocks + 1 &&
55836 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55837 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55838 - !in_group_p (sbi->s_resgid))) {
55839 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55840 return 0;
55841 }
55842 return 1;
55843 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
55844 index b1fc963..881228c 100644
55845 --- a/fs/ext3/xattr.c
55846 +++ b/fs/ext3/xattr.c
55847 @@ -330,7 +330,7 @@ static int
55848 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55849 char *buffer, size_t buffer_size)
55850 {
55851 - size_t rest = buffer_size;
55852 + size_t rest = buffer_size, total_size = 0;
55853
55854 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
55855 const struct xattr_handler *handler =
55856 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55857 buffer += size;
55858 }
55859 rest -= size;
55860 + total_size += size;
55861 }
55862 }
55863 - return buffer_size - rest;
55864 + return total_size;
55865 }
55866
55867 static int
55868 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55869 index dc5d572..4c21f8e 100644
55870 --- a/fs/ext4/balloc.c
55871 +++ b/fs/ext4/balloc.c
55872 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55873 /* Hm, nope. Are (enough) root reserved clusters available? */
55874 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55875 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55876 - capable(CAP_SYS_RESOURCE) ||
55877 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55878 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55879 + capable_nolog(CAP_SYS_RESOURCE)) {
55880
55881 if (free_clusters >= (nclusters + dirty_clusters +
55882 resv_clusters))
55883 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55884 index af815ea..99294a6 100644
55885 --- a/fs/ext4/ext4.h
55886 +++ b/fs/ext4/ext4.h
55887 @@ -1256,19 +1256,19 @@ struct ext4_sb_info {
55888 unsigned long s_mb_last_start;
55889
55890 /* stats for buddy allocator */
55891 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55892 - atomic_t s_bal_success; /* we found long enough chunks */
55893 - atomic_t s_bal_allocated; /* in blocks */
55894 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55895 - atomic_t s_bal_goals; /* goal hits */
55896 - atomic_t s_bal_breaks; /* too long searches */
55897 - atomic_t s_bal_2orders; /* 2^order hits */
55898 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55899 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55900 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55901 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55902 + atomic_unchecked_t s_bal_goals; /* goal hits */
55903 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55904 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55905 spinlock_t s_bal_lock;
55906 unsigned long s_mb_buddies_generated;
55907 unsigned long long s_mb_generation_time;
55908 - atomic_t s_mb_lost_chunks;
55909 - atomic_t s_mb_preallocated;
55910 - atomic_t s_mb_discarded;
55911 + atomic_unchecked_t s_mb_lost_chunks;
55912 + atomic_unchecked_t s_mb_preallocated;
55913 + atomic_unchecked_t s_mb_discarded;
55914 atomic_t s_lock_busy;
55915
55916 /* locality groups */
55917 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55918 index a41e3ba..e574a00 100644
55919 --- a/fs/ext4/mballoc.c
55920 +++ b/fs/ext4/mballoc.c
55921 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55922 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55923
55924 if (EXT4_SB(sb)->s_mb_stats)
55925 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55926 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55927
55928 break;
55929 }
55930 @@ -2189,7 +2189,7 @@ repeat:
55931 ac->ac_status = AC_STATUS_CONTINUE;
55932 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55933 cr = 3;
55934 - atomic_inc(&sbi->s_mb_lost_chunks);
55935 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55936 goto repeat;
55937 }
55938 }
55939 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
55940 if (sbi->s_mb_stats) {
55941 ext4_msg(sb, KERN_INFO,
55942 "mballoc: %u blocks %u reqs (%u success)",
55943 - atomic_read(&sbi->s_bal_allocated),
55944 - atomic_read(&sbi->s_bal_reqs),
55945 - atomic_read(&sbi->s_bal_success));
55946 + atomic_read_unchecked(&sbi->s_bal_allocated),
55947 + atomic_read_unchecked(&sbi->s_bal_reqs),
55948 + atomic_read_unchecked(&sbi->s_bal_success));
55949 ext4_msg(sb, KERN_INFO,
55950 "mballoc: %u extents scanned, %u goal hits, "
55951 "%u 2^N hits, %u breaks, %u lost",
55952 - atomic_read(&sbi->s_bal_ex_scanned),
55953 - atomic_read(&sbi->s_bal_goals),
55954 - atomic_read(&sbi->s_bal_2orders),
55955 - atomic_read(&sbi->s_bal_breaks),
55956 - atomic_read(&sbi->s_mb_lost_chunks));
55957 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55958 + atomic_read_unchecked(&sbi->s_bal_goals),
55959 + atomic_read_unchecked(&sbi->s_bal_2orders),
55960 + atomic_read_unchecked(&sbi->s_bal_breaks),
55961 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55962 ext4_msg(sb, KERN_INFO,
55963 "mballoc: %lu generated and it took %Lu",
55964 sbi->s_mb_buddies_generated,
55965 sbi->s_mb_generation_time);
55966 ext4_msg(sb, KERN_INFO,
55967 "mballoc: %u preallocated, %u discarded",
55968 - atomic_read(&sbi->s_mb_preallocated),
55969 - atomic_read(&sbi->s_mb_discarded));
55970 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55971 + atomic_read_unchecked(&sbi->s_mb_discarded));
55972 }
55973
55974 free_percpu(sbi->s_locality_groups);
55975 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55976 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55977
55978 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55979 - atomic_inc(&sbi->s_bal_reqs);
55980 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55981 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55982 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55983 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55984 - atomic_inc(&sbi->s_bal_success);
55985 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55986 + atomic_inc_unchecked(&sbi->s_bal_success);
55987 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55988 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55989 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55990 - atomic_inc(&sbi->s_bal_goals);
55991 + atomic_inc_unchecked(&sbi->s_bal_goals);
55992 if (ac->ac_found > sbi->s_mb_max_to_scan)
55993 - atomic_inc(&sbi->s_bal_breaks);
55994 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55995 }
55996
55997 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55998 @@ -3578,7 +3578,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55999 trace_ext4_mb_new_inode_pa(ac, pa);
56000
56001 ext4_mb_use_inode_pa(ac, pa);
56002 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56003 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56004
56005 ei = EXT4_I(ac->ac_inode);
56006 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56007 @@ -3638,7 +3638,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56008 trace_ext4_mb_new_group_pa(ac, pa);
56009
56010 ext4_mb_use_group_pa(ac, pa);
56011 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56012 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56013
56014 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56015 lg = ac->ac_lg;
56016 @@ -3727,7 +3727,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56017 * from the bitmap and continue.
56018 */
56019 }
56020 - atomic_add(free, &sbi->s_mb_discarded);
56021 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56022
56023 return err;
56024 }
56025 @@ -3745,7 +3745,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56026 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56027 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56028 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56029 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56030 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56031 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56032
56033 return 0;
56034 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56035 index 214461e..3614c89 100644
56036 --- a/fs/ext4/mmp.c
56037 +++ b/fs/ext4/mmp.c
56038 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56039 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56040 const char *function, unsigned int line, const char *msg)
56041 {
56042 - __ext4_warning(sb, function, line, msg);
56043 + __ext4_warning(sb, function, line, "%s", msg);
56044 __ext4_warning(sb, function, line,
56045 "MMP failure info: last update time: %llu, last update "
56046 "node: %s, last update device: %s\n",
56047 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56048 index 2c2e6cb..7c3ee62 100644
56049 --- a/fs/ext4/super.c
56050 +++ b/fs/ext4/super.c
56051 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56052 }
56053
56054 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56055 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56056 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56057 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56058
56059 #ifdef CONFIG_QUOTA
56060 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56061 int offset;
56062 int deprecated_val;
56063 } u;
56064 -};
56065 +} __do_const;
56066
56067 static int parse_strtoull(const char *buf,
56068 unsigned long long max, unsigned long long *value)
56069 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56070 index 03e9beb..e86ce98 100644
56071 --- a/fs/ext4/xattr.c
56072 +++ b/fs/ext4/xattr.c
56073 @@ -381,7 +381,7 @@ static int
56074 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56075 char *buffer, size_t buffer_size)
56076 {
56077 - size_t rest = buffer_size;
56078 + size_t rest = buffer_size, total_size = 0;
56079
56080 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56081 const struct xattr_handler *handler =
56082 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56083 buffer += size;
56084 }
56085 rest -= size;
56086 + total_size += size;
56087 }
56088 }
56089 - return buffer_size - rest;
56090 + return total_size;
56091 }
56092
56093 static int
56094 diff --git a/fs/fcntl.c b/fs/fcntl.c
56095 index 65343c3..9969dcf 100644
56096 --- a/fs/fcntl.c
56097 +++ b/fs/fcntl.c
56098 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56099 if (err)
56100 return err;
56101
56102 + if (gr_handle_chroot_fowner(pid, type))
56103 + return -ENOENT;
56104 + if (gr_check_protected_task_fowner(pid, type))
56105 + return -EACCES;
56106 +
56107 f_modown(filp, pid, type, force);
56108 return 0;
56109 }
56110 diff --git a/fs/fhandle.c b/fs/fhandle.c
56111 index 999ff5c..41f4109 100644
56112 --- a/fs/fhandle.c
56113 +++ b/fs/fhandle.c
56114 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56115 } else
56116 retval = 0;
56117 /* copy the mount id */
56118 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56119 - sizeof(*mnt_id)) ||
56120 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56121 copy_to_user(ufh, handle,
56122 sizeof(struct file_handle) + handle_bytes))
56123 retval = -EFAULT;
56124 diff --git a/fs/file.c b/fs/file.c
56125 index 4a78f98..9447397 100644
56126 --- a/fs/file.c
56127 +++ b/fs/file.c
56128 @@ -16,6 +16,7 @@
56129 #include <linux/slab.h>
56130 #include <linux/vmalloc.h>
56131 #include <linux/file.h>
56132 +#include <linux/security.h>
56133 #include <linux/fdtable.h>
56134 #include <linux/bitops.h>
56135 #include <linux/interrupt.h>
56136 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56137 if (!file)
56138 return __close_fd(files, fd);
56139
56140 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56141 if (fd >= rlimit(RLIMIT_NOFILE))
56142 return -EBADF;
56143
56144 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56145 if (unlikely(oldfd == newfd))
56146 return -EINVAL;
56147
56148 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56149 if (newfd >= rlimit(RLIMIT_NOFILE))
56150 return -EBADF;
56151
56152 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56153 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56154 {
56155 int err;
56156 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56157 if (from >= rlimit(RLIMIT_NOFILE))
56158 return -EINVAL;
56159 err = alloc_fd(from, flags);
56160 diff --git a/fs/filesystems.c b/fs/filesystems.c
56161 index 92567d9..fcd8cbf 100644
56162 --- a/fs/filesystems.c
56163 +++ b/fs/filesystems.c
56164 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56165 int len = dot ? dot - name : strlen(name);
56166
56167 fs = __get_fs_type(name, len);
56168 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56169 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56170 +#else
56171 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56172 +#endif
56173 fs = __get_fs_type(name, len);
56174
56175 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56176 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56177 index d8ac61d..79a36f0 100644
56178 --- a/fs/fs_struct.c
56179 +++ b/fs/fs_struct.c
56180 @@ -4,6 +4,7 @@
56181 #include <linux/path.h>
56182 #include <linux/slab.h>
56183 #include <linux/fs_struct.h>
56184 +#include <linux/grsecurity.h>
56185 #include "internal.h"
56186
56187 /*
56188 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56189 write_seqcount_begin(&fs->seq);
56190 old_root = fs->root;
56191 fs->root = *path;
56192 + gr_set_chroot_entries(current, path);
56193 write_seqcount_end(&fs->seq);
56194 spin_unlock(&fs->lock);
56195 if (old_root.dentry)
56196 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56197 int hits = 0;
56198 spin_lock(&fs->lock);
56199 write_seqcount_begin(&fs->seq);
56200 + /* this root replacement is only done by pivot_root,
56201 + leave grsec's chroot tagging alone for this task
56202 + so that a pivoted root isn't treated as a chroot
56203 + */
56204 hits += replace_path(&fs->root, old_root, new_root);
56205 hits += replace_path(&fs->pwd, old_root, new_root);
56206 write_seqcount_end(&fs->seq);
56207 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56208 task_lock(tsk);
56209 spin_lock(&fs->lock);
56210 tsk->fs = NULL;
56211 - kill = !--fs->users;
56212 + gr_clear_chroot_entries(tsk);
56213 + kill = !atomic_dec_return(&fs->users);
56214 spin_unlock(&fs->lock);
56215 task_unlock(tsk);
56216 if (kill)
56217 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56218 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56219 /* We don't need to lock fs - think why ;-) */
56220 if (fs) {
56221 - fs->users = 1;
56222 + atomic_set(&fs->users, 1);
56223 fs->in_exec = 0;
56224 spin_lock_init(&fs->lock);
56225 seqcount_init(&fs->seq);
56226 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56227 spin_lock(&old->lock);
56228 fs->root = old->root;
56229 path_get(&fs->root);
56230 + /* instead of calling gr_set_chroot_entries here,
56231 + we call it from every caller of this function
56232 + */
56233 fs->pwd = old->pwd;
56234 path_get(&fs->pwd);
56235 spin_unlock(&old->lock);
56236 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56237
56238 task_lock(current);
56239 spin_lock(&fs->lock);
56240 - kill = !--fs->users;
56241 + kill = !atomic_dec_return(&fs->users);
56242 current->fs = new_fs;
56243 + gr_set_chroot_entries(current, &new_fs->root);
56244 spin_unlock(&fs->lock);
56245 task_unlock(current);
56246
56247 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56248
56249 int current_umask(void)
56250 {
56251 - return current->fs->umask;
56252 + return current->fs->umask | gr_acl_umask();
56253 }
56254 EXPORT_SYMBOL(current_umask);
56255
56256 /* to be mentioned only in INIT_TASK */
56257 struct fs_struct init_fs = {
56258 - .users = 1,
56259 + .users = ATOMIC_INIT(1),
56260 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56261 .seq = SEQCNT_ZERO,
56262 .umask = 0022,
56263 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56264 index b2a86e3..37f425a 100644
56265 --- a/fs/fscache/cookie.c
56266 +++ b/fs/fscache/cookie.c
56267 @@ -19,7 +19,7 @@
56268
56269 struct kmem_cache *fscache_cookie_jar;
56270
56271 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56272 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56273
56274 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56275 static int fscache_alloc_object(struct fscache_cache *cache,
56276 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56277 parent ? (char *) parent->def->name : "<no-parent>",
56278 def->name, netfs_data);
56279
56280 - fscache_stat(&fscache_n_acquires);
56281 + fscache_stat_unchecked(&fscache_n_acquires);
56282
56283 /* if there's no parent cookie, then we don't create one here either */
56284 if (!parent) {
56285 - fscache_stat(&fscache_n_acquires_null);
56286 + fscache_stat_unchecked(&fscache_n_acquires_null);
56287 _leave(" [no parent]");
56288 return NULL;
56289 }
56290 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56291 /* allocate and initialise a cookie */
56292 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56293 if (!cookie) {
56294 - fscache_stat(&fscache_n_acquires_oom);
56295 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56296 _leave(" [ENOMEM]");
56297 return NULL;
56298 }
56299 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56300
56301 switch (cookie->def->type) {
56302 case FSCACHE_COOKIE_TYPE_INDEX:
56303 - fscache_stat(&fscache_n_cookie_index);
56304 + fscache_stat_unchecked(&fscache_n_cookie_index);
56305 break;
56306 case FSCACHE_COOKIE_TYPE_DATAFILE:
56307 - fscache_stat(&fscache_n_cookie_data);
56308 + fscache_stat_unchecked(&fscache_n_cookie_data);
56309 break;
56310 default:
56311 - fscache_stat(&fscache_n_cookie_special);
56312 + fscache_stat_unchecked(&fscache_n_cookie_special);
56313 break;
56314 }
56315
56316 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56317 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56318 atomic_dec(&parent->n_children);
56319 __fscache_cookie_put(cookie);
56320 - fscache_stat(&fscache_n_acquires_nobufs);
56321 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56322 _leave(" = NULL");
56323 return NULL;
56324 }
56325 }
56326
56327 - fscache_stat(&fscache_n_acquires_ok);
56328 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56329 _leave(" = %p", cookie);
56330 return cookie;
56331 }
56332 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56333 cache = fscache_select_cache_for_object(cookie->parent);
56334 if (!cache) {
56335 up_read(&fscache_addremove_sem);
56336 - fscache_stat(&fscache_n_acquires_no_cache);
56337 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56338 _leave(" = -ENOMEDIUM [no cache]");
56339 return -ENOMEDIUM;
56340 }
56341 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56342 object = cache->ops->alloc_object(cache, cookie);
56343 fscache_stat_d(&fscache_n_cop_alloc_object);
56344 if (IS_ERR(object)) {
56345 - fscache_stat(&fscache_n_object_no_alloc);
56346 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56347 ret = PTR_ERR(object);
56348 goto error;
56349 }
56350
56351 - fscache_stat(&fscache_n_object_alloc);
56352 + fscache_stat_unchecked(&fscache_n_object_alloc);
56353
56354 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56355 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56356
56357 _debug("ALLOC OBJ%x: %s {%lx}",
56358 object->debug_id, cookie->def->name, object->events);
56359 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56360
56361 _enter("{%s}", cookie->def->name);
56362
56363 - fscache_stat(&fscache_n_invalidates);
56364 + fscache_stat_unchecked(&fscache_n_invalidates);
56365
56366 /* Only permit invalidation of data files. Invalidating an index will
56367 * require the caller to release all its attachments to the tree rooted
56368 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56369 {
56370 struct fscache_object *object;
56371
56372 - fscache_stat(&fscache_n_updates);
56373 + fscache_stat_unchecked(&fscache_n_updates);
56374
56375 if (!cookie) {
56376 - fscache_stat(&fscache_n_updates_null);
56377 + fscache_stat_unchecked(&fscache_n_updates_null);
56378 _leave(" [no cookie]");
56379 return;
56380 }
56381 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56382 {
56383 struct fscache_object *object;
56384
56385 - fscache_stat(&fscache_n_relinquishes);
56386 + fscache_stat_unchecked(&fscache_n_relinquishes);
56387 if (retire)
56388 - fscache_stat(&fscache_n_relinquishes_retire);
56389 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56390
56391 if (!cookie) {
56392 - fscache_stat(&fscache_n_relinquishes_null);
56393 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56394 _leave(" [no cookie]");
56395 return;
56396 }
56397 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
56398 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
56399 goto inconsistent;
56400
56401 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
56402 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56403
56404 atomic_inc(&cookie->n_active);
56405 if (fscache_submit_op(object, op) < 0)
56406 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56407 index 4226f66..0fb3f45 100644
56408 --- a/fs/fscache/internal.h
56409 +++ b/fs/fscache/internal.h
56410 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
56411 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
56412 extern int fscache_wait_for_operation_activation(struct fscache_object *,
56413 struct fscache_operation *,
56414 - atomic_t *,
56415 - atomic_t *,
56416 + atomic_unchecked_t *,
56417 + atomic_unchecked_t *,
56418 void (*)(struct fscache_operation *));
56419 extern void fscache_invalidate_writes(struct fscache_cookie *);
56420
56421 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
56422 * stats.c
56423 */
56424 #ifdef CONFIG_FSCACHE_STATS
56425 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56426 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56427 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56428 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56429
56430 -extern atomic_t fscache_n_op_pend;
56431 -extern atomic_t fscache_n_op_run;
56432 -extern atomic_t fscache_n_op_enqueue;
56433 -extern atomic_t fscache_n_op_deferred_release;
56434 -extern atomic_t fscache_n_op_release;
56435 -extern atomic_t fscache_n_op_gc;
56436 -extern atomic_t fscache_n_op_cancelled;
56437 -extern atomic_t fscache_n_op_rejected;
56438 +extern atomic_unchecked_t fscache_n_op_pend;
56439 +extern atomic_unchecked_t fscache_n_op_run;
56440 +extern atomic_unchecked_t fscache_n_op_enqueue;
56441 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56442 +extern atomic_unchecked_t fscache_n_op_release;
56443 +extern atomic_unchecked_t fscache_n_op_gc;
56444 +extern atomic_unchecked_t fscache_n_op_cancelled;
56445 +extern atomic_unchecked_t fscache_n_op_rejected;
56446
56447 -extern atomic_t fscache_n_attr_changed;
56448 -extern atomic_t fscache_n_attr_changed_ok;
56449 -extern atomic_t fscache_n_attr_changed_nobufs;
56450 -extern atomic_t fscache_n_attr_changed_nomem;
56451 -extern atomic_t fscache_n_attr_changed_calls;
56452 +extern atomic_unchecked_t fscache_n_attr_changed;
56453 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56454 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56455 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56456 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56457
56458 -extern atomic_t fscache_n_allocs;
56459 -extern atomic_t fscache_n_allocs_ok;
56460 -extern atomic_t fscache_n_allocs_wait;
56461 -extern atomic_t fscache_n_allocs_nobufs;
56462 -extern atomic_t fscache_n_allocs_intr;
56463 -extern atomic_t fscache_n_allocs_object_dead;
56464 -extern atomic_t fscache_n_alloc_ops;
56465 -extern atomic_t fscache_n_alloc_op_waits;
56466 +extern atomic_unchecked_t fscache_n_allocs;
56467 +extern atomic_unchecked_t fscache_n_allocs_ok;
56468 +extern atomic_unchecked_t fscache_n_allocs_wait;
56469 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56470 +extern atomic_unchecked_t fscache_n_allocs_intr;
56471 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56472 +extern atomic_unchecked_t fscache_n_alloc_ops;
56473 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56474
56475 -extern atomic_t fscache_n_retrievals;
56476 -extern atomic_t fscache_n_retrievals_ok;
56477 -extern atomic_t fscache_n_retrievals_wait;
56478 -extern atomic_t fscache_n_retrievals_nodata;
56479 -extern atomic_t fscache_n_retrievals_nobufs;
56480 -extern atomic_t fscache_n_retrievals_intr;
56481 -extern atomic_t fscache_n_retrievals_nomem;
56482 -extern atomic_t fscache_n_retrievals_object_dead;
56483 -extern atomic_t fscache_n_retrieval_ops;
56484 -extern atomic_t fscache_n_retrieval_op_waits;
56485 +extern atomic_unchecked_t fscache_n_retrievals;
56486 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56487 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56488 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56489 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56490 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56491 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56492 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56493 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56494 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56495
56496 -extern atomic_t fscache_n_stores;
56497 -extern atomic_t fscache_n_stores_ok;
56498 -extern atomic_t fscache_n_stores_again;
56499 -extern atomic_t fscache_n_stores_nobufs;
56500 -extern atomic_t fscache_n_stores_oom;
56501 -extern atomic_t fscache_n_store_ops;
56502 -extern atomic_t fscache_n_store_calls;
56503 -extern atomic_t fscache_n_store_pages;
56504 -extern atomic_t fscache_n_store_radix_deletes;
56505 -extern atomic_t fscache_n_store_pages_over_limit;
56506 +extern atomic_unchecked_t fscache_n_stores;
56507 +extern atomic_unchecked_t fscache_n_stores_ok;
56508 +extern atomic_unchecked_t fscache_n_stores_again;
56509 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56510 +extern atomic_unchecked_t fscache_n_stores_oom;
56511 +extern atomic_unchecked_t fscache_n_store_ops;
56512 +extern atomic_unchecked_t fscache_n_store_calls;
56513 +extern atomic_unchecked_t fscache_n_store_pages;
56514 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56515 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56516
56517 -extern atomic_t fscache_n_store_vmscan_not_storing;
56518 -extern atomic_t fscache_n_store_vmscan_gone;
56519 -extern atomic_t fscache_n_store_vmscan_busy;
56520 -extern atomic_t fscache_n_store_vmscan_cancelled;
56521 -extern atomic_t fscache_n_store_vmscan_wait;
56522 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56523 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56524 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56525 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56526 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56527
56528 -extern atomic_t fscache_n_marks;
56529 -extern atomic_t fscache_n_uncaches;
56530 +extern atomic_unchecked_t fscache_n_marks;
56531 +extern atomic_unchecked_t fscache_n_uncaches;
56532
56533 -extern atomic_t fscache_n_acquires;
56534 -extern atomic_t fscache_n_acquires_null;
56535 -extern atomic_t fscache_n_acquires_no_cache;
56536 -extern atomic_t fscache_n_acquires_ok;
56537 -extern atomic_t fscache_n_acquires_nobufs;
56538 -extern atomic_t fscache_n_acquires_oom;
56539 +extern atomic_unchecked_t fscache_n_acquires;
56540 +extern atomic_unchecked_t fscache_n_acquires_null;
56541 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56542 +extern atomic_unchecked_t fscache_n_acquires_ok;
56543 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56544 +extern atomic_unchecked_t fscache_n_acquires_oom;
56545
56546 -extern atomic_t fscache_n_invalidates;
56547 -extern atomic_t fscache_n_invalidates_run;
56548 +extern atomic_unchecked_t fscache_n_invalidates;
56549 +extern atomic_unchecked_t fscache_n_invalidates_run;
56550
56551 -extern atomic_t fscache_n_updates;
56552 -extern atomic_t fscache_n_updates_null;
56553 -extern atomic_t fscache_n_updates_run;
56554 +extern atomic_unchecked_t fscache_n_updates;
56555 +extern atomic_unchecked_t fscache_n_updates_null;
56556 +extern atomic_unchecked_t fscache_n_updates_run;
56557
56558 -extern atomic_t fscache_n_relinquishes;
56559 -extern atomic_t fscache_n_relinquishes_null;
56560 -extern atomic_t fscache_n_relinquishes_waitcrt;
56561 -extern atomic_t fscache_n_relinquishes_retire;
56562 +extern atomic_unchecked_t fscache_n_relinquishes;
56563 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56564 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56565 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56566
56567 -extern atomic_t fscache_n_cookie_index;
56568 -extern atomic_t fscache_n_cookie_data;
56569 -extern atomic_t fscache_n_cookie_special;
56570 +extern atomic_unchecked_t fscache_n_cookie_index;
56571 +extern atomic_unchecked_t fscache_n_cookie_data;
56572 +extern atomic_unchecked_t fscache_n_cookie_special;
56573
56574 -extern atomic_t fscache_n_object_alloc;
56575 -extern atomic_t fscache_n_object_no_alloc;
56576 -extern atomic_t fscache_n_object_lookups;
56577 -extern atomic_t fscache_n_object_lookups_negative;
56578 -extern atomic_t fscache_n_object_lookups_positive;
56579 -extern atomic_t fscache_n_object_lookups_timed_out;
56580 -extern atomic_t fscache_n_object_created;
56581 -extern atomic_t fscache_n_object_avail;
56582 -extern atomic_t fscache_n_object_dead;
56583 +extern atomic_unchecked_t fscache_n_object_alloc;
56584 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56585 +extern atomic_unchecked_t fscache_n_object_lookups;
56586 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56587 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56588 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56589 +extern atomic_unchecked_t fscache_n_object_created;
56590 +extern atomic_unchecked_t fscache_n_object_avail;
56591 +extern atomic_unchecked_t fscache_n_object_dead;
56592
56593 -extern atomic_t fscache_n_checkaux_none;
56594 -extern atomic_t fscache_n_checkaux_okay;
56595 -extern atomic_t fscache_n_checkaux_update;
56596 -extern atomic_t fscache_n_checkaux_obsolete;
56597 +extern atomic_unchecked_t fscache_n_checkaux_none;
56598 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56599 +extern atomic_unchecked_t fscache_n_checkaux_update;
56600 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56601
56602 extern atomic_t fscache_n_cop_alloc_object;
56603 extern atomic_t fscache_n_cop_lookup_object;
56604 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
56605 atomic_inc(stat);
56606 }
56607
56608 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56609 +{
56610 + atomic_inc_unchecked(stat);
56611 +}
56612 +
56613 static inline void fscache_stat_d(atomic_t *stat)
56614 {
56615 atomic_dec(stat);
56616 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
56617
56618 #define __fscache_stat(stat) (NULL)
56619 #define fscache_stat(stat) do {} while (0)
56620 +#define fscache_stat_unchecked(stat) do {} while (0)
56621 #define fscache_stat_d(stat) do {} while (0)
56622 #endif
56623
56624 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56625 index 86d75a6..5f3d7a0 100644
56626 --- a/fs/fscache/object.c
56627 +++ b/fs/fscache/object.c
56628 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56629 _debug("LOOKUP \"%s\" in \"%s\"",
56630 cookie->def->name, object->cache->tag->name);
56631
56632 - fscache_stat(&fscache_n_object_lookups);
56633 + fscache_stat_unchecked(&fscache_n_object_lookups);
56634 fscache_stat(&fscache_n_cop_lookup_object);
56635 ret = object->cache->ops->lookup_object(object);
56636 fscache_stat_d(&fscache_n_cop_lookup_object);
56637 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56638 if (ret == -ETIMEDOUT) {
56639 /* probably stuck behind another object, so move this one to
56640 * the back of the queue */
56641 - fscache_stat(&fscache_n_object_lookups_timed_out);
56642 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56643 _leave(" [timeout]");
56644 return NO_TRANSIT;
56645 }
56646 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56647 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56648
56649 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56650 - fscache_stat(&fscache_n_object_lookups_negative);
56651 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56652
56653 /* Allow write requests to begin stacking up and read requests to begin
56654 * returning ENODATA.
56655 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56656 /* if we were still looking up, then we must have a positive lookup
56657 * result, in which case there may be data available */
56658 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56659 - fscache_stat(&fscache_n_object_lookups_positive);
56660 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56661
56662 /* We do (presumably) have data */
56663 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56664 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56665 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56666 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56667 } else {
56668 - fscache_stat(&fscache_n_object_created);
56669 + fscache_stat_unchecked(&fscache_n_object_created);
56670 }
56671
56672 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56673 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56674 fscache_stat_d(&fscache_n_cop_lookup_complete);
56675
56676 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56677 - fscache_stat(&fscache_n_object_avail);
56678 + fscache_stat_unchecked(&fscache_n_object_avail);
56679
56680 _leave("");
56681 return transit_to(JUMPSTART_DEPS);
56682 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56683
56684 /* this just shifts the object release to the work processor */
56685 fscache_put_object(object);
56686 - fscache_stat(&fscache_n_object_dead);
56687 + fscache_stat_unchecked(&fscache_n_object_dead);
56688
56689 _leave("");
56690 return transit_to(OBJECT_DEAD);
56691 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56692 enum fscache_checkaux result;
56693
56694 if (!object->cookie->def->check_aux) {
56695 - fscache_stat(&fscache_n_checkaux_none);
56696 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56697 return FSCACHE_CHECKAUX_OKAY;
56698 }
56699
56700 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56701 switch (result) {
56702 /* entry okay as is */
56703 case FSCACHE_CHECKAUX_OKAY:
56704 - fscache_stat(&fscache_n_checkaux_okay);
56705 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56706 break;
56707
56708 /* entry requires update */
56709 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56710 - fscache_stat(&fscache_n_checkaux_update);
56711 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56712 break;
56713
56714 /* entry requires deletion */
56715 case FSCACHE_CHECKAUX_OBSOLETE:
56716 - fscache_stat(&fscache_n_checkaux_obsolete);
56717 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56718 break;
56719
56720 default:
56721 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56722 {
56723 const struct fscache_state *s;
56724
56725 - fscache_stat(&fscache_n_invalidates_run);
56726 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56727 fscache_stat(&fscache_n_cop_invalidate_object);
56728 s = _fscache_invalidate_object(object, event);
56729 fscache_stat_d(&fscache_n_cop_invalidate_object);
56730 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56731 {
56732 _enter("{OBJ%x},%d", object->debug_id, event);
56733
56734 - fscache_stat(&fscache_n_updates_run);
56735 + fscache_stat_unchecked(&fscache_n_updates_run);
56736 fscache_stat(&fscache_n_cop_update_object);
56737 object->cache->ops->update_object(object);
56738 fscache_stat_d(&fscache_n_cop_update_object);
56739 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56740 index 318071a..379938b 100644
56741 --- a/fs/fscache/operation.c
56742 +++ b/fs/fscache/operation.c
56743 @@ -17,7 +17,7 @@
56744 #include <linux/slab.h>
56745 #include "internal.h"
56746
56747 -atomic_t fscache_op_debug_id;
56748 +atomic_unchecked_t fscache_op_debug_id;
56749 EXPORT_SYMBOL(fscache_op_debug_id);
56750
56751 /**
56752 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56753 ASSERTCMP(atomic_read(&op->usage), >, 0);
56754 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56755
56756 - fscache_stat(&fscache_n_op_enqueue);
56757 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56758 switch (op->flags & FSCACHE_OP_TYPE) {
56759 case FSCACHE_OP_ASYNC:
56760 _debug("queue async");
56761 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56762 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56763 if (op->processor)
56764 fscache_enqueue_operation(op);
56765 - fscache_stat(&fscache_n_op_run);
56766 + fscache_stat_unchecked(&fscache_n_op_run);
56767 }
56768
56769 /*
56770 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56771 if (object->n_in_progress > 0) {
56772 atomic_inc(&op->usage);
56773 list_add_tail(&op->pend_link, &object->pending_ops);
56774 - fscache_stat(&fscache_n_op_pend);
56775 + fscache_stat_unchecked(&fscache_n_op_pend);
56776 } else if (!list_empty(&object->pending_ops)) {
56777 atomic_inc(&op->usage);
56778 list_add_tail(&op->pend_link, &object->pending_ops);
56779 - fscache_stat(&fscache_n_op_pend);
56780 + fscache_stat_unchecked(&fscache_n_op_pend);
56781 fscache_start_operations(object);
56782 } else {
56783 ASSERTCMP(object->n_in_progress, ==, 0);
56784 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56785 object->n_exclusive++; /* reads and writes must wait */
56786 atomic_inc(&op->usage);
56787 list_add_tail(&op->pend_link, &object->pending_ops);
56788 - fscache_stat(&fscache_n_op_pend);
56789 + fscache_stat_unchecked(&fscache_n_op_pend);
56790 ret = 0;
56791 } else {
56792 /* If we're in any other state, there must have been an I/O
56793 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56794 if (object->n_exclusive > 0) {
56795 atomic_inc(&op->usage);
56796 list_add_tail(&op->pend_link, &object->pending_ops);
56797 - fscache_stat(&fscache_n_op_pend);
56798 + fscache_stat_unchecked(&fscache_n_op_pend);
56799 } else if (!list_empty(&object->pending_ops)) {
56800 atomic_inc(&op->usage);
56801 list_add_tail(&op->pend_link, &object->pending_ops);
56802 - fscache_stat(&fscache_n_op_pend);
56803 + fscache_stat_unchecked(&fscache_n_op_pend);
56804 fscache_start_operations(object);
56805 } else {
56806 ASSERTCMP(object->n_exclusive, ==, 0);
56807 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56808 object->n_ops++;
56809 atomic_inc(&op->usage);
56810 list_add_tail(&op->pend_link, &object->pending_ops);
56811 - fscache_stat(&fscache_n_op_pend);
56812 + fscache_stat_unchecked(&fscache_n_op_pend);
56813 ret = 0;
56814 } else if (fscache_object_is_dying(object)) {
56815 - fscache_stat(&fscache_n_op_rejected);
56816 + fscache_stat_unchecked(&fscache_n_op_rejected);
56817 op->state = FSCACHE_OP_ST_CANCELLED;
56818 ret = -ENOBUFS;
56819 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56820 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56821 ret = -EBUSY;
56822 if (op->state == FSCACHE_OP_ST_PENDING) {
56823 ASSERT(!list_empty(&op->pend_link));
56824 - fscache_stat(&fscache_n_op_cancelled);
56825 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56826 list_del_init(&op->pend_link);
56827 if (do_cancel)
56828 do_cancel(op);
56829 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56830 while (!list_empty(&object->pending_ops)) {
56831 op = list_entry(object->pending_ops.next,
56832 struct fscache_operation, pend_link);
56833 - fscache_stat(&fscache_n_op_cancelled);
56834 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56835 list_del_init(&op->pend_link);
56836
56837 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56838 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56839 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56840 op->state = FSCACHE_OP_ST_DEAD;
56841
56842 - fscache_stat(&fscache_n_op_release);
56843 + fscache_stat_unchecked(&fscache_n_op_release);
56844
56845 if (op->release) {
56846 op->release(op);
56847 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56848 * lock, and defer it otherwise */
56849 if (!spin_trylock(&object->lock)) {
56850 _debug("defer put");
56851 - fscache_stat(&fscache_n_op_deferred_release);
56852 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56853
56854 cache = object->cache;
56855 spin_lock(&cache->op_gc_list_lock);
56856 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56857
56858 _debug("GC DEFERRED REL OBJ%x OP%x",
56859 object->debug_id, op->debug_id);
56860 - fscache_stat(&fscache_n_op_gc);
56861 + fscache_stat_unchecked(&fscache_n_op_gc);
56862
56863 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56864 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56865 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56866 index 73899c1..ae40c58 100644
56867 --- a/fs/fscache/page.c
56868 +++ b/fs/fscache/page.c
56869 @@ -61,7 +61,7 @@ try_again:
56870 val = radix_tree_lookup(&cookie->stores, page->index);
56871 if (!val) {
56872 rcu_read_unlock();
56873 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56874 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56875 __fscache_uncache_page(cookie, page);
56876 return true;
56877 }
56878 @@ -91,11 +91,11 @@ try_again:
56879 spin_unlock(&cookie->stores_lock);
56880
56881 if (xpage) {
56882 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56883 - fscache_stat(&fscache_n_store_radix_deletes);
56884 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56885 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56886 ASSERTCMP(xpage, ==, page);
56887 } else {
56888 - fscache_stat(&fscache_n_store_vmscan_gone);
56889 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56890 }
56891
56892 wake_up_bit(&cookie->flags, 0);
56893 @@ -110,11 +110,11 @@ page_busy:
56894 * sleeping on memory allocation, so we may need to impose a timeout
56895 * too. */
56896 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56897 - fscache_stat(&fscache_n_store_vmscan_busy);
56898 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56899 return false;
56900 }
56901
56902 - fscache_stat(&fscache_n_store_vmscan_wait);
56903 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56904 __fscache_wait_on_page_write(cookie, page);
56905 gfp &= ~__GFP_WAIT;
56906 goto try_again;
56907 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56908 FSCACHE_COOKIE_STORING_TAG);
56909 if (!radix_tree_tag_get(&cookie->stores, page->index,
56910 FSCACHE_COOKIE_PENDING_TAG)) {
56911 - fscache_stat(&fscache_n_store_radix_deletes);
56912 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56913 xpage = radix_tree_delete(&cookie->stores, page->index);
56914 }
56915 spin_unlock(&cookie->stores_lock);
56916 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56917
56918 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56919
56920 - fscache_stat(&fscache_n_attr_changed_calls);
56921 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56922
56923 if (fscache_object_is_active(object) &&
56924 fscache_use_cookie(object)) {
56925 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56926
56927 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56928
56929 - fscache_stat(&fscache_n_attr_changed);
56930 + fscache_stat_unchecked(&fscache_n_attr_changed);
56931
56932 op = kzalloc(sizeof(*op), GFP_KERNEL);
56933 if (!op) {
56934 - fscache_stat(&fscache_n_attr_changed_nomem);
56935 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56936 _leave(" = -ENOMEM");
56937 return -ENOMEM;
56938 }
56939 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56940 if (fscache_submit_exclusive_op(object, op) < 0)
56941 goto nobufs;
56942 spin_unlock(&cookie->lock);
56943 - fscache_stat(&fscache_n_attr_changed_ok);
56944 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56945 fscache_put_operation(op);
56946 _leave(" = 0");
56947 return 0;
56948 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56949 nobufs:
56950 spin_unlock(&cookie->lock);
56951 kfree(op);
56952 - fscache_stat(&fscache_n_attr_changed_nobufs);
56953 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56954 _leave(" = %d", -ENOBUFS);
56955 return -ENOBUFS;
56956 }
56957 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56958 /* allocate a retrieval operation and attempt to submit it */
56959 op = kzalloc(sizeof(*op), GFP_NOIO);
56960 if (!op) {
56961 - fscache_stat(&fscache_n_retrievals_nomem);
56962 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56963 return NULL;
56964 }
56965
56966 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56967 return 0;
56968 }
56969
56970 - fscache_stat(&fscache_n_retrievals_wait);
56971 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56972
56973 jif = jiffies;
56974 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56975 fscache_wait_bit_interruptible,
56976 TASK_INTERRUPTIBLE) != 0) {
56977 - fscache_stat(&fscache_n_retrievals_intr);
56978 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56979 _leave(" = -ERESTARTSYS");
56980 return -ERESTARTSYS;
56981 }
56982 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56983 */
56984 int fscache_wait_for_operation_activation(struct fscache_object *object,
56985 struct fscache_operation *op,
56986 - atomic_t *stat_op_waits,
56987 - atomic_t *stat_object_dead,
56988 + atomic_unchecked_t *stat_op_waits,
56989 + atomic_unchecked_t *stat_object_dead,
56990 void (*do_cancel)(struct fscache_operation *))
56991 {
56992 int ret;
56993 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
56994
56995 _debug(">>> WT");
56996 if (stat_op_waits)
56997 - fscache_stat(stat_op_waits);
56998 + fscache_stat_unchecked(stat_op_waits);
56999 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
57000 fscache_wait_bit_interruptible,
57001 TASK_INTERRUPTIBLE) != 0) {
57002 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57003 check_if_dead:
57004 if (op->state == FSCACHE_OP_ST_CANCELLED) {
57005 if (stat_object_dead)
57006 - fscache_stat(stat_object_dead);
57007 + fscache_stat_unchecked(stat_object_dead);
57008 _leave(" = -ENOBUFS [cancelled]");
57009 return -ENOBUFS;
57010 }
57011 @@ -361,7 +361,7 @@ check_if_dead:
57012 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57013 fscache_cancel_op(op, do_cancel);
57014 if (stat_object_dead)
57015 - fscache_stat(stat_object_dead);
57016 + fscache_stat_unchecked(stat_object_dead);
57017 return -ENOBUFS;
57018 }
57019 return 0;
57020 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57021
57022 _enter("%p,%p,,,", cookie, page);
57023
57024 - fscache_stat(&fscache_n_retrievals);
57025 + fscache_stat_unchecked(&fscache_n_retrievals);
57026
57027 if (hlist_empty(&cookie->backing_objects))
57028 goto nobufs;
57029 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57030 goto nobufs_unlock_dec;
57031 spin_unlock(&cookie->lock);
57032
57033 - fscache_stat(&fscache_n_retrieval_ops);
57034 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57035
57036 /* pin the netfs read context in case we need to do the actual netfs
57037 * read because we've encountered a cache read failure */
57038 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57039
57040 error:
57041 if (ret == -ENOMEM)
57042 - fscache_stat(&fscache_n_retrievals_nomem);
57043 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57044 else if (ret == -ERESTARTSYS)
57045 - fscache_stat(&fscache_n_retrievals_intr);
57046 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57047 else if (ret == -ENODATA)
57048 - fscache_stat(&fscache_n_retrievals_nodata);
57049 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57050 else if (ret < 0)
57051 - fscache_stat(&fscache_n_retrievals_nobufs);
57052 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57053 else
57054 - fscache_stat(&fscache_n_retrievals_ok);
57055 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57056
57057 fscache_put_retrieval(op);
57058 _leave(" = %d", ret);
57059 @@ -480,7 +480,7 @@ nobufs_unlock:
57060 atomic_dec(&cookie->n_active);
57061 kfree(op);
57062 nobufs:
57063 - fscache_stat(&fscache_n_retrievals_nobufs);
57064 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57065 _leave(" = -ENOBUFS");
57066 return -ENOBUFS;
57067 }
57068 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57069
57070 _enter("%p,,%d,,,", cookie, *nr_pages);
57071
57072 - fscache_stat(&fscache_n_retrievals);
57073 + fscache_stat_unchecked(&fscache_n_retrievals);
57074
57075 if (hlist_empty(&cookie->backing_objects))
57076 goto nobufs;
57077 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57078 goto nobufs_unlock_dec;
57079 spin_unlock(&cookie->lock);
57080
57081 - fscache_stat(&fscache_n_retrieval_ops);
57082 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57083
57084 /* pin the netfs read context in case we need to do the actual netfs
57085 * read because we've encountered a cache read failure */
57086 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57087
57088 error:
57089 if (ret == -ENOMEM)
57090 - fscache_stat(&fscache_n_retrievals_nomem);
57091 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57092 else if (ret == -ERESTARTSYS)
57093 - fscache_stat(&fscache_n_retrievals_intr);
57094 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57095 else if (ret == -ENODATA)
57096 - fscache_stat(&fscache_n_retrievals_nodata);
57097 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57098 else if (ret < 0)
57099 - fscache_stat(&fscache_n_retrievals_nobufs);
57100 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57101 else
57102 - fscache_stat(&fscache_n_retrievals_ok);
57103 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57104
57105 fscache_put_retrieval(op);
57106 _leave(" = %d", ret);
57107 @@ -606,7 +606,7 @@ nobufs_unlock:
57108 atomic_dec(&cookie->n_active);
57109 kfree(op);
57110 nobufs:
57111 - fscache_stat(&fscache_n_retrievals_nobufs);
57112 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57113 _leave(" = -ENOBUFS");
57114 return -ENOBUFS;
57115 }
57116 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57117
57118 _enter("%p,%p,,,", cookie, page);
57119
57120 - fscache_stat(&fscache_n_allocs);
57121 + fscache_stat_unchecked(&fscache_n_allocs);
57122
57123 if (hlist_empty(&cookie->backing_objects))
57124 goto nobufs;
57125 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57126 goto nobufs_unlock;
57127 spin_unlock(&cookie->lock);
57128
57129 - fscache_stat(&fscache_n_alloc_ops);
57130 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57131
57132 ret = fscache_wait_for_operation_activation(
57133 object, &op->op,
57134 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57135
57136 error:
57137 if (ret == -ERESTARTSYS)
57138 - fscache_stat(&fscache_n_allocs_intr);
57139 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57140 else if (ret < 0)
57141 - fscache_stat(&fscache_n_allocs_nobufs);
57142 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57143 else
57144 - fscache_stat(&fscache_n_allocs_ok);
57145 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57146
57147 fscache_put_retrieval(op);
57148 _leave(" = %d", ret);
57149 @@ -694,7 +694,7 @@ nobufs_unlock:
57150 atomic_dec(&cookie->n_active);
57151 kfree(op);
57152 nobufs:
57153 - fscache_stat(&fscache_n_allocs_nobufs);
57154 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57155 _leave(" = -ENOBUFS");
57156 return -ENOBUFS;
57157 }
57158 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57159
57160 spin_lock(&cookie->stores_lock);
57161
57162 - fscache_stat(&fscache_n_store_calls);
57163 + fscache_stat_unchecked(&fscache_n_store_calls);
57164
57165 /* find a page to store */
57166 page = NULL;
57167 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57168 page = results[0];
57169 _debug("gang %d [%lx]", n, page->index);
57170 if (page->index > op->store_limit) {
57171 - fscache_stat(&fscache_n_store_pages_over_limit);
57172 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57173 goto superseded;
57174 }
57175
57176 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57177 spin_unlock(&cookie->stores_lock);
57178 spin_unlock(&object->lock);
57179
57180 - fscache_stat(&fscache_n_store_pages);
57181 + fscache_stat_unchecked(&fscache_n_store_pages);
57182 fscache_stat(&fscache_n_cop_write_page);
57183 ret = object->cache->ops->write_page(op, page);
57184 fscache_stat_d(&fscache_n_cop_write_page);
57185 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57186 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57187 ASSERT(PageFsCache(page));
57188
57189 - fscache_stat(&fscache_n_stores);
57190 + fscache_stat_unchecked(&fscache_n_stores);
57191
57192 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57193 _leave(" = -ENOBUFS [invalidating]");
57194 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57195 spin_unlock(&cookie->stores_lock);
57196 spin_unlock(&object->lock);
57197
57198 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57199 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57200 op->store_limit = object->store_limit;
57201
57202 atomic_inc(&cookie->n_active);
57203 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57204
57205 spin_unlock(&cookie->lock);
57206 radix_tree_preload_end();
57207 - fscache_stat(&fscache_n_store_ops);
57208 - fscache_stat(&fscache_n_stores_ok);
57209 + fscache_stat_unchecked(&fscache_n_store_ops);
57210 + fscache_stat_unchecked(&fscache_n_stores_ok);
57211
57212 /* the work queue now carries its own ref on the object */
57213 fscache_put_operation(&op->op);
57214 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57215 return 0;
57216
57217 already_queued:
57218 - fscache_stat(&fscache_n_stores_again);
57219 + fscache_stat_unchecked(&fscache_n_stores_again);
57220 already_pending:
57221 spin_unlock(&cookie->stores_lock);
57222 spin_unlock(&object->lock);
57223 spin_unlock(&cookie->lock);
57224 radix_tree_preload_end();
57225 kfree(op);
57226 - fscache_stat(&fscache_n_stores_ok);
57227 + fscache_stat_unchecked(&fscache_n_stores_ok);
57228 _leave(" = 0");
57229 return 0;
57230
57231 @@ -999,14 +999,14 @@ nobufs:
57232 spin_unlock(&cookie->lock);
57233 radix_tree_preload_end();
57234 kfree(op);
57235 - fscache_stat(&fscache_n_stores_nobufs);
57236 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57237 _leave(" = -ENOBUFS");
57238 return -ENOBUFS;
57239
57240 nomem_free:
57241 kfree(op);
57242 nomem:
57243 - fscache_stat(&fscache_n_stores_oom);
57244 + fscache_stat_unchecked(&fscache_n_stores_oom);
57245 _leave(" = -ENOMEM");
57246 return -ENOMEM;
57247 }
57248 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57249 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57250 ASSERTCMP(page, !=, NULL);
57251
57252 - fscache_stat(&fscache_n_uncaches);
57253 + fscache_stat_unchecked(&fscache_n_uncaches);
57254
57255 /* cache withdrawal may beat us to it */
57256 if (!PageFsCache(page))
57257 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57258 struct fscache_cookie *cookie = op->op.object->cookie;
57259
57260 #ifdef CONFIG_FSCACHE_STATS
57261 - atomic_inc(&fscache_n_marks);
57262 + atomic_inc_unchecked(&fscache_n_marks);
57263 #endif
57264
57265 _debug("- mark %p{%lx}", page, page->index);
57266 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57267 index 40d13c7..ddf52b9 100644
57268 --- a/fs/fscache/stats.c
57269 +++ b/fs/fscache/stats.c
57270 @@ -18,99 +18,99 @@
57271 /*
57272 * operation counters
57273 */
57274 -atomic_t fscache_n_op_pend;
57275 -atomic_t fscache_n_op_run;
57276 -atomic_t fscache_n_op_enqueue;
57277 -atomic_t fscache_n_op_requeue;
57278 -atomic_t fscache_n_op_deferred_release;
57279 -atomic_t fscache_n_op_release;
57280 -atomic_t fscache_n_op_gc;
57281 -atomic_t fscache_n_op_cancelled;
57282 -atomic_t fscache_n_op_rejected;
57283 +atomic_unchecked_t fscache_n_op_pend;
57284 +atomic_unchecked_t fscache_n_op_run;
57285 +atomic_unchecked_t fscache_n_op_enqueue;
57286 +atomic_unchecked_t fscache_n_op_requeue;
57287 +atomic_unchecked_t fscache_n_op_deferred_release;
57288 +atomic_unchecked_t fscache_n_op_release;
57289 +atomic_unchecked_t fscache_n_op_gc;
57290 +atomic_unchecked_t fscache_n_op_cancelled;
57291 +atomic_unchecked_t fscache_n_op_rejected;
57292
57293 -atomic_t fscache_n_attr_changed;
57294 -atomic_t fscache_n_attr_changed_ok;
57295 -atomic_t fscache_n_attr_changed_nobufs;
57296 -atomic_t fscache_n_attr_changed_nomem;
57297 -atomic_t fscache_n_attr_changed_calls;
57298 +atomic_unchecked_t fscache_n_attr_changed;
57299 +atomic_unchecked_t fscache_n_attr_changed_ok;
57300 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
57301 +atomic_unchecked_t fscache_n_attr_changed_nomem;
57302 +atomic_unchecked_t fscache_n_attr_changed_calls;
57303
57304 -atomic_t fscache_n_allocs;
57305 -atomic_t fscache_n_allocs_ok;
57306 -atomic_t fscache_n_allocs_wait;
57307 -atomic_t fscache_n_allocs_nobufs;
57308 -atomic_t fscache_n_allocs_intr;
57309 -atomic_t fscache_n_allocs_object_dead;
57310 -atomic_t fscache_n_alloc_ops;
57311 -atomic_t fscache_n_alloc_op_waits;
57312 +atomic_unchecked_t fscache_n_allocs;
57313 +atomic_unchecked_t fscache_n_allocs_ok;
57314 +atomic_unchecked_t fscache_n_allocs_wait;
57315 +atomic_unchecked_t fscache_n_allocs_nobufs;
57316 +atomic_unchecked_t fscache_n_allocs_intr;
57317 +atomic_unchecked_t fscache_n_allocs_object_dead;
57318 +atomic_unchecked_t fscache_n_alloc_ops;
57319 +atomic_unchecked_t fscache_n_alloc_op_waits;
57320
57321 -atomic_t fscache_n_retrievals;
57322 -atomic_t fscache_n_retrievals_ok;
57323 -atomic_t fscache_n_retrievals_wait;
57324 -atomic_t fscache_n_retrievals_nodata;
57325 -atomic_t fscache_n_retrievals_nobufs;
57326 -atomic_t fscache_n_retrievals_intr;
57327 -atomic_t fscache_n_retrievals_nomem;
57328 -atomic_t fscache_n_retrievals_object_dead;
57329 -atomic_t fscache_n_retrieval_ops;
57330 -atomic_t fscache_n_retrieval_op_waits;
57331 +atomic_unchecked_t fscache_n_retrievals;
57332 +atomic_unchecked_t fscache_n_retrievals_ok;
57333 +atomic_unchecked_t fscache_n_retrievals_wait;
57334 +atomic_unchecked_t fscache_n_retrievals_nodata;
57335 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57336 +atomic_unchecked_t fscache_n_retrievals_intr;
57337 +atomic_unchecked_t fscache_n_retrievals_nomem;
57338 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57339 +atomic_unchecked_t fscache_n_retrieval_ops;
57340 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57341
57342 -atomic_t fscache_n_stores;
57343 -atomic_t fscache_n_stores_ok;
57344 -atomic_t fscache_n_stores_again;
57345 -atomic_t fscache_n_stores_nobufs;
57346 -atomic_t fscache_n_stores_oom;
57347 -atomic_t fscache_n_store_ops;
57348 -atomic_t fscache_n_store_calls;
57349 -atomic_t fscache_n_store_pages;
57350 -atomic_t fscache_n_store_radix_deletes;
57351 -atomic_t fscache_n_store_pages_over_limit;
57352 +atomic_unchecked_t fscache_n_stores;
57353 +atomic_unchecked_t fscache_n_stores_ok;
57354 +atomic_unchecked_t fscache_n_stores_again;
57355 +atomic_unchecked_t fscache_n_stores_nobufs;
57356 +atomic_unchecked_t fscache_n_stores_oom;
57357 +atomic_unchecked_t fscache_n_store_ops;
57358 +atomic_unchecked_t fscache_n_store_calls;
57359 +atomic_unchecked_t fscache_n_store_pages;
57360 +atomic_unchecked_t fscache_n_store_radix_deletes;
57361 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57362
57363 -atomic_t fscache_n_store_vmscan_not_storing;
57364 -atomic_t fscache_n_store_vmscan_gone;
57365 -atomic_t fscache_n_store_vmscan_busy;
57366 -atomic_t fscache_n_store_vmscan_cancelled;
57367 -atomic_t fscache_n_store_vmscan_wait;
57368 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57369 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57370 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57371 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57372 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57373
57374 -atomic_t fscache_n_marks;
57375 -atomic_t fscache_n_uncaches;
57376 +atomic_unchecked_t fscache_n_marks;
57377 +atomic_unchecked_t fscache_n_uncaches;
57378
57379 -atomic_t fscache_n_acquires;
57380 -atomic_t fscache_n_acquires_null;
57381 -atomic_t fscache_n_acquires_no_cache;
57382 -atomic_t fscache_n_acquires_ok;
57383 -atomic_t fscache_n_acquires_nobufs;
57384 -atomic_t fscache_n_acquires_oom;
57385 +atomic_unchecked_t fscache_n_acquires;
57386 +atomic_unchecked_t fscache_n_acquires_null;
57387 +atomic_unchecked_t fscache_n_acquires_no_cache;
57388 +atomic_unchecked_t fscache_n_acquires_ok;
57389 +atomic_unchecked_t fscache_n_acquires_nobufs;
57390 +atomic_unchecked_t fscache_n_acquires_oom;
57391
57392 -atomic_t fscache_n_invalidates;
57393 -atomic_t fscache_n_invalidates_run;
57394 +atomic_unchecked_t fscache_n_invalidates;
57395 +atomic_unchecked_t fscache_n_invalidates_run;
57396
57397 -atomic_t fscache_n_updates;
57398 -atomic_t fscache_n_updates_null;
57399 -atomic_t fscache_n_updates_run;
57400 +atomic_unchecked_t fscache_n_updates;
57401 +atomic_unchecked_t fscache_n_updates_null;
57402 +atomic_unchecked_t fscache_n_updates_run;
57403
57404 -atomic_t fscache_n_relinquishes;
57405 -atomic_t fscache_n_relinquishes_null;
57406 -atomic_t fscache_n_relinquishes_waitcrt;
57407 -atomic_t fscache_n_relinquishes_retire;
57408 +atomic_unchecked_t fscache_n_relinquishes;
57409 +atomic_unchecked_t fscache_n_relinquishes_null;
57410 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57411 +atomic_unchecked_t fscache_n_relinquishes_retire;
57412
57413 -atomic_t fscache_n_cookie_index;
57414 -atomic_t fscache_n_cookie_data;
57415 -atomic_t fscache_n_cookie_special;
57416 +atomic_unchecked_t fscache_n_cookie_index;
57417 +atomic_unchecked_t fscache_n_cookie_data;
57418 +atomic_unchecked_t fscache_n_cookie_special;
57419
57420 -atomic_t fscache_n_object_alloc;
57421 -atomic_t fscache_n_object_no_alloc;
57422 -atomic_t fscache_n_object_lookups;
57423 -atomic_t fscache_n_object_lookups_negative;
57424 -atomic_t fscache_n_object_lookups_positive;
57425 -atomic_t fscache_n_object_lookups_timed_out;
57426 -atomic_t fscache_n_object_created;
57427 -atomic_t fscache_n_object_avail;
57428 -atomic_t fscache_n_object_dead;
57429 +atomic_unchecked_t fscache_n_object_alloc;
57430 +atomic_unchecked_t fscache_n_object_no_alloc;
57431 +atomic_unchecked_t fscache_n_object_lookups;
57432 +atomic_unchecked_t fscache_n_object_lookups_negative;
57433 +atomic_unchecked_t fscache_n_object_lookups_positive;
57434 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57435 +atomic_unchecked_t fscache_n_object_created;
57436 +atomic_unchecked_t fscache_n_object_avail;
57437 +atomic_unchecked_t fscache_n_object_dead;
57438
57439 -atomic_t fscache_n_checkaux_none;
57440 -atomic_t fscache_n_checkaux_okay;
57441 -atomic_t fscache_n_checkaux_update;
57442 -atomic_t fscache_n_checkaux_obsolete;
57443 +atomic_unchecked_t fscache_n_checkaux_none;
57444 +atomic_unchecked_t fscache_n_checkaux_okay;
57445 +atomic_unchecked_t fscache_n_checkaux_update;
57446 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57447
57448 atomic_t fscache_n_cop_alloc_object;
57449 atomic_t fscache_n_cop_lookup_object;
57450 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57451 seq_puts(m, "FS-Cache statistics\n");
57452
57453 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57454 - atomic_read(&fscache_n_cookie_index),
57455 - atomic_read(&fscache_n_cookie_data),
57456 - atomic_read(&fscache_n_cookie_special));
57457 + atomic_read_unchecked(&fscache_n_cookie_index),
57458 + atomic_read_unchecked(&fscache_n_cookie_data),
57459 + atomic_read_unchecked(&fscache_n_cookie_special));
57460
57461 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57462 - atomic_read(&fscache_n_object_alloc),
57463 - atomic_read(&fscache_n_object_no_alloc),
57464 - atomic_read(&fscache_n_object_avail),
57465 - atomic_read(&fscache_n_object_dead));
57466 + atomic_read_unchecked(&fscache_n_object_alloc),
57467 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57468 + atomic_read_unchecked(&fscache_n_object_avail),
57469 + atomic_read_unchecked(&fscache_n_object_dead));
57470 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57471 - atomic_read(&fscache_n_checkaux_none),
57472 - atomic_read(&fscache_n_checkaux_okay),
57473 - atomic_read(&fscache_n_checkaux_update),
57474 - atomic_read(&fscache_n_checkaux_obsolete));
57475 + atomic_read_unchecked(&fscache_n_checkaux_none),
57476 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57477 + atomic_read_unchecked(&fscache_n_checkaux_update),
57478 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57479
57480 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57481 - atomic_read(&fscache_n_marks),
57482 - atomic_read(&fscache_n_uncaches));
57483 + atomic_read_unchecked(&fscache_n_marks),
57484 + atomic_read_unchecked(&fscache_n_uncaches));
57485
57486 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57487 " oom=%u\n",
57488 - atomic_read(&fscache_n_acquires),
57489 - atomic_read(&fscache_n_acquires_null),
57490 - atomic_read(&fscache_n_acquires_no_cache),
57491 - atomic_read(&fscache_n_acquires_ok),
57492 - atomic_read(&fscache_n_acquires_nobufs),
57493 - atomic_read(&fscache_n_acquires_oom));
57494 + atomic_read_unchecked(&fscache_n_acquires),
57495 + atomic_read_unchecked(&fscache_n_acquires_null),
57496 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57497 + atomic_read_unchecked(&fscache_n_acquires_ok),
57498 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57499 + atomic_read_unchecked(&fscache_n_acquires_oom));
57500
57501 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57502 - atomic_read(&fscache_n_object_lookups),
57503 - atomic_read(&fscache_n_object_lookups_negative),
57504 - atomic_read(&fscache_n_object_lookups_positive),
57505 - atomic_read(&fscache_n_object_created),
57506 - atomic_read(&fscache_n_object_lookups_timed_out));
57507 + atomic_read_unchecked(&fscache_n_object_lookups),
57508 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57509 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57510 + atomic_read_unchecked(&fscache_n_object_created),
57511 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57512
57513 seq_printf(m, "Invals : n=%u run=%u\n",
57514 - atomic_read(&fscache_n_invalidates),
57515 - atomic_read(&fscache_n_invalidates_run));
57516 + atomic_read_unchecked(&fscache_n_invalidates),
57517 + atomic_read_unchecked(&fscache_n_invalidates_run));
57518
57519 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57520 - atomic_read(&fscache_n_updates),
57521 - atomic_read(&fscache_n_updates_null),
57522 - atomic_read(&fscache_n_updates_run));
57523 + atomic_read_unchecked(&fscache_n_updates),
57524 + atomic_read_unchecked(&fscache_n_updates_null),
57525 + atomic_read_unchecked(&fscache_n_updates_run));
57526
57527 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57528 - atomic_read(&fscache_n_relinquishes),
57529 - atomic_read(&fscache_n_relinquishes_null),
57530 - atomic_read(&fscache_n_relinquishes_waitcrt),
57531 - atomic_read(&fscache_n_relinquishes_retire));
57532 + atomic_read_unchecked(&fscache_n_relinquishes),
57533 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57534 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57535 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57536
57537 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57538 - atomic_read(&fscache_n_attr_changed),
57539 - atomic_read(&fscache_n_attr_changed_ok),
57540 - atomic_read(&fscache_n_attr_changed_nobufs),
57541 - atomic_read(&fscache_n_attr_changed_nomem),
57542 - atomic_read(&fscache_n_attr_changed_calls));
57543 + atomic_read_unchecked(&fscache_n_attr_changed),
57544 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57545 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57546 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57547 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57548
57549 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57550 - atomic_read(&fscache_n_allocs),
57551 - atomic_read(&fscache_n_allocs_ok),
57552 - atomic_read(&fscache_n_allocs_wait),
57553 - atomic_read(&fscache_n_allocs_nobufs),
57554 - atomic_read(&fscache_n_allocs_intr));
57555 + atomic_read_unchecked(&fscache_n_allocs),
57556 + atomic_read_unchecked(&fscache_n_allocs_ok),
57557 + atomic_read_unchecked(&fscache_n_allocs_wait),
57558 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57559 + atomic_read_unchecked(&fscache_n_allocs_intr));
57560 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57561 - atomic_read(&fscache_n_alloc_ops),
57562 - atomic_read(&fscache_n_alloc_op_waits),
57563 - atomic_read(&fscache_n_allocs_object_dead));
57564 + atomic_read_unchecked(&fscache_n_alloc_ops),
57565 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57566 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57567
57568 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57569 " int=%u oom=%u\n",
57570 - atomic_read(&fscache_n_retrievals),
57571 - atomic_read(&fscache_n_retrievals_ok),
57572 - atomic_read(&fscache_n_retrievals_wait),
57573 - atomic_read(&fscache_n_retrievals_nodata),
57574 - atomic_read(&fscache_n_retrievals_nobufs),
57575 - atomic_read(&fscache_n_retrievals_intr),
57576 - atomic_read(&fscache_n_retrievals_nomem));
57577 + atomic_read_unchecked(&fscache_n_retrievals),
57578 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57579 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57580 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57581 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57582 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57583 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57584 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57585 - atomic_read(&fscache_n_retrieval_ops),
57586 - atomic_read(&fscache_n_retrieval_op_waits),
57587 - atomic_read(&fscache_n_retrievals_object_dead));
57588 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57589 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57590 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57591
57592 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57593 - atomic_read(&fscache_n_stores),
57594 - atomic_read(&fscache_n_stores_ok),
57595 - atomic_read(&fscache_n_stores_again),
57596 - atomic_read(&fscache_n_stores_nobufs),
57597 - atomic_read(&fscache_n_stores_oom));
57598 + atomic_read_unchecked(&fscache_n_stores),
57599 + atomic_read_unchecked(&fscache_n_stores_ok),
57600 + atomic_read_unchecked(&fscache_n_stores_again),
57601 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57602 + atomic_read_unchecked(&fscache_n_stores_oom));
57603 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57604 - atomic_read(&fscache_n_store_ops),
57605 - atomic_read(&fscache_n_store_calls),
57606 - atomic_read(&fscache_n_store_pages),
57607 - atomic_read(&fscache_n_store_radix_deletes),
57608 - atomic_read(&fscache_n_store_pages_over_limit));
57609 + atomic_read_unchecked(&fscache_n_store_ops),
57610 + atomic_read_unchecked(&fscache_n_store_calls),
57611 + atomic_read_unchecked(&fscache_n_store_pages),
57612 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57613 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57614
57615 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57616 - atomic_read(&fscache_n_store_vmscan_not_storing),
57617 - atomic_read(&fscache_n_store_vmscan_gone),
57618 - atomic_read(&fscache_n_store_vmscan_busy),
57619 - atomic_read(&fscache_n_store_vmscan_cancelled),
57620 - atomic_read(&fscache_n_store_vmscan_wait));
57621 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57622 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57623 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57624 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57625 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57626
57627 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57628 - atomic_read(&fscache_n_op_pend),
57629 - atomic_read(&fscache_n_op_run),
57630 - atomic_read(&fscache_n_op_enqueue),
57631 - atomic_read(&fscache_n_op_cancelled),
57632 - atomic_read(&fscache_n_op_rejected));
57633 + atomic_read_unchecked(&fscache_n_op_pend),
57634 + atomic_read_unchecked(&fscache_n_op_run),
57635 + atomic_read_unchecked(&fscache_n_op_enqueue),
57636 + atomic_read_unchecked(&fscache_n_op_cancelled),
57637 + atomic_read_unchecked(&fscache_n_op_rejected));
57638 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57639 - atomic_read(&fscache_n_op_deferred_release),
57640 - atomic_read(&fscache_n_op_release),
57641 - atomic_read(&fscache_n_op_gc));
57642 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57643 + atomic_read_unchecked(&fscache_n_op_release),
57644 + atomic_read_unchecked(&fscache_n_op_gc));
57645
57646 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57647 atomic_read(&fscache_n_cop_alloc_object),
57648 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57649 index adbfd66..4b25822 100644
57650 --- a/fs/fuse/cuse.c
57651 +++ b/fs/fuse/cuse.c
57652 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
57653 INIT_LIST_HEAD(&cuse_conntbl[i]);
57654
57655 /* inherit and extend fuse_dev_operations */
57656 - cuse_channel_fops = fuse_dev_operations;
57657 - cuse_channel_fops.owner = THIS_MODULE;
57658 - cuse_channel_fops.open = cuse_channel_open;
57659 - cuse_channel_fops.release = cuse_channel_release;
57660 + pax_open_kernel();
57661 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57662 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57663 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57664 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57665 + pax_close_kernel();
57666
57667 cuse_class = class_create(THIS_MODULE, "cuse");
57668 if (IS_ERR(cuse_class))
57669 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57670 index ef74ad5..c9ac759e 100644
57671 --- a/fs/fuse/dev.c
57672 +++ b/fs/fuse/dev.c
57673 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57674 ret = 0;
57675 pipe_lock(pipe);
57676
57677 - if (!pipe->readers) {
57678 + if (!atomic_read(&pipe->readers)) {
57679 send_sig(SIGPIPE, current, 0);
57680 if (!ret)
57681 ret = -EPIPE;
57682 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57683 page_nr++;
57684 ret += buf->len;
57685
57686 - if (pipe->files)
57687 + if (atomic_read(&pipe->files))
57688 do_wakeup = 1;
57689 }
57690
57691 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57692 index b7989f2..1f72ec4 100644
57693 --- a/fs/fuse/dir.c
57694 +++ b/fs/fuse/dir.c
57695 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
57696 return link;
57697 }
57698
57699 -static void free_link(char *link)
57700 +static void free_link(const char *link)
57701 {
57702 if (!IS_ERR(link))
57703 free_page((unsigned long) link);
57704 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57705 index 968d4c56..54a398d 100644
57706 --- a/fs/gfs2/inode.c
57707 +++ b/fs/gfs2/inode.c
57708 @@ -1512,7 +1512,7 @@ out:
57709
57710 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57711 {
57712 - char *s = nd_get_link(nd);
57713 + const char *s = nd_get_link(nd);
57714 if (!IS_ERR(s))
57715 kfree(s);
57716 }
57717 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
57718 index 2543728..14d7bd4 100644
57719 --- a/fs/hostfs/hostfs_kern.c
57720 +++ b/fs/hostfs/hostfs_kern.c
57721 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57722
57723 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57724 {
57725 - char *s = nd_get_link(nd);
57726 + const char *s = nd_get_link(nd);
57727 if (!IS_ERR(s))
57728 __putname(s);
57729 }
57730 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57731 index d19b30a..ef89c36 100644
57732 --- a/fs/hugetlbfs/inode.c
57733 +++ b/fs/hugetlbfs/inode.c
57734 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57735 struct mm_struct *mm = current->mm;
57736 struct vm_area_struct *vma;
57737 struct hstate *h = hstate_file(file);
57738 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57739 struct vm_unmapped_area_info info;
57740
57741 if (len & ~huge_page_mask(h))
57742 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57743 return addr;
57744 }
57745
57746 +#ifdef CONFIG_PAX_RANDMMAP
57747 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57748 +#endif
57749 +
57750 if (addr) {
57751 addr = ALIGN(addr, huge_page_size(h));
57752 vma = find_vma(mm, addr);
57753 - if (TASK_SIZE - len >= addr &&
57754 - (!vma || addr + len <= vma->vm_start))
57755 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57756 return addr;
57757 }
57758
57759 info.flags = 0;
57760 info.length = len;
57761 info.low_limit = TASK_UNMAPPED_BASE;
57762 +
57763 +#ifdef CONFIG_PAX_RANDMMAP
57764 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57765 + info.low_limit += mm->delta_mmap;
57766 +#endif
57767 +
57768 info.high_limit = TASK_SIZE;
57769 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57770 info.align_offset = 0;
57771 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57772 };
57773 MODULE_ALIAS_FS("hugetlbfs");
57774
57775 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57776 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57777
57778 static int can_do_hugetlb_shm(void)
57779 {
57780 diff --git a/fs/inode.c b/fs/inode.c
57781 index b33ba8e..3c79a47 100644
57782 --- a/fs/inode.c
57783 +++ b/fs/inode.c
57784 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
57785
57786 #ifdef CONFIG_SMP
57787 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57788 - static atomic_t shared_last_ino;
57789 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57790 + static atomic_unchecked_t shared_last_ino;
57791 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57792
57793 res = next - LAST_INO_BATCH;
57794 }
57795 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57796 index 4a6cf28..d3a29d3 100644
57797 --- a/fs/jffs2/erase.c
57798 +++ b/fs/jffs2/erase.c
57799 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57800 struct jffs2_unknown_node marker = {
57801 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57802 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57803 - .totlen = cpu_to_je32(c->cleanmarker_size)
57804 + .totlen = cpu_to_je32(c->cleanmarker_size),
57805 + .hdr_crc = cpu_to_je32(0)
57806 };
57807
57808 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57809 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57810 index a6597d6..41b30ec 100644
57811 --- a/fs/jffs2/wbuf.c
57812 +++ b/fs/jffs2/wbuf.c
57813 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57814 {
57815 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57816 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57817 - .totlen = constant_cpu_to_je32(8)
57818 + .totlen = constant_cpu_to_je32(8),
57819 + .hdr_crc = constant_cpu_to_je32(0)
57820 };
57821
57822 /*
57823 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57824 index 6669aa2..36b033d 100644
57825 --- a/fs/jfs/super.c
57826 +++ b/fs/jfs/super.c
57827 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57828
57829 jfs_inode_cachep =
57830 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57831 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57832 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57833 init_once);
57834 if (jfs_inode_cachep == NULL)
57835 return -ENOMEM;
57836 diff --git a/fs/libfs.c b/fs/libfs.c
57837 index 3a3a9b5..3a9b074 100644
57838 --- a/fs/libfs.c
57839 +++ b/fs/libfs.c
57840 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57841
57842 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57843 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57844 + char d_name[sizeof(next->d_iname)];
57845 + const unsigned char *name;
57846 +
57847 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57848 if (!simple_positive(next)) {
57849 spin_unlock(&next->d_lock);
57850 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57851
57852 spin_unlock(&next->d_lock);
57853 spin_unlock(&dentry->d_lock);
57854 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57855 + name = next->d_name.name;
57856 + if (name == next->d_iname) {
57857 + memcpy(d_name, name, next->d_name.len);
57858 + name = d_name;
57859 + }
57860 + if (!dir_emit(ctx, name, next->d_name.len,
57861 next->d_inode->i_ino, dt_type(next->d_inode)))
57862 return 0;
57863 spin_lock(&dentry->d_lock);
57864 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57865 index acd3947..1f896e2 100644
57866 --- a/fs/lockd/clntproc.c
57867 +++ b/fs/lockd/clntproc.c
57868 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57869 /*
57870 * Cookie counter for NLM requests
57871 */
57872 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57873 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57874
57875 void nlmclnt_next_cookie(struct nlm_cookie *c)
57876 {
57877 - u32 cookie = atomic_inc_return(&nlm_cookie);
57878 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57879
57880 memcpy(c->data, &cookie, 4);
57881 c->len=4;
57882 diff --git a/fs/locks.c b/fs/locks.c
57883 index b27a300..4156d0b 100644
57884 --- a/fs/locks.c
57885 +++ b/fs/locks.c
57886 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57887 return;
57888
57889 if (filp->f_op && filp->f_op->flock) {
57890 - struct file_lock fl = {
57891 + struct file_lock flock = {
57892 .fl_pid = current->tgid,
57893 .fl_file = filp,
57894 .fl_flags = FL_FLOCK,
57895 .fl_type = F_UNLCK,
57896 .fl_end = OFFSET_MAX,
57897 };
57898 - filp->f_op->flock(filp, F_SETLKW, &fl);
57899 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57900 - fl.fl_ops->fl_release_private(&fl);
57901 + filp->f_op->flock(filp, F_SETLKW, &flock);
57902 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57903 + flock.fl_ops->fl_release_private(&flock);
57904 }
57905
57906 spin_lock(&inode->i_lock);
57907 diff --git a/fs/namei.c b/fs/namei.c
57908 index caa2805..c9d3edc 100644
57909 --- a/fs/namei.c
57910 +++ b/fs/namei.c
57911 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57912 if (ret != -EACCES)
57913 return ret;
57914
57915 +#ifdef CONFIG_GRKERNSEC
57916 + /* we'll block if we have to log due to a denied capability use */
57917 + if (mask & MAY_NOT_BLOCK)
57918 + return -ECHILD;
57919 +#endif
57920 +
57921 if (S_ISDIR(inode->i_mode)) {
57922 /* DACs are overridable for directories */
57923 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57924 - return 0;
57925 if (!(mask & MAY_WRITE))
57926 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57927 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57928 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57929 return 0;
57930 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57931 + return 0;
57932 return -EACCES;
57933 }
57934 /*
57935 + * Searching includes executable on directories, else just read.
57936 + */
57937 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57938 + if (mask == MAY_READ)
57939 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57940 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57941 + return 0;
57942 +
57943 + /*
57944 * Read/write DACs are always overridable.
57945 * Executable DACs are overridable when there is
57946 * at least one exec bit set.
57947 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57948 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57949 return 0;
57950
57951 - /*
57952 - * Searching includes executable on directories, else just read.
57953 - */
57954 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57955 - if (mask == MAY_READ)
57956 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57957 - return 0;
57958 -
57959 return -EACCES;
57960 }
57961
57962 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57963 {
57964 struct dentry *dentry = link->dentry;
57965 int error;
57966 - char *s;
57967 + const char *s;
57968
57969 BUG_ON(nd->flags & LOOKUP_RCU);
57970
57971 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57972 if (error)
57973 goto out_put_nd_path;
57974
57975 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57976 + dentry->d_inode, dentry, nd->path.mnt)) {
57977 + error = -EACCES;
57978 + goto out_put_nd_path;
57979 + }
57980 +
57981 nd->last_type = LAST_BIND;
57982 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57983 error = PTR_ERR(*p);
57984 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57985 if (res)
57986 break;
57987 res = walk_component(nd, path, LOOKUP_FOLLOW);
57988 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57989 + res = -EACCES;
57990 put_link(nd, &link, cookie);
57991 } while (res > 0);
57992
57993 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
57994 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57995 {
57996 unsigned long a, b, adata, bdata, mask, hash, len;
57997 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57998 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57999
58000 hash = a = 0;
58001 len = -sizeof(unsigned long);
58002 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
58003 if (err)
58004 break;
58005 err = lookup_last(nd, &path);
58006 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58007 + err = -EACCES;
58008 put_link(nd, &link, cookie);
58009 }
58010 }
58011 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58012 if (!err)
58013 err = complete_walk(nd);
58014
58015 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58016 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58017 + path_put(&nd->path);
58018 + err = -ENOENT;
58019 + }
58020 + }
58021 +
58022 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58023 if (!can_lookup(nd->inode)) {
58024 path_put(&nd->path);
58025 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58026 retval = path_lookupat(dfd, name->name,
58027 flags | LOOKUP_REVAL, nd);
58028
58029 - if (likely(!retval))
58030 + if (likely(!retval)) {
58031 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58032 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58033 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58034 + path_put(&nd->path);
58035 + return -ENOENT;
58036 + }
58037 + }
58038 + }
58039 return retval;
58040 }
58041
58042 @@ -2586,6 +2618,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58043 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58044 return -EPERM;
58045
58046 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58047 + return -EPERM;
58048 + if (gr_handle_rawio(inode))
58049 + return -EPERM;
58050 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58051 + return -EACCES;
58052 +
58053 return 0;
58054 }
58055
58056 @@ -2817,7 +2856,7 @@ looked_up:
58057 * cleared otherwise prior to returning.
58058 */
58059 static int lookup_open(struct nameidata *nd, struct path *path,
58060 - struct file *file,
58061 + struct path *link, struct file *file,
58062 const struct open_flags *op,
58063 bool got_write, int *opened)
58064 {
58065 @@ -2852,6 +2891,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58066 /* Negative dentry, just create the file */
58067 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58068 umode_t mode = op->mode;
58069 +
58070 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58071 + error = -EACCES;
58072 + goto out_dput;
58073 + }
58074 +
58075 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58076 + error = -EACCES;
58077 + goto out_dput;
58078 + }
58079 +
58080 if (!IS_POSIXACL(dir->d_inode))
58081 mode &= ~current_umask();
58082 /*
58083 @@ -2873,6 +2923,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58084 nd->flags & LOOKUP_EXCL);
58085 if (error)
58086 goto out_dput;
58087 + else
58088 + gr_handle_create(dentry, nd->path.mnt);
58089 }
58090 out_no_open:
58091 path->dentry = dentry;
58092 @@ -2887,7 +2939,7 @@ out_dput:
58093 /*
58094 * Handle the last step of open()
58095 */
58096 -static int do_last(struct nameidata *nd, struct path *path,
58097 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58098 struct file *file, const struct open_flags *op,
58099 int *opened, struct filename *name)
58100 {
58101 @@ -2937,6 +2989,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58102 if (error)
58103 return error;
58104
58105 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58106 + error = -ENOENT;
58107 + goto out;
58108 + }
58109 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58110 + error = -EACCES;
58111 + goto out;
58112 + }
58113 +
58114 audit_inode(name, dir, LOOKUP_PARENT);
58115 error = -EISDIR;
58116 /* trailing slashes? */
58117 @@ -2956,7 +3017,7 @@ retry_lookup:
58118 */
58119 }
58120 mutex_lock(&dir->d_inode->i_mutex);
58121 - error = lookup_open(nd, path, file, op, got_write, opened);
58122 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58123 mutex_unlock(&dir->d_inode->i_mutex);
58124
58125 if (error <= 0) {
58126 @@ -2980,11 +3041,28 @@ retry_lookup:
58127 goto finish_open_created;
58128 }
58129
58130 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58131 + error = -ENOENT;
58132 + goto exit_dput;
58133 + }
58134 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58135 + error = -EACCES;
58136 + goto exit_dput;
58137 + }
58138 +
58139 /*
58140 * create/update audit record if it already exists.
58141 */
58142 - if (path->dentry->d_inode)
58143 + if (path->dentry->d_inode) {
58144 + /* only check if O_CREAT is specified, all other checks need to go
58145 + into may_open */
58146 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58147 + error = -EACCES;
58148 + goto exit_dput;
58149 + }
58150 +
58151 audit_inode(name, path->dentry, 0);
58152 + }
58153
58154 /*
58155 * If atomic_open() acquired write access it is dropped now due to
58156 @@ -3025,6 +3103,11 @@ finish_lookup:
58157 }
58158 }
58159 BUG_ON(inode != path->dentry->d_inode);
58160 + /* if we're resolving a symlink to another symlink */
58161 + if (link && gr_handle_symlink_owner(link, inode)) {
58162 + error = -EACCES;
58163 + goto out;
58164 + }
58165 return 1;
58166 }
58167
58168 @@ -3034,7 +3117,6 @@ finish_lookup:
58169 save_parent.dentry = nd->path.dentry;
58170 save_parent.mnt = mntget(path->mnt);
58171 nd->path.dentry = path->dentry;
58172 -
58173 }
58174 nd->inode = inode;
58175 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58176 @@ -3044,7 +3126,18 @@ finish_open:
58177 path_put(&save_parent);
58178 return error;
58179 }
58180 +
58181 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58182 + error = -ENOENT;
58183 + goto out;
58184 + }
58185 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58186 + error = -EACCES;
58187 + goto out;
58188 + }
58189 +
58190 audit_inode(name, nd->path.dentry, 0);
58191 +
58192 error = -EISDIR;
58193 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58194 goto out;
58195 @@ -3207,7 +3300,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58196 if (unlikely(error))
58197 goto out;
58198
58199 - error = do_last(nd, &path, file, op, &opened, pathname);
58200 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58201 while (unlikely(error > 0)) { /* trailing symlink */
58202 struct path link = path;
58203 void *cookie;
58204 @@ -3225,7 +3318,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58205 error = follow_link(&link, nd, &cookie);
58206 if (unlikely(error))
58207 break;
58208 - error = do_last(nd, &path, file, op, &opened, pathname);
58209 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58210 put_link(nd, &link, cookie);
58211 }
58212 out:
58213 @@ -3325,8 +3418,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58214 goto unlock;
58215
58216 error = -EEXIST;
58217 - if (dentry->d_inode)
58218 + if (dentry->d_inode) {
58219 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58220 + error = -ENOENT;
58221 + }
58222 goto fail;
58223 + }
58224 /*
58225 * Special case - lookup gave negative, but... we had foo/bar/
58226 * From the vfs_mknod() POV we just have a negative dentry -
58227 @@ -3378,6 +3475,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58228 }
58229 EXPORT_SYMBOL(user_path_create);
58230
58231 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58232 +{
58233 + struct filename *tmp = getname(pathname);
58234 + struct dentry *res;
58235 + if (IS_ERR(tmp))
58236 + return ERR_CAST(tmp);
58237 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58238 + if (IS_ERR(res))
58239 + putname(tmp);
58240 + else
58241 + *to = tmp;
58242 + return res;
58243 +}
58244 +
58245 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58246 {
58247 int error = may_create(dir, dentry);
58248 @@ -3440,6 +3551,17 @@ retry:
58249
58250 if (!IS_POSIXACL(path.dentry->d_inode))
58251 mode &= ~current_umask();
58252 +
58253 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58254 + error = -EPERM;
58255 + goto out;
58256 + }
58257 +
58258 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58259 + error = -EACCES;
58260 + goto out;
58261 + }
58262 +
58263 error = security_path_mknod(&path, dentry, mode, dev);
58264 if (error)
58265 goto out;
58266 @@ -3456,6 +3578,8 @@ retry:
58267 break;
58268 }
58269 out:
58270 + if (!error)
58271 + gr_handle_create(dentry, path.mnt);
58272 done_path_create(&path, dentry);
58273 if (retry_estale(error, lookup_flags)) {
58274 lookup_flags |= LOOKUP_REVAL;
58275 @@ -3508,9 +3632,16 @@ retry:
58276
58277 if (!IS_POSIXACL(path.dentry->d_inode))
58278 mode &= ~current_umask();
58279 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58280 + error = -EACCES;
58281 + goto out;
58282 + }
58283 error = security_path_mkdir(&path, dentry, mode);
58284 if (!error)
58285 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58286 + if (!error)
58287 + gr_handle_create(dentry, path.mnt);
58288 +out:
58289 done_path_create(&path, dentry);
58290 if (retry_estale(error, lookup_flags)) {
58291 lookup_flags |= LOOKUP_REVAL;
58292 @@ -3591,6 +3722,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
58293 struct filename *name;
58294 struct dentry *dentry;
58295 struct nameidata nd;
58296 + ino_t saved_ino = 0;
58297 + dev_t saved_dev = 0;
58298 unsigned int lookup_flags = 0;
58299 retry:
58300 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58301 @@ -3623,10 +3756,21 @@ retry:
58302 error = -ENOENT;
58303 goto exit3;
58304 }
58305 +
58306 + saved_ino = dentry->d_inode->i_ino;
58307 + saved_dev = gr_get_dev_from_dentry(dentry);
58308 +
58309 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
58310 + error = -EACCES;
58311 + goto exit3;
58312 + }
58313 +
58314 error = security_path_rmdir(&nd.path, dentry);
58315 if (error)
58316 goto exit3;
58317 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
58318 + if (!error && (saved_dev || saved_ino))
58319 + gr_handle_delete(saved_ino, saved_dev);
58320 exit3:
58321 dput(dentry);
58322 exit2:
58323 @@ -3692,6 +3836,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58324 struct dentry *dentry;
58325 struct nameidata nd;
58326 struct inode *inode = NULL;
58327 + ino_t saved_ino = 0;
58328 + dev_t saved_dev = 0;
58329 unsigned int lookup_flags = 0;
58330 retry:
58331 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58332 @@ -3718,10 +3864,22 @@ retry:
58333 if (!inode)
58334 goto slashes;
58335 ihold(inode);
58336 +
58337 + if (inode->i_nlink <= 1) {
58338 + saved_ino = inode->i_ino;
58339 + saved_dev = gr_get_dev_from_dentry(dentry);
58340 + }
58341 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58342 + error = -EACCES;
58343 + goto exit2;
58344 + }
58345 +
58346 error = security_path_unlink(&nd.path, dentry);
58347 if (error)
58348 goto exit2;
58349 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58350 + if (!error && (saved_ino || saved_dev))
58351 + gr_handle_delete(saved_ino, saved_dev);
58352 exit2:
58353 dput(dentry);
58354 }
58355 @@ -3799,9 +3957,17 @@ retry:
58356 if (IS_ERR(dentry))
58357 goto out_putname;
58358
58359 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58360 + error = -EACCES;
58361 + goto out;
58362 + }
58363 +
58364 error = security_path_symlink(&path, dentry, from->name);
58365 if (!error)
58366 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58367 + if (!error)
58368 + gr_handle_create(dentry, path.mnt);
58369 +out:
58370 done_path_create(&path, dentry);
58371 if (retry_estale(error, lookup_flags)) {
58372 lookup_flags |= LOOKUP_REVAL;
58373 @@ -3881,6 +4047,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58374 {
58375 struct dentry *new_dentry;
58376 struct path old_path, new_path;
58377 + struct filename *to = NULL;
58378 int how = 0;
58379 int error;
58380
58381 @@ -3904,7 +4071,7 @@ retry:
58382 if (error)
58383 return error;
58384
58385 - new_dentry = user_path_create(newdfd, newname, &new_path,
58386 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58387 (how & LOOKUP_REVAL));
58388 error = PTR_ERR(new_dentry);
58389 if (IS_ERR(new_dentry))
58390 @@ -3916,11 +4083,28 @@ retry:
58391 error = may_linkat(&old_path);
58392 if (unlikely(error))
58393 goto out_dput;
58394 +
58395 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58396 + old_path.dentry->d_inode,
58397 + old_path.dentry->d_inode->i_mode, to)) {
58398 + error = -EACCES;
58399 + goto out_dput;
58400 + }
58401 +
58402 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58403 + old_path.dentry, old_path.mnt, to)) {
58404 + error = -EACCES;
58405 + goto out_dput;
58406 + }
58407 +
58408 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58409 if (error)
58410 goto out_dput;
58411 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58412 + if (!error)
58413 + gr_handle_create(new_dentry, new_path.mnt);
58414 out_dput:
58415 + putname(to);
58416 done_path_create(&new_path, new_dentry);
58417 if (retry_estale(error, how)) {
58418 how |= LOOKUP_REVAL;
58419 @@ -4166,12 +4350,21 @@ retry:
58420 if (new_dentry == trap)
58421 goto exit5;
58422
58423 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58424 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58425 + to);
58426 + if (error)
58427 + goto exit5;
58428 +
58429 error = security_path_rename(&oldnd.path, old_dentry,
58430 &newnd.path, new_dentry);
58431 if (error)
58432 goto exit5;
58433 error = vfs_rename(old_dir->d_inode, old_dentry,
58434 new_dir->d_inode, new_dentry);
58435 + if (!error)
58436 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58437 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58438 exit5:
58439 dput(new_dentry);
58440 exit4:
58441 @@ -4203,6 +4396,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58442
58443 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58444 {
58445 + char tmpbuf[64];
58446 + const char *newlink;
58447 int len;
58448
58449 len = PTR_ERR(link);
58450 @@ -4212,7 +4407,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58451 len = strlen(link);
58452 if (len > (unsigned) buflen)
58453 len = buflen;
58454 - if (copy_to_user(buffer, link, len))
58455 +
58456 + if (len < sizeof(tmpbuf)) {
58457 + memcpy(tmpbuf, link, len);
58458 + newlink = tmpbuf;
58459 + } else
58460 + newlink = link;
58461 +
58462 + if (copy_to_user(buffer, newlink, len))
58463 len = -EFAULT;
58464 out:
58465 return len;
58466 diff --git a/fs/namespace.c b/fs/namespace.c
58467 index da5c494..a755a54 100644
58468 --- a/fs/namespace.c
58469 +++ b/fs/namespace.c
58470 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
58471 if (!(sb->s_flags & MS_RDONLY))
58472 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58473 up_write(&sb->s_umount);
58474 +
58475 + gr_log_remount(mnt->mnt_devname, retval);
58476 +
58477 return retval;
58478 }
58479
58480 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
58481 }
58482 br_write_unlock(&vfsmount_lock);
58483 namespace_unlock();
58484 +
58485 + gr_log_unmount(mnt->mnt_devname, retval);
58486 +
58487 return retval;
58488 }
58489
58490 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
58491 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58492 */
58493
58494 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58495 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58496 {
58497 struct path path;
58498 struct mount *mnt;
58499 @@ -1347,7 +1353,7 @@ out:
58500 /*
58501 * The 2.0 compatible umount. No flags.
58502 */
58503 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58504 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58505 {
58506 return sys_umount(name, 0);
58507 }
58508 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58509 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58510 MS_STRICTATIME);
58511
58512 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58513 + retval = -EPERM;
58514 + goto dput_out;
58515 + }
58516 +
58517 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58518 + retval = -EPERM;
58519 + goto dput_out;
58520 + }
58521 +
58522 if (flags & MS_REMOUNT)
58523 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58524 data_page);
58525 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58526 dev_name, data_page);
58527 dput_out:
58528 path_put(&path);
58529 +
58530 + gr_log_mount(dev_name, dir_name, retval);
58531 +
58532 return retval;
58533 }
58534
58535 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58536 * number incrementing at 10Ghz will take 12,427 years to wrap which
58537 * is effectively never, so we can ignore the possibility.
58538 */
58539 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58540 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58541
58542 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58543 {
58544 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58545 kfree(new_ns);
58546 return ERR_PTR(ret);
58547 }
58548 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58549 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58550 atomic_set(&new_ns->count, 1);
58551 new_ns->root = NULL;
58552 INIT_LIST_HEAD(&new_ns->list);
58553 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58554 * Allocate a new namespace structure and populate it with contents
58555 * copied from the namespace of the passed in task structure.
58556 */
58557 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58558 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58559 struct user_namespace *user_ns, struct fs_struct *fs)
58560 {
58561 struct mnt_namespace *new_ns;
58562 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58563 }
58564 EXPORT_SYMBOL(mount_subtree);
58565
58566 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58567 - char __user *, type, unsigned long, flags, void __user *, data)
58568 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58569 + const char __user *, type, unsigned long, flags, void __user *, data)
58570 {
58571 int ret;
58572 char *kernel_type;
58573 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58574 if (error)
58575 goto out2;
58576
58577 + if (gr_handle_chroot_pivot()) {
58578 + error = -EPERM;
58579 + goto out2;
58580 + }
58581 +
58582 get_fs_root(current->fs, &root);
58583 old_mp = lock_mount(&old);
58584 error = PTR_ERR(old_mp);
58585 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58586 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
58587 return -EPERM;
58588
58589 - if (fs->users != 1)
58590 + if (atomic_read(&fs->users) != 1)
58591 return -EINVAL;
58592
58593 get_mnt_ns(mnt_ns);
58594 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58595 index f4ccfe6..a5cf064 100644
58596 --- a/fs/nfs/callback_xdr.c
58597 +++ b/fs/nfs/callback_xdr.c
58598 @@ -51,7 +51,7 @@ struct callback_op {
58599 callback_decode_arg_t decode_args;
58600 callback_encode_res_t encode_res;
58601 long res_maxsize;
58602 -};
58603 +} __do_const;
58604
58605 static struct callback_op callback_ops[];
58606
58607 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58608 index eda8879..bfc6837 100644
58609 --- a/fs/nfs/inode.c
58610 +++ b/fs/nfs/inode.c
58611 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58612 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58613 }
58614
58615 -static atomic_long_t nfs_attr_generation_counter;
58616 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58617
58618 static unsigned long nfs_read_attr_generation_counter(void)
58619 {
58620 - return atomic_long_read(&nfs_attr_generation_counter);
58621 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58622 }
58623
58624 unsigned long nfs_inc_attr_generation_counter(void)
58625 {
58626 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58627 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58628 }
58629
58630 void nfs_fattr_init(struct nfs_fattr *fattr)
58631 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58632 index 419572f..5414a23 100644
58633 --- a/fs/nfsd/nfs4proc.c
58634 +++ b/fs/nfsd/nfs4proc.c
58635 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58636 nfsd4op_rsize op_rsize_bop;
58637 stateid_getter op_get_currentstateid;
58638 stateid_setter op_set_currentstateid;
58639 -};
58640 +} __do_const;
58641
58642 static struct nfsd4_operation nfsd4_ops[];
58643
58644 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58645 index ecc735e..79b2d31 100644
58646 --- a/fs/nfsd/nfs4xdr.c
58647 +++ b/fs/nfsd/nfs4xdr.c
58648 @@ -1500,7 +1500,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58649
58650 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58651
58652 -static nfsd4_dec nfsd4_dec_ops[] = {
58653 +static const nfsd4_dec nfsd4_dec_ops[] = {
58654 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58655 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58656 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58657 @@ -1540,7 +1540,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58658 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58659 };
58660
58661 -static nfsd4_dec nfsd41_dec_ops[] = {
58662 +static const nfsd4_dec nfsd41_dec_ops[] = {
58663 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58664 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58665 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58666 @@ -1602,7 +1602,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58667 };
58668
58669 struct nfsd4_minorversion_ops {
58670 - nfsd4_dec *decoders;
58671 + const nfsd4_dec *decoders;
58672 int nops;
58673 };
58674
58675 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58676 index 9186c7c..3fdde3e 100644
58677 --- a/fs/nfsd/nfscache.c
58678 +++ b/fs/nfsd/nfscache.c
58679 @@ -540,14 +540,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58680 {
58681 struct svc_cacherep *rp = rqstp->rq_cacherep;
58682 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58683 - int len;
58684 + long len;
58685 size_t bufsize = 0;
58686
58687 if (!rp)
58688 return;
58689
58690 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58691 - len >>= 2;
58692 + if (statp) {
58693 + len = (char*)statp - (char*)resv->iov_base;
58694 + len = resv->iov_len - len;
58695 + len >>= 2;
58696 + }
58697
58698 /* Don't cache excessive amounts of data and XDR failures */
58699 if (!statp || len > (256 >> 2)) {
58700 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58701 index 72cb28e..5b5f87d 100644
58702 --- a/fs/nfsd/vfs.c
58703 +++ b/fs/nfsd/vfs.c
58704 @@ -993,7 +993,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58705 } else {
58706 oldfs = get_fs();
58707 set_fs(KERNEL_DS);
58708 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58709 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58710 set_fs(oldfs);
58711 }
58712
58713 @@ -1080,7 +1080,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58714
58715 /* Write the data. */
58716 oldfs = get_fs(); set_fs(KERNEL_DS);
58717 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58718 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58719 set_fs(oldfs);
58720 if (host_err < 0)
58721 goto out_nfserr;
58722 @@ -1626,7 +1626,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58723 */
58724
58725 oldfs = get_fs(); set_fs(KERNEL_DS);
58726 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58727 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58728 set_fs(oldfs);
58729
58730 if (host_err < 0)
58731 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58732 index fea6bd5..8ee9d81 100644
58733 --- a/fs/nls/nls_base.c
58734 +++ b/fs/nls/nls_base.c
58735 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58736
58737 int register_nls(struct nls_table * nls)
58738 {
58739 - struct nls_table ** tmp = &tables;
58740 + struct nls_table *tmp = tables;
58741
58742 if (nls->next)
58743 return -EBUSY;
58744
58745 spin_lock(&nls_lock);
58746 - while (*tmp) {
58747 - if (nls == *tmp) {
58748 + while (tmp) {
58749 + if (nls == tmp) {
58750 spin_unlock(&nls_lock);
58751 return -EBUSY;
58752 }
58753 - tmp = &(*tmp)->next;
58754 + tmp = tmp->next;
58755 }
58756 - nls->next = tables;
58757 + pax_open_kernel();
58758 + *(struct nls_table **)&nls->next = tables;
58759 + pax_close_kernel();
58760 tables = nls;
58761 spin_unlock(&nls_lock);
58762 return 0;
58763 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58764
58765 int unregister_nls(struct nls_table * nls)
58766 {
58767 - struct nls_table ** tmp = &tables;
58768 + struct nls_table * const * tmp = &tables;
58769
58770 spin_lock(&nls_lock);
58771 while (*tmp) {
58772 if (nls == *tmp) {
58773 - *tmp = nls->next;
58774 + pax_open_kernel();
58775 + *(struct nls_table **)tmp = nls->next;
58776 + pax_close_kernel();
58777 spin_unlock(&nls_lock);
58778 return 0;
58779 }
58780 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58781 index 7424929..35f6be5 100644
58782 --- a/fs/nls/nls_euc-jp.c
58783 +++ b/fs/nls/nls_euc-jp.c
58784 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58785 p_nls = load_nls("cp932");
58786
58787 if (p_nls) {
58788 - table.charset2upper = p_nls->charset2upper;
58789 - table.charset2lower = p_nls->charset2lower;
58790 + pax_open_kernel();
58791 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58792 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58793 + pax_close_kernel();
58794 return register_nls(&table);
58795 }
58796
58797 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58798 index e7bc1d7..06bd4bb 100644
58799 --- a/fs/nls/nls_koi8-ru.c
58800 +++ b/fs/nls/nls_koi8-ru.c
58801 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58802 p_nls = load_nls("koi8-u");
58803
58804 if (p_nls) {
58805 - table.charset2upper = p_nls->charset2upper;
58806 - table.charset2lower = p_nls->charset2lower;
58807 + pax_open_kernel();
58808 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58809 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58810 + pax_close_kernel();
58811 return register_nls(&table);
58812 }
58813
58814 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58815 index e44cb64..4807084 100644
58816 --- a/fs/notify/fanotify/fanotify_user.c
58817 +++ b/fs/notify/fanotify/fanotify_user.c
58818 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58819
58820 fd = fanotify_event_metadata.fd;
58821 ret = -EFAULT;
58822 - if (copy_to_user(buf, &fanotify_event_metadata,
58823 - fanotify_event_metadata.event_len))
58824 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58825 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58826 goto out_close_fd;
58827
58828 ret = prepare_for_access_response(group, event, fd);
58829 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58830 index 7b51b05..5ea5ef6 100644
58831 --- a/fs/notify/notification.c
58832 +++ b/fs/notify/notification.c
58833 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58834 * get set to 0 so it will never get 'freed'
58835 */
58836 static struct fsnotify_event *q_overflow_event;
58837 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58838 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58839
58840 /**
58841 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58842 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58843 */
58844 u32 fsnotify_get_cookie(void)
58845 {
58846 - return atomic_inc_return(&fsnotify_sync_cookie);
58847 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58848 }
58849 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58850
58851 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58852 index 9e38daf..5727cae 100644
58853 --- a/fs/ntfs/dir.c
58854 +++ b/fs/ntfs/dir.c
58855 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58856 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58857 ~(s64)(ndir->itype.index.block_size - 1)));
58858 /* Bounds checks. */
58859 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58860 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58861 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58862 "inode 0x%lx or driver bug.", vdir->i_ino);
58863 goto err_out;
58864 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58865 index ea4ba9d..1e13d34 100644
58866 --- a/fs/ntfs/file.c
58867 +++ b/fs/ntfs/file.c
58868 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58869 char *addr;
58870 size_t total = 0;
58871 unsigned len;
58872 - int left;
58873 + unsigned left;
58874
58875 do {
58876 len = PAGE_CACHE_SIZE - ofs;
58877 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58878 index 82650d5..db37dcf 100644
58879 --- a/fs/ntfs/super.c
58880 +++ b/fs/ntfs/super.c
58881 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58882 if (!silent)
58883 ntfs_error(sb, "Primary boot sector is invalid.");
58884 } else if (!silent)
58885 - ntfs_error(sb, read_err_str, "primary");
58886 + ntfs_error(sb, read_err_str, "%s", "primary");
58887 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58888 if (bh_primary)
58889 brelse(bh_primary);
58890 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58891 goto hotfix_primary_boot_sector;
58892 brelse(bh_backup);
58893 } else if (!silent)
58894 - ntfs_error(sb, read_err_str, "backup");
58895 + ntfs_error(sb, read_err_str, "%s", "backup");
58896 /* Try to read NT3.51- backup boot sector. */
58897 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58898 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58899 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58900 "sector.");
58901 brelse(bh_backup);
58902 } else if (!silent)
58903 - ntfs_error(sb, read_err_str, "backup");
58904 + ntfs_error(sb, read_err_str, "%s", "backup");
58905 /* We failed. Cleanup and return. */
58906 if (bh_primary)
58907 brelse(bh_primary);
58908 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58909 index cd5496b..26a1055 100644
58910 --- a/fs/ocfs2/localalloc.c
58911 +++ b/fs/ocfs2/localalloc.c
58912 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58913 goto bail;
58914 }
58915
58916 - atomic_inc(&osb->alloc_stats.moves);
58917 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58918
58919 bail:
58920 if (handle)
58921 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58922 index 3a90347..c40bef8 100644
58923 --- a/fs/ocfs2/ocfs2.h
58924 +++ b/fs/ocfs2/ocfs2.h
58925 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58926
58927 struct ocfs2_alloc_stats
58928 {
58929 - atomic_t moves;
58930 - atomic_t local_data;
58931 - atomic_t bitmap_data;
58932 - atomic_t bg_allocs;
58933 - atomic_t bg_extends;
58934 + atomic_unchecked_t moves;
58935 + atomic_unchecked_t local_data;
58936 + atomic_unchecked_t bitmap_data;
58937 + atomic_unchecked_t bg_allocs;
58938 + atomic_unchecked_t bg_extends;
58939 };
58940
58941 enum ocfs2_local_alloc_state
58942 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58943 index 5397c07..54afc55 100644
58944 --- a/fs/ocfs2/suballoc.c
58945 +++ b/fs/ocfs2/suballoc.c
58946 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58947 mlog_errno(status);
58948 goto bail;
58949 }
58950 - atomic_inc(&osb->alloc_stats.bg_extends);
58951 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58952
58953 /* You should never ask for this much metadata */
58954 BUG_ON(bits_wanted >
58955 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58956 mlog_errno(status);
58957 goto bail;
58958 }
58959 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58960 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58961
58962 *suballoc_loc = res.sr_bg_blkno;
58963 *suballoc_bit_start = res.sr_bit_offset;
58964 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58965 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58966 res->sr_bits);
58967
58968 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58969 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58970
58971 BUG_ON(res->sr_bits != 1);
58972
58973 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58974 mlog_errno(status);
58975 goto bail;
58976 }
58977 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58978 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58979
58980 BUG_ON(res.sr_bits != 1);
58981
58982 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58983 cluster_start,
58984 num_clusters);
58985 if (!status)
58986 - atomic_inc(&osb->alloc_stats.local_data);
58987 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58988 } else {
58989 if (min_clusters > (osb->bitmap_cpg - 1)) {
58990 /* The only paths asking for contiguousness
58991 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58992 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58993 res.sr_bg_blkno,
58994 res.sr_bit_offset);
58995 - atomic_inc(&osb->alloc_stats.bitmap_data);
58996 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58997 *num_clusters = res.sr_bits;
58998 }
58999 }
59000 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59001 index d4e81e4..ad89f5f 100644
59002 --- a/fs/ocfs2/super.c
59003 +++ b/fs/ocfs2/super.c
59004 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59005 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59006 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59007 "Stats",
59008 - atomic_read(&osb->alloc_stats.bitmap_data),
59009 - atomic_read(&osb->alloc_stats.local_data),
59010 - atomic_read(&osb->alloc_stats.bg_allocs),
59011 - atomic_read(&osb->alloc_stats.moves),
59012 - atomic_read(&osb->alloc_stats.bg_extends));
59013 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59014 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59015 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59016 + atomic_read_unchecked(&osb->alloc_stats.moves),
59017 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59018
59019 out += snprintf(buf + out, len - out,
59020 "%10s => State: %u Descriptor: %llu Size: %u bits "
59021 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59022 spin_lock_init(&osb->osb_xattr_lock);
59023 ocfs2_init_steal_slots(osb);
59024
59025 - atomic_set(&osb->alloc_stats.moves, 0);
59026 - atomic_set(&osb->alloc_stats.local_data, 0);
59027 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59028 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59029 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59030 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59031 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59032 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59033 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59034 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59035
59036 /* Copy the blockcheck stats from the superblock probe */
59037 osb->osb_ecc_stats = *stats;
59038 diff --git a/fs/open.c b/fs/open.c
59039 index d420331..2dbb3fd 100644
59040 --- a/fs/open.c
59041 +++ b/fs/open.c
59042 @@ -32,6 +32,8 @@
59043 #include <linux/dnotify.h>
59044 #include <linux/compat.h>
59045
59046 +#define CREATE_TRACE_POINTS
59047 +#include <trace/events/fs.h>
59048 #include "internal.h"
59049
59050 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59051 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59052 error = locks_verify_truncate(inode, NULL, length);
59053 if (!error)
59054 error = security_path_truncate(path);
59055 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59056 + error = -EACCES;
59057 if (!error)
59058 error = do_truncate(path->dentry, length, 0, NULL);
59059
59060 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59061 error = locks_verify_truncate(inode, f.file, length);
59062 if (!error)
59063 error = security_path_truncate(&f.file->f_path);
59064 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59065 + error = -EACCES;
59066 if (!error)
59067 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59068 sb_end_write(inode->i_sb);
59069 @@ -360,6 +366,9 @@ retry:
59070 if (__mnt_is_readonly(path.mnt))
59071 res = -EROFS;
59072
59073 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59074 + res = -EACCES;
59075 +
59076 out_path_release:
59077 path_put(&path);
59078 if (retry_estale(res, lookup_flags)) {
59079 @@ -391,6 +400,8 @@ retry:
59080 if (error)
59081 goto dput_and_out;
59082
59083 + gr_log_chdir(path.dentry, path.mnt);
59084 +
59085 set_fs_pwd(current->fs, &path);
59086
59087 dput_and_out:
59088 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59089 goto out_putf;
59090
59091 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59092 +
59093 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59094 + error = -EPERM;
59095 +
59096 + if (!error)
59097 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59098 +
59099 if (!error)
59100 set_fs_pwd(current->fs, &f.file->f_path);
59101 out_putf:
59102 @@ -449,7 +467,13 @@ retry:
59103 if (error)
59104 goto dput_and_out;
59105
59106 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59107 + goto dput_and_out;
59108 +
59109 set_fs_root(current->fs, &path);
59110 +
59111 + gr_handle_chroot_chdir(&path);
59112 +
59113 error = 0;
59114 dput_and_out:
59115 path_put(&path);
59116 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59117 if (error)
59118 return error;
59119 mutex_lock(&inode->i_mutex);
59120 +
59121 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59122 + error = -EACCES;
59123 + goto out_unlock;
59124 + }
59125 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59126 + error = -EACCES;
59127 + goto out_unlock;
59128 + }
59129 +
59130 error = security_path_chmod(path, mode);
59131 if (error)
59132 goto out_unlock;
59133 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59134 uid = make_kuid(current_user_ns(), user);
59135 gid = make_kgid(current_user_ns(), group);
59136
59137 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59138 + return -EACCES;
59139 +
59140 newattrs.ia_valid = ATTR_CTIME;
59141 if (user != (uid_t) -1) {
59142 if (!uid_valid(uid))
59143 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59144 } else {
59145 fsnotify_open(f);
59146 fd_install(fd, f);
59147 + trace_do_sys_open(tmp->name, flags, mode);
59148 }
59149 }
59150 putname(tmp);
59151 diff --git a/fs/pipe.c b/fs/pipe.c
59152 index d2c45e1..009fe1c 100644
59153 --- a/fs/pipe.c
59154 +++ b/fs/pipe.c
59155 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59156
59157 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59158 {
59159 - if (pipe->files)
59160 + if (atomic_read(&pipe->files))
59161 mutex_lock_nested(&pipe->mutex, subclass);
59162 }
59163
59164 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59165
59166 void pipe_unlock(struct pipe_inode_info *pipe)
59167 {
59168 - if (pipe->files)
59169 + if (atomic_read(&pipe->files))
59170 mutex_unlock(&pipe->mutex);
59171 }
59172 EXPORT_SYMBOL(pipe_unlock);
59173 @@ -449,9 +449,9 @@ redo:
59174 }
59175 if (bufs) /* More to do? */
59176 continue;
59177 - if (!pipe->writers)
59178 + if (!atomic_read(&pipe->writers))
59179 break;
59180 - if (!pipe->waiting_writers) {
59181 + if (!atomic_read(&pipe->waiting_writers)) {
59182 /* syscall merging: Usually we must not sleep
59183 * if O_NONBLOCK is set, or if we got some data.
59184 * But if a writer sleeps in kernel space, then
59185 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59186 ret = 0;
59187 __pipe_lock(pipe);
59188
59189 - if (!pipe->readers) {
59190 + if (!atomic_read(&pipe->readers)) {
59191 send_sig(SIGPIPE, current, 0);
59192 ret = -EPIPE;
59193 goto out;
59194 @@ -562,7 +562,7 @@ redo1:
59195 for (;;) {
59196 int bufs;
59197
59198 - if (!pipe->readers) {
59199 + if (!atomic_read(&pipe->readers)) {
59200 send_sig(SIGPIPE, current, 0);
59201 if (!ret)
59202 ret = -EPIPE;
59203 @@ -653,9 +653,9 @@ redo2:
59204 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59205 do_wakeup = 0;
59206 }
59207 - pipe->waiting_writers++;
59208 + atomic_inc(&pipe->waiting_writers);
59209 pipe_wait(pipe);
59210 - pipe->waiting_writers--;
59211 + atomic_dec(&pipe->waiting_writers);
59212 }
59213 out:
59214 __pipe_unlock(pipe);
59215 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59216 mask = 0;
59217 if (filp->f_mode & FMODE_READ) {
59218 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
59219 - if (!pipe->writers && filp->f_version != pipe->w_counter)
59220 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
59221 mask |= POLLHUP;
59222 }
59223
59224 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59225 * Most Unices do not set POLLERR for FIFOs but on Linux they
59226 * behave exactly like pipes for poll().
59227 */
59228 - if (!pipe->readers)
59229 + if (!atomic_read(&pipe->readers))
59230 mask |= POLLERR;
59231 }
59232
59233 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
59234
59235 __pipe_lock(pipe);
59236 if (file->f_mode & FMODE_READ)
59237 - pipe->readers--;
59238 + atomic_dec(&pipe->readers);
59239 if (file->f_mode & FMODE_WRITE)
59240 - pipe->writers--;
59241 + atomic_dec(&pipe->writers);
59242
59243 - if (pipe->readers || pipe->writers) {
59244 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
59245 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
59246 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59247 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
59248 }
59249 spin_lock(&inode->i_lock);
59250 - if (!--pipe->files) {
59251 + if (atomic_dec_and_test(&pipe->files)) {
59252 inode->i_pipe = NULL;
59253 kill = 1;
59254 }
59255 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
59256 kfree(pipe);
59257 }
59258
59259 -static struct vfsmount *pipe_mnt __read_mostly;
59260 +struct vfsmount *pipe_mnt __read_mostly;
59261
59262 /*
59263 * pipefs_dname() is called from d_path().
59264 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
59265 goto fail_iput;
59266
59267 inode->i_pipe = pipe;
59268 - pipe->files = 2;
59269 - pipe->readers = pipe->writers = 1;
59270 + atomic_set(&pipe->files, 2);
59271 + atomic_set(&pipe->readers, 1);
59272 + atomic_set(&pipe->writers, 1);
59273 inode->i_fop = &pipefifo_fops;
59274
59275 /*
59276 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
59277 spin_lock(&inode->i_lock);
59278 if (inode->i_pipe) {
59279 pipe = inode->i_pipe;
59280 - pipe->files++;
59281 + atomic_inc(&pipe->files);
59282 spin_unlock(&inode->i_lock);
59283 } else {
59284 spin_unlock(&inode->i_lock);
59285 pipe = alloc_pipe_info();
59286 if (!pipe)
59287 return -ENOMEM;
59288 - pipe->files = 1;
59289 + atomic_set(&pipe->files, 1);
59290 spin_lock(&inode->i_lock);
59291 if (unlikely(inode->i_pipe)) {
59292 - inode->i_pipe->files++;
59293 + atomic_inc(&inode->i_pipe->files);
59294 spin_unlock(&inode->i_lock);
59295 free_pipe_info(pipe);
59296 pipe = inode->i_pipe;
59297 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
59298 * opened, even when there is no process writing the FIFO.
59299 */
59300 pipe->r_counter++;
59301 - if (pipe->readers++ == 0)
59302 + if (atomic_inc_return(&pipe->readers) == 1)
59303 wake_up_partner(pipe);
59304
59305 - if (!is_pipe && !pipe->writers) {
59306 + if (!is_pipe && !atomic_read(&pipe->writers)) {
59307 if ((filp->f_flags & O_NONBLOCK)) {
59308 /* suppress POLLHUP until we have
59309 * seen a writer */
59310 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
59311 * errno=ENXIO when there is no process reading the FIFO.
59312 */
59313 ret = -ENXIO;
59314 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
59315 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
59316 goto err;
59317
59318 pipe->w_counter++;
59319 - if (!pipe->writers++)
59320 + if (atomic_inc_return(&pipe->writers) == 1)
59321 wake_up_partner(pipe);
59322
59323 - if (!is_pipe && !pipe->readers) {
59324 + if (!is_pipe && !atomic_read(&pipe->readers)) {
59325 if (wait_for_partner(pipe, &pipe->r_counter))
59326 goto err_wr;
59327 }
59328 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
59329 * the process can at least talk to itself.
59330 */
59331
59332 - pipe->readers++;
59333 - pipe->writers++;
59334 + atomic_inc(&pipe->readers);
59335 + atomic_inc(&pipe->writers);
59336 pipe->r_counter++;
59337 pipe->w_counter++;
59338 - if (pipe->readers == 1 || pipe->writers == 1)
59339 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
59340 wake_up_partner(pipe);
59341 break;
59342
59343 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
59344 return 0;
59345
59346 err_rd:
59347 - if (!--pipe->readers)
59348 + if (atomic_dec_and_test(&pipe->readers))
59349 wake_up_interruptible(&pipe->wait);
59350 ret = -ERESTARTSYS;
59351 goto err;
59352
59353 err_wr:
59354 - if (!--pipe->writers)
59355 + if (atomic_dec_and_test(&pipe->writers))
59356 wake_up_interruptible(&pipe->wait);
59357 ret = -ERESTARTSYS;
59358 goto err;
59359
59360 err:
59361 spin_lock(&inode->i_lock);
59362 - if (!--pipe->files) {
59363 + if (atomic_dec_and_test(&pipe->files)) {
59364 inode->i_pipe = NULL;
59365 kill = 1;
59366 }
59367 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
59368 index 15af622..0e9f4467 100644
59369 --- a/fs/proc/Kconfig
59370 +++ b/fs/proc/Kconfig
59371 @@ -30,12 +30,12 @@ config PROC_FS
59372
59373 config PROC_KCORE
59374 bool "/proc/kcore support" if !ARM
59375 - depends on PROC_FS && MMU
59376 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
59377
59378 config PROC_VMCORE
59379 bool "/proc/vmcore support"
59380 - depends on PROC_FS && CRASH_DUMP
59381 - default y
59382 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
59383 + default n
59384 help
59385 Exports the dump image of crashed kernel in ELF format.
59386
59387 @@ -59,8 +59,8 @@ config PROC_SYSCTL
59388 limited in memory.
59389
59390 config PROC_PAGE_MONITOR
59391 - default y
59392 - depends on PROC_FS && MMU
59393 + default n
59394 + depends on PROC_FS && MMU && !GRKERNSEC
59395 bool "Enable /proc page monitoring" if EXPERT
59396 help
59397 Various /proc files exist to monitor process memory utilization:
59398 diff --git a/fs/proc/array.c b/fs/proc/array.c
59399 index cbd0f1b..adec3f0 100644
59400 --- a/fs/proc/array.c
59401 +++ b/fs/proc/array.c
59402 @@ -60,6 +60,7 @@
59403 #include <linux/tty.h>
59404 #include <linux/string.h>
59405 #include <linux/mman.h>
59406 +#include <linux/grsecurity.h>
59407 #include <linux/proc_fs.h>
59408 #include <linux/ioport.h>
59409 #include <linux/uaccess.h>
59410 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
59411 seq_putc(m, '\n');
59412 }
59413
59414 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59415 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
59416 +{
59417 + if (p->mm)
59418 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
59419 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
59420 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
59421 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
59422 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
59423 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
59424 + else
59425 + seq_printf(m, "PaX:\t-----\n");
59426 +}
59427 +#endif
59428 +
59429 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59430 struct pid *pid, struct task_struct *task)
59431 {
59432 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59433 task_cpus_allowed(m, task);
59434 cpuset_task_status_allowed(m, task);
59435 task_context_switch_counts(m, task);
59436 +
59437 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59438 + task_pax(m, task);
59439 +#endif
59440 +
59441 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
59442 + task_grsec_rbac(m, task);
59443 +#endif
59444 +
59445 return 0;
59446 }
59447
59448 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59449 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59450 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59451 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59452 +#endif
59453 +
59454 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59455 struct pid *pid, struct task_struct *task, int whole)
59456 {
59457 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59458 char tcomm[sizeof(task->comm)];
59459 unsigned long flags;
59460
59461 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59462 + if (current->exec_id != m->exec_id) {
59463 + gr_log_badprocpid("stat");
59464 + return 0;
59465 + }
59466 +#endif
59467 +
59468 state = *get_task_state(task);
59469 vsize = eip = esp = 0;
59470 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59471 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59472 gtime = task_gtime(task);
59473 }
59474
59475 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59476 + if (PAX_RAND_FLAGS(mm)) {
59477 + eip = 0;
59478 + esp = 0;
59479 + wchan = 0;
59480 + }
59481 +#endif
59482 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59483 + wchan = 0;
59484 + eip =0;
59485 + esp =0;
59486 +#endif
59487 +
59488 /* scale priority and nice values from timeslices to -20..20 */
59489 /* to make it look like a "normal" Unix priority/nice value */
59490 priority = task_prio(task);
59491 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59492 seq_put_decimal_ull(m, ' ', vsize);
59493 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59494 seq_put_decimal_ull(m, ' ', rsslim);
59495 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59496 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59497 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59498 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59499 +#else
59500 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59501 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59502 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59503 +#endif
59504 seq_put_decimal_ull(m, ' ', esp);
59505 seq_put_decimal_ull(m, ' ', eip);
59506 /* The signal information here is obsolete.
59507 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59508 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59509 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59510
59511 - if (mm && permitted) {
59512 + if (mm && permitted
59513 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59514 + && !PAX_RAND_FLAGS(mm)
59515 +#endif
59516 + ) {
59517 seq_put_decimal_ull(m, ' ', mm->start_data);
59518 seq_put_decimal_ull(m, ' ', mm->end_data);
59519 seq_put_decimal_ull(m, ' ', mm->start_brk);
59520 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59521 struct pid *pid, struct task_struct *task)
59522 {
59523 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59524 - struct mm_struct *mm = get_task_mm(task);
59525 + struct mm_struct *mm;
59526
59527 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59528 + if (current->exec_id != m->exec_id) {
59529 + gr_log_badprocpid("statm");
59530 + return 0;
59531 + }
59532 +#endif
59533 + mm = get_task_mm(task);
59534 if (mm) {
59535 size = task_statm(mm, &shared, &text, &data, &resident);
59536 mmput(mm);
59537 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59538 return 0;
59539 }
59540
59541 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59542 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59543 +{
59544 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59545 +}
59546 +#endif
59547 +
59548 #ifdef CONFIG_CHECKPOINT_RESTORE
59549 static struct pid *
59550 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59551 diff --git a/fs/proc/base.c b/fs/proc/base.c
59552 index 1485e38..8ad4236 100644
59553 --- a/fs/proc/base.c
59554 +++ b/fs/proc/base.c
59555 @@ -113,6 +113,14 @@ struct pid_entry {
59556 union proc_op op;
59557 };
59558
59559 +struct getdents_callback {
59560 + struct linux_dirent __user * current_dir;
59561 + struct linux_dirent __user * previous;
59562 + struct file * file;
59563 + int count;
59564 + int error;
59565 +};
59566 +
59567 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59568 .name = (NAME), \
59569 .len = sizeof(NAME) - 1, \
59570 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59571 if (!mm->arg_end)
59572 goto out_mm; /* Shh! No looking before we're done */
59573
59574 + if (gr_acl_handle_procpidmem(task))
59575 + goto out_mm;
59576 +
59577 len = mm->arg_end - mm->arg_start;
59578
59579 if (len > PAGE_SIZE)
59580 @@ -237,12 +248,28 @@ out:
59581 return res;
59582 }
59583
59584 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59585 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59586 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59587 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59588 +#endif
59589 +
59590 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59591 {
59592 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59593 int res = PTR_ERR(mm);
59594 if (mm && !IS_ERR(mm)) {
59595 unsigned int nwords = 0;
59596 +
59597 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59598 + /* allow if we're currently ptracing this task */
59599 + if (PAX_RAND_FLAGS(mm) &&
59600 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59601 + mmput(mm);
59602 + return 0;
59603 + }
59604 +#endif
59605 +
59606 do {
59607 nwords += 2;
59608 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59609 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59610 }
59611
59612
59613 -#ifdef CONFIG_KALLSYMS
59614 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59615 /*
59616 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59617 * Returns the resolved symbol. If that fails, simply return the address.
59618 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59619 mutex_unlock(&task->signal->cred_guard_mutex);
59620 }
59621
59622 -#ifdef CONFIG_STACKTRACE
59623 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59624
59625 #define MAX_STACK_TRACE_DEPTH 64
59626
59627 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59628 return count;
59629 }
59630
59631 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59632 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59633 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59634 {
59635 long nr;
59636 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59637 /************************************************************************/
59638
59639 /* permission checks */
59640 -static int proc_fd_access_allowed(struct inode *inode)
59641 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59642 {
59643 struct task_struct *task;
59644 int allowed = 0;
59645 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59646 */
59647 task = get_proc_task(inode);
59648 if (task) {
59649 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59650 + if (log)
59651 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59652 + else
59653 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59654 put_task_struct(task);
59655 }
59656 return allowed;
59657 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59658 struct task_struct *task,
59659 int hide_pid_min)
59660 {
59661 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59662 + return false;
59663 +
59664 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59665 + rcu_read_lock();
59666 + {
59667 + const struct cred *tmpcred = current_cred();
59668 + const struct cred *cred = __task_cred(task);
59669 +
59670 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59671 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59672 + || in_group_p(grsec_proc_gid)
59673 +#endif
59674 + ) {
59675 + rcu_read_unlock();
59676 + return true;
59677 + }
59678 + }
59679 + rcu_read_unlock();
59680 +
59681 + if (!pid->hide_pid)
59682 + return false;
59683 +#endif
59684 +
59685 if (pid->hide_pid < hide_pid_min)
59686 return true;
59687 if (in_group_p(pid->pid_gid))
59688 return true;
59689 +
59690 return ptrace_may_access(task, PTRACE_MODE_READ);
59691 }
59692
59693 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59694 put_task_struct(task);
59695
59696 if (!has_perms) {
59697 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59698 + {
59699 +#else
59700 if (pid->hide_pid == 2) {
59701 +#endif
59702 /*
59703 * Let's make getdents(), stat(), and open()
59704 * consistent with each other. If a process
59705 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59706 if (!task)
59707 return -ESRCH;
59708
59709 + if (gr_acl_handle_procpidmem(task)) {
59710 + put_task_struct(task);
59711 + return -EPERM;
59712 + }
59713 +
59714 mm = mm_access(task, mode);
59715 put_task_struct(task);
59716
59717 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59718
59719 file->private_data = mm;
59720
59721 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59722 + file->f_version = current->exec_id;
59723 +#endif
59724 +
59725 return 0;
59726 }
59727
59728 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59729 ssize_t copied;
59730 char *page;
59731
59732 +#ifdef CONFIG_GRKERNSEC
59733 + if (write)
59734 + return -EPERM;
59735 +#endif
59736 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59737 + if (file->f_version != current->exec_id) {
59738 + gr_log_badprocpid("mem");
59739 + return 0;
59740 + }
59741 +#endif
59742 +
59743 if (!mm)
59744 return 0;
59745
59746 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59747 goto free;
59748
59749 while (count > 0) {
59750 - int this_len = min_t(int, count, PAGE_SIZE);
59751 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59752
59753 if (write && copy_from_user(page, buf, this_len)) {
59754 copied = -EFAULT;
59755 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59756 if (!mm)
59757 return 0;
59758
59759 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59760 + if (file->f_version != current->exec_id) {
59761 + gr_log_badprocpid("environ");
59762 + return 0;
59763 + }
59764 +#endif
59765 +
59766 page = (char *)__get_free_page(GFP_TEMPORARY);
59767 if (!page)
59768 return -ENOMEM;
59769 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59770 goto free;
59771 while (count > 0) {
59772 size_t this_len, max_len;
59773 - int retval;
59774 + ssize_t retval;
59775
59776 if (src >= (mm->env_end - mm->env_start))
59777 break;
59778 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59779 int error = -EACCES;
59780
59781 /* Are we allowed to snoop on the tasks file descriptors? */
59782 - if (!proc_fd_access_allowed(inode))
59783 + if (!proc_fd_access_allowed(inode, 0))
59784 goto out;
59785
59786 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59787 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59788 struct path path;
59789
59790 /* Are we allowed to snoop on the tasks file descriptors? */
59791 - if (!proc_fd_access_allowed(inode))
59792 - goto out;
59793 + /* logging this is needed for learning on chromium to work properly,
59794 + but we don't want to flood the logs from 'ps' which does a readlink
59795 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59796 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59797 + */
59798 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59799 + if (!proc_fd_access_allowed(inode,0))
59800 + goto out;
59801 + } else {
59802 + if (!proc_fd_access_allowed(inode,1))
59803 + goto out;
59804 + }
59805
59806 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59807 if (error)
59808 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59809 rcu_read_lock();
59810 cred = __task_cred(task);
59811 inode->i_uid = cred->euid;
59812 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59813 + inode->i_gid = grsec_proc_gid;
59814 +#else
59815 inode->i_gid = cred->egid;
59816 +#endif
59817 rcu_read_unlock();
59818 }
59819 security_task_to_inode(task, inode);
59820 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59821 return -ENOENT;
59822 }
59823 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59824 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59825 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59826 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59827 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59828 +#endif
59829 task_dumpable(task)) {
59830 cred = __task_cred(task);
59831 stat->uid = cred->euid;
59832 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59833 + stat->gid = grsec_proc_gid;
59834 +#else
59835 stat->gid = cred->egid;
59836 +#endif
59837 }
59838 }
59839 rcu_read_unlock();
59840 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59841
59842 if (task) {
59843 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59844 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59845 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59846 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59847 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59848 +#endif
59849 task_dumpable(task)) {
59850 rcu_read_lock();
59851 cred = __task_cred(task);
59852 inode->i_uid = cred->euid;
59853 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59854 + inode->i_gid = grsec_proc_gid;
59855 +#else
59856 inode->i_gid = cred->egid;
59857 +#endif
59858 rcu_read_unlock();
59859 } else {
59860 inode->i_uid = GLOBAL_ROOT_UID;
59861 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59862 if (!task)
59863 goto out_no_task;
59864
59865 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59866 + goto out;
59867 +
59868 /*
59869 * Yes, it does not scale. And it should not. Don't add
59870 * new entries into /proc/<tgid>/ without very good reasons.
59871 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59872 if (!task)
59873 return -ENOENT;
59874
59875 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59876 + goto out;
59877 +
59878 if (!dir_emit_dots(file, ctx))
59879 goto out;
59880
59881 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59882 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59883 #endif
59884 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59885 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59886 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59887 INF("syscall", S_IRUGO, proc_pid_syscall),
59888 #endif
59889 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59890 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59891 #ifdef CONFIG_SECURITY
59892 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59893 #endif
59894 -#ifdef CONFIG_KALLSYMS
59895 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59896 INF("wchan", S_IRUGO, proc_pid_wchan),
59897 #endif
59898 -#ifdef CONFIG_STACKTRACE
59899 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59900 ONE("stack", S_IRUGO, proc_pid_stack),
59901 #endif
59902 #ifdef CONFIG_SCHEDSTATS
59903 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59904 #ifdef CONFIG_HARDWALL
59905 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59906 #endif
59907 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59908 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59909 +#endif
59910 #ifdef CONFIG_USER_NS
59911 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59912 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59913 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59914 if (!inode)
59915 goto out;
59916
59917 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59918 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59919 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59920 + inode->i_gid = grsec_proc_gid;
59921 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59922 +#else
59923 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59924 +#endif
59925 inode->i_op = &proc_tgid_base_inode_operations;
59926 inode->i_fop = &proc_tgid_base_operations;
59927 inode->i_flags|=S_IMMUTABLE;
59928 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59929 if (!task)
59930 goto out;
59931
59932 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59933 + goto out_put_task;
59934 +
59935 result = proc_pid_instantiate(dir, dentry, task, NULL);
59936 +out_put_task:
59937 put_task_struct(task);
59938 out:
59939 return ERR_PTR(result);
59940 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59941 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59942 #endif
59943 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59944 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59945 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59946 INF("syscall", S_IRUGO, proc_pid_syscall),
59947 #endif
59948 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59949 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59950 #ifdef CONFIG_SECURITY
59951 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59952 #endif
59953 -#ifdef CONFIG_KALLSYMS
59954 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59955 INF("wchan", S_IRUGO, proc_pid_wchan),
59956 #endif
59957 -#ifdef CONFIG_STACKTRACE
59958 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59959 ONE("stack", S_IRUGO, proc_pid_stack),
59960 #endif
59961 #ifdef CONFIG_SCHEDSTATS
59962 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59963 index 82676e3..5f8518a 100644
59964 --- a/fs/proc/cmdline.c
59965 +++ b/fs/proc/cmdline.c
59966 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59967
59968 static int __init proc_cmdline_init(void)
59969 {
59970 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59971 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59972 +#else
59973 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59974 +#endif
59975 return 0;
59976 }
59977 module_init(proc_cmdline_init);
59978 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59979 index b143471..bb105e5 100644
59980 --- a/fs/proc/devices.c
59981 +++ b/fs/proc/devices.c
59982 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59983
59984 static int __init proc_devices_init(void)
59985 {
59986 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59987 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59988 +#else
59989 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59990 +#endif
59991 return 0;
59992 }
59993 module_init(proc_devices_init);
59994 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59995 index 985ea88..d118a0a 100644
59996 --- a/fs/proc/fd.c
59997 +++ b/fs/proc/fd.c
59998 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59999 if (!task)
60000 return -ENOENT;
60001
60002 - files = get_files_struct(task);
60003 + if (!gr_acl_handle_procpidmem(task))
60004 + files = get_files_struct(task);
60005 put_task_struct(task);
60006
60007 if (files) {
60008 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60009 */
60010 int proc_fd_permission(struct inode *inode, int mask)
60011 {
60012 + struct task_struct *task;
60013 int rv = generic_permission(inode, mask);
60014 - if (rv == 0)
60015 - return 0;
60016 +
60017 if (task_tgid(current) == proc_pid(inode))
60018 rv = 0;
60019 +
60020 + task = get_proc_task(inode);
60021 + if (task == NULL)
60022 + return rv;
60023 +
60024 + if (gr_acl_handle_procpidmem(task))
60025 + rv = -EACCES;
60026 +
60027 + put_task_struct(task);
60028 +
60029 return rv;
60030 }
60031
60032 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60033 index 8eaa1ba..cc6ff42 100644
60034 --- a/fs/proc/inode.c
60035 +++ b/fs/proc/inode.c
60036 @@ -23,11 +23,17 @@
60037 #include <linux/slab.h>
60038 #include <linux/mount.h>
60039 #include <linux/magic.h>
60040 +#include <linux/grsecurity.h>
60041
60042 #include <asm/uaccess.h>
60043
60044 #include "internal.h"
60045
60046 +#ifdef CONFIG_PROC_SYSCTL
60047 +extern const struct inode_operations proc_sys_inode_operations;
60048 +extern const struct inode_operations proc_sys_dir_operations;
60049 +#endif
60050 +
60051 static void proc_evict_inode(struct inode *inode)
60052 {
60053 struct proc_dir_entry *de;
60054 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60055 ns = PROC_I(inode)->ns.ns;
60056 if (ns_ops && ns)
60057 ns_ops->put(ns);
60058 +
60059 +#ifdef CONFIG_PROC_SYSCTL
60060 + if (inode->i_op == &proc_sys_inode_operations ||
60061 + inode->i_op == &proc_sys_dir_operations)
60062 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60063 +#endif
60064 +
60065 }
60066
60067 static struct kmem_cache * proc_inode_cachep;
60068 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60069 if (de->mode) {
60070 inode->i_mode = de->mode;
60071 inode->i_uid = de->uid;
60072 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60073 + inode->i_gid = grsec_proc_gid;
60074 +#else
60075 inode->i_gid = de->gid;
60076 +#endif
60077 }
60078 if (de->size)
60079 inode->i_size = de->size;
60080 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60081 index 651d09a..60c73ae 100644
60082 --- a/fs/proc/internal.h
60083 +++ b/fs/proc/internal.h
60084 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60085 struct pid *, struct task_struct *);
60086 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60087 struct pid *, struct task_struct *);
60088 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60089 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60090 +#endif
60091
60092 /*
60093 * base.c
60094 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60095 index 06ea155..9a798c7 100644
60096 --- a/fs/proc/kcore.c
60097 +++ b/fs/proc/kcore.c
60098 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60099 * the addresses in the elf_phdr on our list.
60100 */
60101 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60102 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60103 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60104 + if (tsz > buflen)
60105 tsz = buflen;
60106 -
60107 +
60108 while (buflen) {
60109 struct kcore_list *m;
60110
60111 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60112 kfree(elf_buf);
60113 } else {
60114 if (kern_addr_valid(start)) {
60115 - unsigned long n;
60116 + char *elf_buf;
60117 + mm_segment_t oldfs;
60118
60119 - n = copy_to_user(buffer, (char *)start, tsz);
60120 - /*
60121 - * We cannot distinguish between fault on source
60122 - * and fault on destination. When this happens
60123 - * we clear too and hope it will trigger the
60124 - * EFAULT again.
60125 - */
60126 - if (n) {
60127 - if (clear_user(buffer + tsz - n,
60128 - n))
60129 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60130 + if (!elf_buf)
60131 + return -ENOMEM;
60132 + oldfs = get_fs();
60133 + set_fs(KERNEL_DS);
60134 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60135 + set_fs(oldfs);
60136 + if (copy_to_user(buffer, elf_buf, tsz)) {
60137 + kfree(elf_buf);
60138 return -EFAULT;
60139 + }
60140 }
60141 + set_fs(oldfs);
60142 + kfree(elf_buf);
60143 } else {
60144 if (clear_user(buffer, tsz))
60145 return -EFAULT;
60146 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60147
60148 static int open_kcore(struct inode *inode, struct file *filp)
60149 {
60150 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60151 + return -EPERM;
60152 +#endif
60153 if (!capable(CAP_SYS_RAWIO))
60154 return -EPERM;
60155 if (kcore_need_update)
60156 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60157 index 59d85d6..ac6fc05 100644
60158 --- a/fs/proc/meminfo.c
60159 +++ b/fs/proc/meminfo.c
60160 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60161 vmi.used >> 10,
60162 vmi.largest_chunk >> 10
60163 #ifdef CONFIG_MEMORY_FAILURE
60164 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60165 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60166 #endif
60167 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60168 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60169 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60170 index ccfd99b..1b7e255 100644
60171 --- a/fs/proc/nommu.c
60172 +++ b/fs/proc/nommu.c
60173 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60174 if (len < 1)
60175 len = 1;
60176 seq_printf(m, "%*c", len, ' ');
60177 - seq_path(m, &file->f_path, "");
60178 + seq_path(m, &file->f_path, "\n\\");
60179 }
60180
60181 seq_putc(m, '\n');
60182 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60183 index 4677bb7..408e936 100644
60184 --- a/fs/proc/proc_net.c
60185 +++ b/fs/proc/proc_net.c
60186 @@ -23,6 +23,7 @@
60187 #include <linux/nsproxy.h>
60188 #include <net/net_namespace.h>
60189 #include <linux/seq_file.h>
60190 +#include <linux/grsecurity.h>
60191
60192 #include "internal.h"
60193
60194 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
60195 struct task_struct *task;
60196 struct nsproxy *ns;
60197 struct net *net = NULL;
60198 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60199 + const struct cred *cred = current_cred();
60200 +#endif
60201 +
60202 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60203 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
60204 + return net;
60205 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60206 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
60207 + return net;
60208 +#endif
60209
60210 rcu_read_lock();
60211 task = pid_task(proc_pid(dir), PIDTYPE_PID);
60212 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
60213 index 7129046..6914844 100644
60214 --- a/fs/proc/proc_sysctl.c
60215 +++ b/fs/proc/proc_sysctl.c
60216 @@ -11,13 +11,21 @@
60217 #include <linux/namei.h>
60218 #include <linux/mm.h>
60219 #include <linux/module.h>
60220 +#include <linux/nsproxy.h>
60221 +#ifdef CONFIG_GRKERNSEC
60222 +#include <net/net_namespace.h>
60223 +#endif
60224 #include "internal.h"
60225
60226 +extern int gr_handle_chroot_sysctl(const int op);
60227 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
60228 + const int op);
60229 +
60230 static const struct dentry_operations proc_sys_dentry_operations;
60231 static const struct file_operations proc_sys_file_operations;
60232 -static const struct inode_operations proc_sys_inode_operations;
60233 +const struct inode_operations proc_sys_inode_operations;
60234 static const struct file_operations proc_sys_dir_file_operations;
60235 -static const struct inode_operations proc_sys_dir_operations;
60236 +const struct inode_operations proc_sys_dir_operations;
60237
60238 void proc_sys_poll_notify(struct ctl_table_poll *poll)
60239 {
60240 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
60241
60242 err = NULL;
60243 d_set_d_op(dentry, &proc_sys_dentry_operations);
60244 +
60245 + gr_handle_proc_create(dentry, inode);
60246 +
60247 d_add(dentry, inode);
60248
60249 out:
60250 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60251 struct inode *inode = file_inode(filp);
60252 struct ctl_table_header *head = grab_header(inode);
60253 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
60254 + int op = write ? MAY_WRITE : MAY_READ;
60255 ssize_t error;
60256 size_t res;
60257
60258 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60259 * and won't be until we finish.
60260 */
60261 error = -EPERM;
60262 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
60263 + if (sysctl_perm(head, table, op))
60264 goto out;
60265
60266 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
60267 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60268 if (!table->proc_handler)
60269 goto out;
60270
60271 +#ifdef CONFIG_GRKERNSEC
60272 + error = -EPERM;
60273 + if (gr_handle_chroot_sysctl(op))
60274 + goto out;
60275 + dget(filp->f_path.dentry);
60276 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
60277 + dput(filp->f_path.dentry);
60278 + goto out;
60279 + }
60280 + dput(filp->f_path.dentry);
60281 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
60282 + goto out;
60283 + if (write) {
60284 + if (current->nsproxy->net_ns != table->extra2) {
60285 + if (!capable(CAP_SYS_ADMIN))
60286 + goto out;
60287 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
60288 + goto out;
60289 + }
60290 +#endif
60291 +
60292 /* careful: calling conventions are nasty here */
60293 res = count;
60294 error = table->proc_handler(table, write, buf, &res, ppos);
60295 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
60296 return false;
60297 } else {
60298 d_set_d_op(child, &proc_sys_dentry_operations);
60299 +
60300 + gr_handle_proc_create(child, inode);
60301 +
60302 d_add(child, inode);
60303 }
60304 } else {
60305 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
60306 if ((*pos)++ < ctx->pos)
60307 return true;
60308
60309 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
60310 + return 0;
60311 +
60312 if (unlikely(S_ISLNK(table->mode)))
60313 res = proc_sys_link_fill_cache(file, ctx, head, table);
60314 else
60315 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
60316 if (IS_ERR(head))
60317 return PTR_ERR(head);
60318
60319 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
60320 + return -ENOENT;
60321 +
60322 generic_fillattr(inode, stat);
60323 if (table)
60324 stat->mode = (stat->mode & S_IFMT) | table->mode;
60325 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
60326 .llseek = generic_file_llseek,
60327 };
60328
60329 -static const struct inode_operations proc_sys_inode_operations = {
60330 +const struct inode_operations proc_sys_inode_operations = {
60331 .permission = proc_sys_permission,
60332 .setattr = proc_sys_setattr,
60333 .getattr = proc_sys_getattr,
60334 };
60335
60336 -static const struct inode_operations proc_sys_dir_operations = {
60337 +const struct inode_operations proc_sys_dir_operations = {
60338 .lookup = proc_sys_lookup,
60339 .permission = proc_sys_permission,
60340 .setattr = proc_sys_setattr,
60341 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
60342 static struct ctl_dir *new_dir(struct ctl_table_set *set,
60343 const char *name, int namelen)
60344 {
60345 - struct ctl_table *table;
60346 + ctl_table_no_const *table;
60347 struct ctl_dir *new;
60348 struct ctl_node *node;
60349 char *new_name;
60350 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
60351 return NULL;
60352
60353 node = (struct ctl_node *)(new + 1);
60354 - table = (struct ctl_table *)(node + 1);
60355 + table = (ctl_table_no_const *)(node + 1);
60356 new_name = (char *)(table + 2);
60357 memcpy(new_name, name, namelen);
60358 new_name[namelen] = '\0';
60359 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
60360 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
60361 struct ctl_table_root *link_root)
60362 {
60363 - struct ctl_table *link_table, *entry, *link;
60364 + ctl_table_no_const *link_table, *link;
60365 + struct ctl_table *entry;
60366 struct ctl_table_header *links;
60367 struct ctl_node *node;
60368 char *link_name;
60369 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
60370 return NULL;
60371
60372 node = (struct ctl_node *)(links + 1);
60373 - link_table = (struct ctl_table *)(node + nr_entries);
60374 + link_table = (ctl_table_no_const *)(node + nr_entries);
60375 link_name = (char *)&link_table[nr_entries + 1];
60376
60377 for (link = link_table, entry = table; entry->procname; link++, entry++) {
60378 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60379 struct ctl_table_header ***subheader, struct ctl_table_set *set,
60380 struct ctl_table *table)
60381 {
60382 - struct ctl_table *ctl_table_arg = NULL;
60383 - struct ctl_table *entry, *files;
60384 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
60385 + struct ctl_table *entry;
60386 int nr_files = 0;
60387 int nr_dirs = 0;
60388 int err = -ENOMEM;
60389 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60390 nr_files++;
60391 }
60392
60393 - files = table;
60394 /* If there are mixed files and directories we need a new table */
60395 if (nr_dirs && nr_files) {
60396 - struct ctl_table *new;
60397 + ctl_table_no_const *new;
60398 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
60399 GFP_KERNEL);
60400 if (!files)
60401 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60402 /* Register everything except a directory full of subdirectories */
60403 if (nr_files || !nr_dirs) {
60404 struct ctl_table_header *header;
60405 - header = __register_sysctl_table(set, path, files);
60406 + header = __register_sysctl_table(set, path, files ? files : table);
60407 if (!header) {
60408 kfree(ctl_table_arg);
60409 goto out;
60410 diff --git a/fs/proc/root.c b/fs/proc/root.c
60411 index 87dbcbe..55e1b4d 100644
60412 --- a/fs/proc/root.c
60413 +++ b/fs/proc/root.c
60414 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
60415 #ifdef CONFIG_PROC_DEVICETREE
60416 proc_device_tree_init();
60417 #endif
60418 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60419 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60420 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
60421 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60422 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
60423 +#endif
60424 +#else
60425 proc_mkdir("bus", NULL);
60426 +#endif
60427 proc_sys_init();
60428 }
60429
60430 diff --git a/fs/proc/self.c b/fs/proc/self.c
60431 index 6b6a993..807cccc 100644
60432 --- a/fs/proc/self.c
60433 +++ b/fs/proc/self.c
60434 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
60435 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
60436 void *cookie)
60437 {
60438 - char *s = nd_get_link(nd);
60439 + const char *s = nd_get_link(nd);
60440 if (!IS_ERR(s))
60441 kfree(s);
60442 }
60443 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
60444 index 390bdab..83c1e8a 100644
60445 --- a/fs/proc/task_mmu.c
60446 +++ b/fs/proc/task_mmu.c
60447 @@ -12,12 +12,19 @@
60448 #include <linux/swap.h>
60449 #include <linux/swapops.h>
60450 #include <linux/mmu_notifier.h>
60451 +#include <linux/grsecurity.h>
60452
60453 #include <asm/elf.h>
60454 #include <asm/uaccess.h>
60455 #include <asm/tlbflush.h>
60456 #include "internal.h"
60457
60458 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60459 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60460 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60461 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60462 +#endif
60463 +
60464 void task_mem(struct seq_file *m, struct mm_struct *mm)
60465 {
60466 unsigned long data, text, lib, swap;
60467 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60468 "VmExe:\t%8lu kB\n"
60469 "VmLib:\t%8lu kB\n"
60470 "VmPTE:\t%8lu kB\n"
60471 - "VmSwap:\t%8lu kB\n",
60472 - hiwater_vm << (PAGE_SHIFT-10),
60473 + "VmSwap:\t%8lu kB\n"
60474 +
60475 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60476 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60477 +#endif
60478 +
60479 + ,hiwater_vm << (PAGE_SHIFT-10),
60480 total_vm << (PAGE_SHIFT-10),
60481 mm->locked_vm << (PAGE_SHIFT-10),
60482 mm->pinned_vm << (PAGE_SHIFT-10),
60483 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60484 data << (PAGE_SHIFT-10),
60485 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60486 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60487 - swap << (PAGE_SHIFT-10));
60488 + swap << (PAGE_SHIFT-10)
60489 +
60490 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60491 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60492 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60493 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60494 +#else
60495 + , mm->context.user_cs_base
60496 + , mm->context.user_cs_limit
60497 +#endif
60498 +#endif
60499 +
60500 + );
60501 }
60502
60503 unsigned long task_vsize(struct mm_struct *mm)
60504 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60505 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60506 }
60507
60508 - /* We don't show the stack guard page in /proc/maps */
60509 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60510 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60511 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60512 +#else
60513 start = vma->vm_start;
60514 - if (stack_guard_page_start(vma, start))
60515 - start += PAGE_SIZE;
60516 end = vma->vm_end;
60517 - if (stack_guard_page_end(vma, end))
60518 - end -= PAGE_SIZE;
60519 +#endif
60520
60521 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60522 start,
60523 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60524 flags & VM_WRITE ? 'w' : '-',
60525 flags & VM_EXEC ? 'x' : '-',
60526 flags & VM_MAYSHARE ? 's' : 'p',
60527 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60528 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60529 +#else
60530 pgoff,
60531 +#endif
60532 MAJOR(dev), MINOR(dev), ino, &len);
60533
60534 /*
60535 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60536 */
60537 if (file) {
60538 pad_len_spaces(m, len);
60539 - seq_path(m, &file->f_path, "\n");
60540 + seq_path(m, &file->f_path, "\n\\");
60541 goto done;
60542 }
60543
60544 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60545 * Thread stack in /proc/PID/task/TID/maps or
60546 * the main process stack.
60547 */
60548 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60549 - vma->vm_end >= mm->start_stack)) {
60550 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60551 + (vma->vm_start <= mm->start_stack &&
60552 + vma->vm_end >= mm->start_stack)) {
60553 name = "[stack]";
60554 } else {
60555 /* Thread stack in /proc/PID/maps */
60556 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60557 struct proc_maps_private *priv = m->private;
60558 struct task_struct *task = priv->task;
60559
60560 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60561 + if (current->exec_id != m->exec_id) {
60562 + gr_log_badprocpid("maps");
60563 + return 0;
60564 + }
60565 +#endif
60566 +
60567 show_map_vma(m, vma, is_pid);
60568
60569 if (m->count < m->size) /* vma is copied successfully */
60570 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60571 .private = &mss,
60572 };
60573
60574 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60575 + if (current->exec_id != m->exec_id) {
60576 + gr_log_badprocpid("smaps");
60577 + return 0;
60578 + }
60579 +#endif
60580 memset(&mss, 0, sizeof mss);
60581 - mss.vma = vma;
60582 - /* mmap_sem is held in m_start */
60583 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60584 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60585 -
60586 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60587 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60588 +#endif
60589 + mss.vma = vma;
60590 + /* mmap_sem is held in m_start */
60591 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60592 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60593 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60594 + }
60595 +#endif
60596 show_map_vma(m, vma, is_pid);
60597
60598 seq_printf(m,
60599 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60600 "KernelPageSize: %8lu kB\n"
60601 "MMUPageSize: %8lu kB\n"
60602 "Locked: %8lu kB\n",
60603 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60604 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60605 +#else
60606 (vma->vm_end - vma->vm_start) >> 10,
60607 +#endif
60608 mss.resident >> 10,
60609 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60610 mss.shared_clean >> 10,
60611 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60612 int n;
60613 char buffer[50];
60614
60615 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60616 + if (current->exec_id != m->exec_id) {
60617 + gr_log_badprocpid("numa_maps");
60618 + return 0;
60619 + }
60620 +#endif
60621 +
60622 if (!mm)
60623 return 0;
60624
60625 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60626 if (n < 0)
60627 return n;
60628
60629 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60630 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60631 +#else
60632 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60633 +#endif
60634
60635 if (file) {
60636 seq_printf(m, " file=");
60637 - seq_path(m, &file->f_path, "\n\t= ");
60638 + seq_path(m, &file->f_path, "\n\t\\= ");
60639 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60640 seq_printf(m, " heap");
60641 } else {
60642 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60643 index 56123a6..5a2f6ec 100644
60644 --- a/fs/proc/task_nommu.c
60645 +++ b/fs/proc/task_nommu.c
60646 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60647 else
60648 bytes += kobjsize(mm);
60649
60650 - if (current->fs && current->fs->users > 1)
60651 + if (current->fs && atomic_read(&current->fs->users) > 1)
60652 sbytes += kobjsize(current->fs);
60653 else
60654 bytes += kobjsize(current->fs);
60655 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60656
60657 if (file) {
60658 pad_len_spaces(m, len);
60659 - seq_path(m, &file->f_path, "");
60660 + seq_path(m, &file->f_path, "\n\\");
60661 } else if (mm) {
60662 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60663
60664 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60665 index 9100d69..f1f9fc9 100644
60666 --- a/fs/proc/vmcore.c
60667 +++ b/fs/proc/vmcore.c
60668 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60669 nr_bytes = count;
60670
60671 /* If pfn is not ram, return zeros for sparse dump files */
60672 - if (pfn_is_ram(pfn) == 0)
60673 - memset(buf, 0, nr_bytes);
60674 - else {
60675 + if (pfn_is_ram(pfn) == 0) {
60676 + if (userbuf) {
60677 + if (clear_user((char __force_user *)buf, nr_bytes))
60678 + return -EFAULT;
60679 + } else
60680 + memset(buf, 0, nr_bytes);
60681 + } else {
60682 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60683 offset, userbuf);
60684 if (tmp < 0)
60685 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
60686 if (*fpos < m->offset + m->size) {
60687 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60688 start = m->paddr + *fpos - m->offset;
60689 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
60690 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
60691 if (tmp < 0)
60692 return tmp;
60693 buflen -= tsz;
60694 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60695 index b00fcc9..e0c6381 100644
60696 --- a/fs/qnx6/qnx6.h
60697 +++ b/fs/qnx6/qnx6.h
60698 @@ -74,7 +74,7 @@ enum {
60699 BYTESEX_BE,
60700 };
60701
60702 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60703 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60704 {
60705 if (sbi->s_bytesex == BYTESEX_LE)
60706 return le64_to_cpu((__force __le64)n);
60707 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60708 return (__force __fs64)cpu_to_be64(n);
60709 }
60710
60711 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60712 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60713 {
60714 if (sbi->s_bytesex == BYTESEX_LE)
60715 return le32_to_cpu((__force __le32)n);
60716 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60717 index 16e8abb..2dcf914 100644
60718 --- a/fs/quota/netlink.c
60719 +++ b/fs/quota/netlink.c
60720 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60721 void quota_send_warning(struct kqid qid, dev_t dev,
60722 const char warntype)
60723 {
60724 - static atomic_t seq;
60725 + static atomic_unchecked_t seq;
60726 struct sk_buff *skb;
60727 void *msg_head;
60728 int ret;
60729 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60730 "VFS: Not enough memory to send quota warning.\n");
60731 return;
60732 }
60733 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60734 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60735 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60736 if (!msg_head) {
60737 printk(KERN_ERR
60738 diff --git a/fs/read_write.c b/fs/read_write.c
60739 index e3cd280..a378473 100644
60740 --- a/fs/read_write.c
60741 +++ b/fs/read_write.c
60742 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60743
60744 old_fs = get_fs();
60745 set_fs(get_ds());
60746 - p = (__force const char __user *)buf;
60747 + p = (const char __force_user *)buf;
60748 if (count > MAX_RW_COUNT)
60749 count = MAX_RW_COUNT;
60750 if (file->f_op->write)
60751 diff --git a/fs/readdir.c b/fs/readdir.c
60752 index 93d71e5..6a14be8 100644
60753 --- a/fs/readdir.c
60754 +++ b/fs/readdir.c
60755 @@ -17,6 +17,7 @@
60756 #include <linux/security.h>
60757 #include <linux/syscalls.h>
60758 #include <linux/unistd.h>
60759 +#include <linux/namei.h>
60760
60761 #include <asm/uaccess.h>
60762
60763 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60764 struct readdir_callback {
60765 struct dir_context ctx;
60766 struct old_linux_dirent __user * dirent;
60767 + struct file * file;
60768 int result;
60769 };
60770
60771 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60772 buf->result = -EOVERFLOW;
60773 return -EOVERFLOW;
60774 }
60775 +
60776 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60777 + return 0;
60778 +
60779 buf->result++;
60780 dirent = buf->dirent;
60781 if (!access_ok(VERIFY_WRITE, dirent,
60782 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60783 if (!f.file)
60784 return -EBADF;
60785
60786 + buf.file = f.file;
60787 error = iterate_dir(f.file, &buf.ctx);
60788 if (buf.result)
60789 error = buf.result;
60790 @@ -142,6 +149,7 @@ struct getdents_callback {
60791 struct dir_context ctx;
60792 struct linux_dirent __user * current_dir;
60793 struct linux_dirent __user * previous;
60794 + struct file * file;
60795 int count;
60796 int error;
60797 };
60798 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60799 buf->error = -EOVERFLOW;
60800 return -EOVERFLOW;
60801 }
60802 +
60803 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60804 + return 0;
60805 +
60806 dirent = buf->previous;
60807 if (dirent) {
60808 if (__put_user(offset, &dirent->d_off))
60809 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60810 if (!f.file)
60811 return -EBADF;
60812
60813 + buf.file = f.file;
60814 error = iterate_dir(f.file, &buf.ctx);
60815 if (error >= 0)
60816 error = buf.error;
60817 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60818 struct dir_context ctx;
60819 struct linux_dirent64 __user * current_dir;
60820 struct linux_dirent64 __user * previous;
60821 + struct file *file;
60822 int count;
60823 int error;
60824 };
60825 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60826 buf->error = -EINVAL; /* only used if we fail.. */
60827 if (reclen > buf->count)
60828 return -EINVAL;
60829 +
60830 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60831 + return 0;
60832 +
60833 dirent = buf->previous;
60834 if (dirent) {
60835 if (__put_user(offset, &dirent->d_off))
60836 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60837 if (!f.file)
60838 return -EBADF;
60839
60840 + buf.file = f.file;
60841 error = iterate_dir(f.file, &buf.ctx);
60842 if (error >= 0)
60843 error = buf.error;
60844 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60845 index 2b7882b..1c5ef48 100644
60846 --- a/fs/reiserfs/do_balan.c
60847 +++ b/fs/reiserfs/do_balan.c
60848 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60849 return;
60850 }
60851
60852 - atomic_inc(&(fs_generation(tb->tb_sb)));
60853 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60854 do_balance_starts(tb);
60855
60856 /* balance leaf returns 0 except if combining L R and S into
60857 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60858 index a958444..42b2323 100644
60859 --- a/fs/reiserfs/procfs.c
60860 +++ b/fs/reiserfs/procfs.c
60861 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60862 "SMALL_TAILS " : "NO_TAILS ",
60863 replay_only(sb) ? "REPLAY_ONLY " : "",
60864 convert_reiserfs(sb) ? "CONV " : "",
60865 - atomic_read(&r->s_generation_counter),
60866 + atomic_read_unchecked(&r->s_generation_counter),
60867 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60868 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60869 SF(s_good_search_by_key_reada), SF(s_bmaps),
60870 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60871 index f8adaee..0eeeeca 100644
60872 --- a/fs/reiserfs/reiserfs.h
60873 +++ b/fs/reiserfs/reiserfs.h
60874 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60875 /* Comment? -Hans */
60876 wait_queue_head_t s_wait;
60877 /* To be obsoleted soon by per buffer seals.. -Hans */
60878 - atomic_t s_generation_counter; // increased by one every time the
60879 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60880 // tree gets re-balanced
60881 unsigned long s_properties; /* File system properties. Currently holds
60882 on-disk FS format */
60883 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60884 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60885
60886 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60887 -#define get_generation(s) atomic_read (&fs_generation(s))
60888 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60889 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60890 #define __fs_changed(gen,s) (gen != get_generation (s))
60891 #define fs_changed(gen,s) \
60892 diff --git a/fs/select.c b/fs/select.c
60893 index dfd5cb1..1754d57 100644
60894 --- a/fs/select.c
60895 +++ b/fs/select.c
60896 @@ -20,6 +20,7 @@
60897 #include <linux/export.h>
60898 #include <linux/slab.h>
60899 #include <linux/poll.h>
60900 +#include <linux/security.h>
60901 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60902 #include <linux/file.h>
60903 #include <linux/fdtable.h>
60904 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60905 struct poll_list *walk = head;
60906 unsigned long todo = nfds;
60907
60908 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60909 if (nfds > rlimit(RLIMIT_NOFILE))
60910 return -EINVAL;
60911
60912 diff --git a/fs/seq_file.c b/fs/seq_file.c
60913 index a290157..ec3211a 100644
60914 --- a/fs/seq_file.c
60915 +++ b/fs/seq_file.c
60916 @@ -10,6 +10,7 @@
60917 #include <linux/seq_file.h>
60918 #include <linux/slab.h>
60919 #include <linux/cred.h>
60920 +#include <linux/sched.h>
60921
60922 #include <asm/uaccess.h>
60923 #include <asm/page.h>
60924 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60925 #ifdef CONFIG_USER_NS
60926 p->user_ns = file->f_cred->user_ns;
60927 #endif
60928 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60929 + p->exec_id = current->exec_id;
60930 +#endif
60931
60932 /*
60933 * Wrappers around seq_open(e.g. swaps_open) need to be
60934 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60935 return 0;
60936 }
60937 if (!m->buf) {
60938 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60939 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60940 if (!m->buf)
60941 return -ENOMEM;
60942 }
60943 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60944 Eoverflow:
60945 m->op->stop(m, p);
60946 kfree(m->buf);
60947 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60948 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60949 return !m->buf ? -ENOMEM : -EAGAIN;
60950 }
60951
60952 @@ -152,7 +156,7 @@ Eoverflow:
60953 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60954 {
60955 struct seq_file *m = file->private_data;
60956 - size_t copied = 0;
60957 + ssize_t copied = 0;
60958 loff_t pos;
60959 size_t n;
60960 void *p;
60961 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60962
60963 /* grab buffer if we didn't have one */
60964 if (!m->buf) {
60965 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60966 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60967 if (!m->buf)
60968 goto Enomem;
60969 }
60970 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60971 goto Fill;
60972 m->op->stop(m, p);
60973 kfree(m->buf);
60974 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60975 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60976 if (!m->buf)
60977 goto Enomem;
60978 m->count = 0;
60979 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
60980 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60981 void *data)
60982 {
60983 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60984 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60985 int res = -ENOMEM;
60986
60987 if (op) {
60988 diff --git a/fs/splice.c b/fs/splice.c
60989 index 3b7ee65..87fc2e4 100644
60990 --- a/fs/splice.c
60991 +++ b/fs/splice.c
60992 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60993 pipe_lock(pipe);
60994
60995 for (;;) {
60996 - if (!pipe->readers) {
60997 + if (!atomic_read(&pipe->readers)) {
60998 send_sig(SIGPIPE, current, 0);
60999 if (!ret)
61000 ret = -EPIPE;
61001 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61002 page_nr++;
61003 ret += buf->len;
61004
61005 - if (pipe->files)
61006 + if (atomic_read(&pipe->files))
61007 do_wakeup = 1;
61008
61009 if (!--spd->nr_pages)
61010 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61011 do_wakeup = 0;
61012 }
61013
61014 - pipe->waiting_writers++;
61015 + atomic_inc(&pipe->waiting_writers);
61016 pipe_wait(pipe);
61017 - pipe->waiting_writers--;
61018 + atomic_dec(&pipe->waiting_writers);
61019 }
61020
61021 pipe_unlock(pipe);
61022 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61023 old_fs = get_fs();
61024 set_fs(get_ds());
61025 /* The cast to a user pointer is valid due to the set_fs() */
61026 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61027 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61028 set_fs(old_fs);
61029
61030 return res;
61031 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61032 old_fs = get_fs();
61033 set_fs(get_ds());
61034 /* The cast to a user pointer is valid due to the set_fs() */
61035 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61036 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61037 set_fs(old_fs);
61038
61039 return res;
61040 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61041 goto err;
61042
61043 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61044 - vec[i].iov_base = (void __user *) page_address(page);
61045 + vec[i].iov_base = (void __force_user *) page_address(page);
61046 vec[i].iov_len = this_len;
61047 spd.pages[i] = page;
61048 spd.nr_pages++;
61049 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61050 ops->release(pipe, buf);
61051 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61052 pipe->nrbufs--;
61053 - if (pipe->files)
61054 + if (atomic_read(&pipe->files))
61055 sd->need_wakeup = true;
61056 }
61057
61058 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61059 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61060 {
61061 while (!pipe->nrbufs) {
61062 - if (!pipe->writers)
61063 + if (!atomic_read(&pipe->writers))
61064 return 0;
61065
61066 - if (!pipe->waiting_writers && sd->num_spliced)
61067 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61068 return 0;
61069
61070 if (sd->flags & SPLICE_F_NONBLOCK)
61071 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61072 * out of the pipe right after the splice_to_pipe(). So set
61073 * PIPE_READERS appropriately.
61074 */
61075 - pipe->readers = 1;
61076 + atomic_set(&pipe->readers, 1);
61077
61078 current->splice_pipe = pipe;
61079 }
61080 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61081
61082 partial[buffers].offset = off;
61083 partial[buffers].len = plen;
61084 + partial[buffers].private = 0;
61085
61086 off = 0;
61087 len -= plen;
61088 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61089 ret = -ERESTARTSYS;
61090 break;
61091 }
61092 - if (!pipe->writers)
61093 + if (!atomic_read(&pipe->writers))
61094 break;
61095 - if (!pipe->waiting_writers) {
61096 + if (!atomic_read(&pipe->waiting_writers)) {
61097 if (flags & SPLICE_F_NONBLOCK) {
61098 ret = -EAGAIN;
61099 break;
61100 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61101 pipe_lock(pipe);
61102
61103 while (pipe->nrbufs >= pipe->buffers) {
61104 - if (!pipe->readers) {
61105 + if (!atomic_read(&pipe->readers)) {
61106 send_sig(SIGPIPE, current, 0);
61107 ret = -EPIPE;
61108 break;
61109 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61110 ret = -ERESTARTSYS;
61111 break;
61112 }
61113 - pipe->waiting_writers++;
61114 + atomic_inc(&pipe->waiting_writers);
61115 pipe_wait(pipe);
61116 - pipe->waiting_writers--;
61117 + atomic_dec(&pipe->waiting_writers);
61118 }
61119
61120 pipe_unlock(pipe);
61121 @@ -1862,14 +1863,14 @@ retry:
61122 pipe_double_lock(ipipe, opipe);
61123
61124 do {
61125 - if (!opipe->readers) {
61126 + if (!atomic_read(&opipe->readers)) {
61127 send_sig(SIGPIPE, current, 0);
61128 if (!ret)
61129 ret = -EPIPE;
61130 break;
61131 }
61132
61133 - if (!ipipe->nrbufs && !ipipe->writers)
61134 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61135 break;
61136
61137 /*
61138 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61139 pipe_double_lock(ipipe, opipe);
61140
61141 do {
61142 - if (!opipe->readers) {
61143 + if (!atomic_read(&opipe->readers)) {
61144 send_sig(SIGPIPE, current, 0);
61145 if (!ret)
61146 ret = -EPIPE;
61147 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61148 * return EAGAIN if we have the potential of some data in the
61149 * future, otherwise just return 0
61150 */
61151 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
61152 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
61153 ret = -EAGAIN;
61154
61155 pipe_unlock(ipipe);
61156 diff --git a/fs/stat.c b/fs/stat.c
61157 index d0ea7ef..f463f9d 100644
61158 --- a/fs/stat.c
61159 +++ b/fs/stat.c
61160 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
61161 stat->gid = inode->i_gid;
61162 stat->rdev = inode->i_rdev;
61163 stat->size = i_size_read(inode);
61164 - stat->atime = inode->i_atime;
61165 - stat->mtime = inode->i_mtime;
61166 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61167 + stat->atime = inode->i_ctime;
61168 + stat->mtime = inode->i_ctime;
61169 + } else {
61170 + stat->atime = inode->i_atime;
61171 + stat->mtime = inode->i_mtime;
61172 + }
61173 stat->ctime = inode->i_ctime;
61174 stat->blksize = (1 << inode->i_blkbits);
61175 stat->blocks = inode->i_blocks;
61176 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
61177 if (retval)
61178 return retval;
61179
61180 - if (inode->i_op->getattr)
61181 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
61182 + if (inode->i_op->getattr) {
61183 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
61184 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61185 + stat->atime = stat->ctime;
61186 + stat->mtime = stat->ctime;
61187 + }
61188 + return retval;
61189 + }
61190
61191 generic_fillattr(inode, stat);
61192 return 0;
61193 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
61194 index c590cab..6dfd6fc 100644
61195 --- a/fs/sysfs/bin.c
61196 +++ b/fs/sysfs/bin.c
61197 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
61198 return ret;
61199 }
61200
61201 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
61202 - void *buf, int len, int write)
61203 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
61204 + void *buf, size_t len, int write)
61205 {
61206 struct file *file = vma->vm_file;
61207 struct bin_buffer *bb = file->private_data;
61208 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
61209 - int ret;
61210 + ssize_t ret;
61211
61212 if (!bb->vm_ops)
61213 return -EINVAL;
61214 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
61215 index 4d83ced..049dc45 100644
61216 --- a/fs/sysfs/dir.c
61217 +++ b/fs/sysfs/dir.c
61218 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
61219 *
61220 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61221 */
61222 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
61223 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
61224 {
61225 unsigned long hash = init_name_hash();
61226 unsigned int len = strlen(name);
61227 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
61228 struct sysfs_dirent *sd;
61229 int rc;
61230
61231 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
61232 + const char *parent_name = parent_sd->s_name;
61233 +
61234 + mode = S_IFDIR | S_IRWXU;
61235 +
61236 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
61237 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
61238 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
61239 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
61240 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
61241 +#endif
61242 +
61243 /* allocate */
61244 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
61245 if (!sd)
61246 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
61247 index 15ef5eb..e474372 100644
61248 --- a/fs/sysfs/file.c
61249 +++ b/fs/sysfs/file.c
61250 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
61251
61252 struct sysfs_open_dirent {
61253 atomic_t refcnt;
61254 - atomic_t event;
61255 + atomic_unchecked_t event;
61256 wait_queue_head_t poll;
61257 struct list_head buffers; /* goes through sysfs_buffer.list */
61258 };
61259 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
61260 if (!sysfs_get_active(attr_sd))
61261 return -ENODEV;
61262
61263 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
61264 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
61265 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
61266
61267 sysfs_put_active(attr_sd);
61268 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
61269 return -ENOMEM;
61270
61271 atomic_set(&new_od->refcnt, 0);
61272 - atomic_set(&new_od->event, 1);
61273 + atomic_set_unchecked(&new_od->event, 1);
61274 init_waitqueue_head(&new_od->poll);
61275 INIT_LIST_HEAD(&new_od->buffers);
61276 goto retry;
61277 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
61278
61279 sysfs_put_active(attr_sd);
61280
61281 - if (buffer->event != atomic_read(&od->event))
61282 + if (buffer->event != atomic_read_unchecked(&od->event))
61283 goto trigger;
61284
61285 return DEFAULT_POLLMASK;
61286 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
61287 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
61288 od = sd->s_attr.open;
61289 if (od) {
61290 - atomic_inc(&od->event);
61291 + atomic_inc_unchecked(&od->event);
61292 wake_up_interruptible(&od->poll);
61293 }
61294 }
61295 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
61296 index 2dd4507..62a215a 100644
61297 --- a/fs/sysfs/symlink.c
61298 +++ b/fs/sysfs/symlink.c
61299 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
61300 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
61301 void *cookie)
61302 {
61303 - char *page = nd_get_link(nd);
61304 + const char *page = nd_get_link(nd);
61305 if (!IS_ERR(page))
61306 free_page((unsigned long)page);
61307 }
61308 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
61309 index 69d4889..a810bd4 100644
61310 --- a/fs/sysv/sysv.h
61311 +++ b/fs/sysv/sysv.h
61312 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
61313 #endif
61314 }
61315
61316 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61317 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61318 {
61319 if (sbi->s_bytesex == BYTESEX_PDP)
61320 return PDP_swab((__force __u32)n);
61321 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
61322 index e18b988..f1d4ad0f 100644
61323 --- a/fs/ubifs/io.c
61324 +++ b/fs/ubifs/io.c
61325 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
61326 return err;
61327 }
61328
61329 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61330 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61331 {
61332 int err;
61333
61334 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
61335 index c175b4d..8f36a16 100644
61336 --- a/fs/udf/misc.c
61337 +++ b/fs/udf/misc.c
61338 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
61339
61340 u8 udf_tag_checksum(const struct tag *t)
61341 {
61342 - u8 *data = (u8 *)t;
61343 + const u8 *data = (const u8 *)t;
61344 u8 checksum = 0;
61345 int i;
61346 for (i = 0; i < sizeof(struct tag); ++i)
61347 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
61348 index 8d974c4..b82f6ec 100644
61349 --- a/fs/ufs/swab.h
61350 +++ b/fs/ufs/swab.h
61351 @@ -22,7 +22,7 @@ enum {
61352 BYTESEX_BE
61353 };
61354
61355 -static inline u64
61356 +static inline u64 __intentional_overflow(-1)
61357 fs64_to_cpu(struct super_block *sbp, __fs64 n)
61358 {
61359 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61360 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
61361 return (__force __fs64)cpu_to_be64(n);
61362 }
61363
61364 -static inline u32
61365 +static inline u32 __intentional_overflow(-1)
61366 fs32_to_cpu(struct super_block *sbp, __fs32 n)
61367 {
61368 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61369 diff --git a/fs/utimes.c b/fs/utimes.c
61370 index f4fb7ec..3fe03c0 100644
61371 --- a/fs/utimes.c
61372 +++ b/fs/utimes.c
61373 @@ -1,6 +1,7 @@
61374 #include <linux/compiler.h>
61375 #include <linux/file.h>
61376 #include <linux/fs.h>
61377 +#include <linux/security.h>
61378 #include <linux/linkage.h>
61379 #include <linux/mount.h>
61380 #include <linux/namei.h>
61381 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
61382 goto mnt_drop_write_and_out;
61383 }
61384 }
61385 +
61386 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
61387 + error = -EACCES;
61388 + goto mnt_drop_write_and_out;
61389 + }
61390 +
61391 mutex_lock(&inode->i_mutex);
61392 error = notify_change(path->dentry, &newattrs);
61393 mutex_unlock(&inode->i_mutex);
61394 diff --git a/fs/xattr.c b/fs/xattr.c
61395 index 3377dff..4d074d9 100644
61396 --- a/fs/xattr.c
61397 +++ b/fs/xattr.c
61398 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
61399 return rc;
61400 }
61401
61402 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
61403 +ssize_t
61404 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
61405 +{
61406 + struct inode *inode = dentry->d_inode;
61407 + ssize_t error;
61408 +
61409 + error = inode_permission(inode, MAY_EXEC);
61410 + if (error)
61411 + return error;
61412 +
61413 + if (inode->i_op->getxattr)
61414 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
61415 + else
61416 + error = -EOPNOTSUPP;
61417 +
61418 + return error;
61419 +}
61420 +EXPORT_SYMBOL(pax_getxattr);
61421 +#endif
61422 +
61423 ssize_t
61424 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
61425 {
61426 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
61427 * Extended attribute SET operations
61428 */
61429 static long
61430 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
61431 +setxattr(struct path *path, const char __user *name, const void __user *value,
61432 size_t size, int flags)
61433 {
61434 int error;
61435 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
61436 posix_acl_fix_xattr_from_user(kvalue, size);
61437 }
61438
61439 - error = vfs_setxattr(d, kname, kvalue, size, flags);
61440 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
61441 + error = -EACCES;
61442 + goto out;
61443 + }
61444 +
61445 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
61446 out:
61447 if (vvalue)
61448 vfree(vvalue);
61449 @@ -377,7 +403,7 @@ retry:
61450 return error;
61451 error = mnt_want_write(path.mnt);
61452 if (!error) {
61453 - error = setxattr(path.dentry, name, value, size, flags);
61454 + error = setxattr(&path, name, value, size, flags);
61455 mnt_drop_write(path.mnt);
61456 }
61457 path_put(&path);
61458 @@ -401,7 +427,7 @@ retry:
61459 return error;
61460 error = mnt_want_write(path.mnt);
61461 if (!error) {
61462 - error = setxattr(path.dentry, name, value, size, flags);
61463 + error = setxattr(&path, name, value, size, flags);
61464 mnt_drop_write(path.mnt);
61465 }
61466 path_put(&path);
61467 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
61468 const void __user *,value, size_t, size, int, flags)
61469 {
61470 struct fd f = fdget(fd);
61471 - struct dentry *dentry;
61472 int error = -EBADF;
61473
61474 if (!f.file)
61475 return error;
61476 - dentry = f.file->f_path.dentry;
61477 - audit_inode(NULL, dentry, 0);
61478 + audit_inode(NULL, f.file->f_path.dentry, 0);
61479 error = mnt_want_write_file(f.file);
61480 if (!error) {
61481 - error = setxattr(dentry, name, value, size, flags);
61482 + error = setxattr(&f.file->f_path, name, value, size, flags);
61483 mnt_drop_write_file(f.file);
61484 }
61485 fdput(f);
61486 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61487 index 9fbea87..6b19972 100644
61488 --- a/fs/xattr_acl.c
61489 +++ b/fs/xattr_acl.c
61490 @@ -76,8 +76,8 @@ struct posix_acl *
61491 posix_acl_from_xattr(struct user_namespace *user_ns,
61492 const void *value, size_t size)
61493 {
61494 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61495 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61496 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61497 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61498 int count;
61499 struct posix_acl *acl;
61500 struct posix_acl_entry *acl_e;
61501 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61502 index f47e65c..e7125d9 100644
61503 --- a/fs/xfs/xfs_bmap.c
61504 +++ b/fs/xfs/xfs_bmap.c
61505 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
61506
61507 #else
61508 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61509 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61510 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61511 #endif /* DEBUG */
61512
61513 /*
61514 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
61515 index 8f84153..7ce60d0 100644
61516 --- a/fs/xfs/xfs_dir2_readdir.c
61517 +++ b/fs/xfs/xfs_dir2_readdir.c
61518 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
61519 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
61520 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
61521 ctx->pos = off & 0x7fffffff;
61522 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61523 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61524 + char name[sfep->namelen];
61525 + memcpy(name, sfep->name, sfep->namelen);
61526 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
61527 + return 0;
61528 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61529 xfs_dir3_get_dtype(mp, filetype)))
61530 return 0;
61531 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
61532 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61533 index 668e8f4..9d38104 100644
61534 --- a/fs/xfs/xfs_ioctl.c
61535 +++ b/fs/xfs/xfs_ioctl.c
61536 @@ -127,7 +127,7 @@ xfs_find_handle(
61537 }
61538
61539 error = -EFAULT;
61540 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61541 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61542 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61543 goto out_put;
61544
61545 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61546 index 2b8952d..a60c6be 100644
61547 --- a/fs/xfs/xfs_iops.c
61548 +++ b/fs/xfs/xfs_iops.c
61549 @@ -401,7 +401,7 @@ xfs_vn_put_link(
61550 struct nameidata *nd,
61551 void *p)
61552 {
61553 - char *s = nd_get_link(nd);
61554 + const char *s = nd_get_link(nd);
61555
61556 if (!IS_ERR(s))
61557 kfree(s);
61558 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61559 new file mode 100644
61560 index 0000000..6d22fbe
61561 --- /dev/null
61562 +++ b/grsecurity/Kconfig
61563 @@ -0,0 +1,1112 @@
61564 +#
61565 +# grecurity configuration
61566 +#
61567 +menu "Memory Protections"
61568 +depends on GRKERNSEC
61569 +
61570 +config GRKERNSEC_KMEM
61571 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61572 + default y if GRKERNSEC_CONFIG_AUTO
61573 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61574 + help
61575 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61576 + be written to or read from to modify or leak the contents of the running
61577 + kernel. /dev/port will also not be allowed to be opened and support
61578 + for /dev/cpu/*/msr will be removed. If you have module
61579 + support disabled, enabling this will close up five ways that are
61580 + currently used to insert malicious code into the running kernel.
61581 +
61582 + Even with all these features enabled, we still highly recommend that
61583 + you use the RBAC system, as it is still possible for an attacker to
61584 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61585 +
61586 + If you are not using XFree86, you may be able to stop this additional
61587 + case by enabling the 'Disable privileged I/O' option. Though nothing
61588 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61589 + but only to video memory, which is the only writing we allow in this
61590 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61591 + not be allowed to mprotect it with PROT_WRITE later.
61592 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61593 + from working.
61594 +
61595 + It is highly recommended that you say Y here if you meet all the
61596 + conditions above.
61597 +
61598 +config GRKERNSEC_VM86
61599 + bool "Restrict VM86 mode"
61600 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61601 + depends on X86_32
61602 +
61603 + help
61604 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61605 + make use of a special execution mode on 32bit x86 processors called
61606 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61607 + video cards and will still work with this option enabled. The purpose
61608 + of the option is to prevent exploitation of emulation errors in
61609 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61610 + Nearly all users should be able to enable this option.
61611 +
61612 +config GRKERNSEC_IO
61613 + bool "Disable privileged I/O"
61614 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61615 + depends on X86
61616 + select RTC_CLASS
61617 + select RTC_INTF_DEV
61618 + select RTC_DRV_CMOS
61619 +
61620 + help
61621 + If you say Y here, all ioperm and iopl calls will return an error.
61622 + Ioperm and iopl can be used to modify the running kernel.
61623 + Unfortunately, some programs need this access to operate properly,
61624 + the most notable of which are XFree86 and hwclock. hwclock can be
61625 + remedied by having RTC support in the kernel, so real-time
61626 + clock support is enabled if this option is enabled, to ensure
61627 + that hwclock operates correctly. XFree86 still will not
61628 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61629 + IF YOU USE XFree86. If you use XFree86 and you still want to
61630 + protect your kernel against modification, use the RBAC system.
61631 +
61632 +config GRKERNSEC_JIT_HARDEN
61633 + bool "Harden BPF JIT against spray attacks"
61634 + default y if GRKERNSEC_CONFIG_AUTO
61635 + depends on BPF_JIT
61636 + help
61637 + If you say Y here, the native code generated by the kernel's Berkeley
61638 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61639 + attacks that attempt to fit attacker-beneficial instructions in
61640 + 32bit immediate fields of JIT-generated native instructions. The
61641 + attacker will generally aim to cause an unintended instruction sequence
61642 + of JIT-generated native code to execute by jumping into the middle of
61643 + a generated instruction. This feature effectively randomizes the 32bit
61644 + immediate constants present in the generated code to thwart such attacks.
61645 +
61646 + If you're using KERNEXEC, it's recommended that you enable this option
61647 + to supplement the hardening of the kernel.
61648 +
61649 +config GRKERNSEC_PERF_HARDEN
61650 + bool "Disable unprivileged PERF_EVENTS usage by default"
61651 + default y if GRKERNSEC_CONFIG_AUTO
61652 + depends on PERF_EVENTS
61653 + help
61654 + If you say Y here, the range of acceptable values for the
61655 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61656 + default to a new value: 3. When the sysctl is set to this value, no
61657 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61658 +
61659 + Though PERF_EVENTS can be used legitimately for performance monitoring
61660 + and low-level application profiling, it is forced on regardless of
61661 + configuration, has been at fault for several vulnerabilities, and
61662 + creates new opportunities for side channels and other information leaks.
61663 +
61664 + This feature puts PERF_EVENTS into a secure default state and permits
61665 + the administrator to change out of it temporarily if unprivileged
61666 + application profiling is needed.
61667 +
61668 +config GRKERNSEC_RAND_THREADSTACK
61669 + bool "Insert random gaps between thread stacks"
61670 + default y if GRKERNSEC_CONFIG_AUTO
61671 + depends on PAX_RANDMMAP && !PPC
61672 + help
61673 + If you say Y here, a random-sized gap will be enforced between allocated
61674 + thread stacks. Glibc's NPTL and other threading libraries that
61675 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61676 + The implementation currently provides 8 bits of entropy for the gap.
61677 +
61678 + Many distributions do not compile threaded remote services with the
61679 + -fstack-check argument to GCC, causing the variable-sized stack-based
61680 + allocator, alloca(), to not probe the stack on allocation. This
61681 + permits an unbounded alloca() to skip over any guard page and potentially
61682 + modify another thread's stack reliably. An enforced random gap
61683 + reduces the reliability of such an attack and increases the chance
61684 + that such a read/write to another thread's stack instead lands in
61685 + an unmapped area, causing a crash and triggering grsecurity's
61686 + anti-bruteforcing logic.
61687 +
61688 +config GRKERNSEC_PROC_MEMMAP
61689 + bool "Harden ASLR against information leaks and entropy reduction"
61690 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61691 + depends on PAX_NOEXEC || PAX_ASLR
61692 + help
61693 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61694 + give no information about the addresses of its mappings if
61695 + PaX features that rely on random addresses are enabled on the task.
61696 + In addition to sanitizing this information and disabling other
61697 + dangerous sources of information, this option causes reads of sensitive
61698 + /proc/<pid> entries where the file descriptor was opened in a different
61699 + task than the one performing the read. Such attempts are logged.
61700 + This option also limits argv/env strings for suid/sgid binaries
61701 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61702 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61703 + binaries to prevent alternative mmap layouts from being abused.
61704 +
61705 + If you use PaX it is essential that you say Y here as it closes up
61706 + several holes that make full ASLR useless locally.
61707 +
61708 +config GRKERNSEC_BRUTE
61709 + bool "Deter exploit bruteforcing"
61710 + default y if GRKERNSEC_CONFIG_AUTO
61711 + help
61712 + If you say Y here, attempts to bruteforce exploits against forking
61713 + daemons such as apache or sshd, as well as against suid/sgid binaries
61714 + will be deterred. When a child of a forking daemon is killed by PaX
61715 + or crashes due to an illegal instruction or other suspicious signal,
61716 + the parent process will be delayed 30 seconds upon every subsequent
61717 + fork until the administrator is able to assess the situation and
61718 + restart the daemon.
61719 + In the suid/sgid case, the attempt is logged, the user has all their
61720 + existing instances of the suid/sgid binary terminated and will
61721 + be unable to execute any suid/sgid binaries for 15 minutes.
61722 +
61723 + It is recommended that you also enable signal logging in the auditing
61724 + section so that logs are generated when a process triggers a suspicious
61725 + signal.
61726 + If the sysctl option is enabled, a sysctl option with name
61727 + "deter_bruteforce" is created.
61728 +
61729 +
61730 +config GRKERNSEC_MODHARDEN
61731 + bool "Harden module auto-loading"
61732 + default y if GRKERNSEC_CONFIG_AUTO
61733 + depends on MODULES
61734 + help
61735 + If you say Y here, module auto-loading in response to use of some
61736 + feature implemented by an unloaded module will be restricted to
61737 + root users. Enabling this option helps defend against attacks
61738 + by unprivileged users who abuse the auto-loading behavior to
61739 + cause a vulnerable module to load that is then exploited.
61740 +
61741 + If this option prevents a legitimate use of auto-loading for a
61742 + non-root user, the administrator can execute modprobe manually
61743 + with the exact name of the module mentioned in the alert log.
61744 + Alternatively, the administrator can add the module to the list
61745 + of modules loaded at boot by modifying init scripts.
61746 +
61747 + Modification of init scripts will most likely be needed on
61748 + Ubuntu servers with encrypted home directory support enabled,
61749 + as the first non-root user logging in will cause the ecb(aes),
61750 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61751 +
61752 +config GRKERNSEC_HIDESYM
61753 + bool "Hide kernel symbols"
61754 + default y if GRKERNSEC_CONFIG_AUTO
61755 + select PAX_USERCOPY_SLABS
61756 + help
61757 + If you say Y here, getting information on loaded modules, and
61758 + displaying all kernel symbols through a syscall will be restricted
61759 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61760 + /proc/kallsyms will be restricted to the root user. The RBAC
61761 + system can hide that entry even from root.
61762 +
61763 + This option also prevents leaking of kernel addresses through
61764 + several /proc entries.
61765 +
61766 + Note that this option is only effective provided the following
61767 + conditions are met:
61768 + 1) The kernel using grsecurity is not precompiled by some distribution
61769 + 2) You have also enabled GRKERNSEC_DMESG
61770 + 3) You are using the RBAC system and hiding other files such as your
61771 + kernel image and System.map. Alternatively, enabling this option
61772 + causes the permissions on /boot, /lib/modules, and the kernel
61773 + source directory to change at compile time to prevent
61774 + reading by non-root users.
61775 + If the above conditions are met, this option will aid in providing a
61776 + useful protection against local kernel exploitation of overflows
61777 + and arbitrary read/write vulnerabilities.
61778 +
61779 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61780 + in addition to this feature.
61781 +
61782 +config GRKERNSEC_KERN_LOCKOUT
61783 + bool "Active kernel exploit response"
61784 + default y if GRKERNSEC_CONFIG_AUTO
61785 + depends on X86 || ARM || PPC || SPARC
61786 + help
61787 + If you say Y here, when a PaX alert is triggered due to suspicious
61788 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61789 + or an OOPS occurs due to bad memory accesses, instead of just
61790 + terminating the offending process (and potentially allowing
61791 + a subsequent exploit from the same user), we will take one of two
61792 + actions:
61793 + If the user was root, we will panic the system
61794 + If the user was non-root, we will log the attempt, terminate
61795 + all processes owned by the user, then prevent them from creating
61796 + any new processes until the system is restarted
61797 + This deters repeated kernel exploitation/bruteforcing attempts
61798 + and is useful for later forensics.
61799 +
61800 +config GRKERNSEC_OLD_ARM_USERLAND
61801 + bool "Old ARM userland compatibility"
61802 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61803 + help
61804 + If you say Y here, stubs of executable code to perform such operations
61805 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61806 + table. This is unfortunately needed for old ARM userland meant to run
61807 + across a wide range of processors. Without this option enabled,
61808 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61809 + which is enough for Linaro userlands or other userlands designed for v6
61810 + and newer ARM CPUs. It's recommended that you try without this option enabled
61811 + first, and only enable it if your userland does not boot (it will likely fail
61812 + at init time).
61813 +
61814 +endmenu
61815 +menu "Role Based Access Control Options"
61816 +depends on GRKERNSEC
61817 +
61818 +config GRKERNSEC_RBAC_DEBUG
61819 + bool
61820 +
61821 +config GRKERNSEC_NO_RBAC
61822 + bool "Disable RBAC system"
61823 + help
61824 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61825 + preventing the RBAC system from being enabled. You should only say Y
61826 + here if you have no intention of using the RBAC system, so as to prevent
61827 + an attacker with root access from misusing the RBAC system to hide files
61828 + and processes when loadable module support and /dev/[k]mem have been
61829 + locked down.
61830 +
61831 +config GRKERNSEC_ACL_HIDEKERN
61832 + bool "Hide kernel processes"
61833 + help
61834 + If you say Y here, all kernel threads will be hidden to all
61835 + processes but those whose subject has the "view hidden processes"
61836 + flag.
61837 +
61838 +config GRKERNSEC_ACL_MAXTRIES
61839 + int "Maximum tries before password lockout"
61840 + default 3
61841 + help
61842 + This option enforces the maximum number of times a user can attempt
61843 + to authorize themselves with the grsecurity RBAC system before being
61844 + denied the ability to attempt authorization again for a specified time.
61845 + The lower the number, the harder it will be to brute-force a password.
61846 +
61847 +config GRKERNSEC_ACL_TIMEOUT
61848 + int "Time to wait after max password tries, in seconds"
61849 + default 30
61850 + help
61851 + This option specifies the time the user must wait after attempting to
61852 + authorize to the RBAC system with the maximum number of invalid
61853 + passwords. The higher the number, the harder it will be to brute-force
61854 + a password.
61855 +
61856 +endmenu
61857 +menu "Filesystem Protections"
61858 +depends on GRKERNSEC
61859 +
61860 +config GRKERNSEC_PROC
61861 + bool "Proc restrictions"
61862 + default y if GRKERNSEC_CONFIG_AUTO
61863 + help
61864 + If you say Y here, the permissions of the /proc filesystem
61865 + will be altered to enhance system security and privacy. You MUST
61866 + choose either a user only restriction or a user and group restriction.
61867 + Depending upon the option you choose, you can either restrict users to
61868 + see only the processes they themselves run, or choose a group that can
61869 + view all processes and files normally restricted to root if you choose
61870 + the "restrict to user only" option. NOTE: If you're running identd or
61871 + ntpd as a non-root user, you will have to run it as the group you
61872 + specify here.
61873 +
61874 +config GRKERNSEC_PROC_USER
61875 + bool "Restrict /proc to user only"
61876 + depends on GRKERNSEC_PROC
61877 + help
61878 + If you say Y here, non-root users will only be able to view their own
61879 + processes, and restricts them from viewing network-related information,
61880 + and viewing kernel symbol and module information.
61881 +
61882 +config GRKERNSEC_PROC_USERGROUP
61883 + bool "Allow special group"
61884 + default y if GRKERNSEC_CONFIG_AUTO
61885 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61886 + help
61887 + If you say Y here, you will be able to select a group that will be
61888 + able to view all processes and network-related information. If you've
61889 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61890 + remain hidden. This option is useful if you want to run identd as
61891 + a non-root user. The group you select may also be chosen at boot time
61892 + via "grsec_proc_gid=" on the kernel commandline.
61893 +
61894 +config GRKERNSEC_PROC_GID
61895 + int "GID for special group"
61896 + depends on GRKERNSEC_PROC_USERGROUP
61897 + default 1001
61898 +
61899 +config GRKERNSEC_PROC_ADD
61900 + bool "Additional restrictions"
61901 + default y if GRKERNSEC_CONFIG_AUTO
61902 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61903 + help
61904 + If you say Y here, additional restrictions will be placed on
61905 + /proc that keep normal users from viewing device information and
61906 + slabinfo information that could be useful for exploits.
61907 +
61908 +config GRKERNSEC_LINK
61909 + bool "Linking restrictions"
61910 + default y if GRKERNSEC_CONFIG_AUTO
61911 + help
61912 + If you say Y here, /tmp race exploits will be prevented, since users
61913 + will no longer be able to follow symlinks owned by other users in
61914 + world-writable +t directories (e.g. /tmp), unless the owner of the
61915 + symlink is the owner of the directory. users will also not be
61916 + able to hardlink to files they do not own. If the sysctl option is
61917 + enabled, a sysctl option with name "linking_restrictions" is created.
61918 +
61919 +config GRKERNSEC_SYMLINKOWN
61920 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61921 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61922 + help
61923 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61924 + that prevents it from being used as a security feature. As Apache
61925 + verifies the symlink by performing a stat() against the target of
61926 + the symlink before it is followed, an attacker can setup a symlink
61927 + to point to a same-owned file, then replace the symlink with one
61928 + that targets another user's file just after Apache "validates" the
61929 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61930 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61931 + will be in place for the group you specify. If the sysctl option
61932 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61933 + created.
61934 +
61935 +config GRKERNSEC_SYMLINKOWN_GID
61936 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61937 + depends on GRKERNSEC_SYMLINKOWN
61938 + default 1006
61939 + help
61940 + Setting this GID determines what group kernel-enforced
61941 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61942 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61943 +
61944 +config GRKERNSEC_FIFO
61945 + bool "FIFO restrictions"
61946 + default y if GRKERNSEC_CONFIG_AUTO
61947 + help
61948 + If you say Y here, users will not be able to write to FIFOs they don't
61949 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61950 + the FIFO is the same owner of the directory it's held in. If the sysctl
61951 + option is enabled, a sysctl option with name "fifo_restrictions" is
61952 + created.
61953 +
61954 +config GRKERNSEC_SYSFS_RESTRICT
61955 + bool "Sysfs/debugfs restriction"
61956 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61957 + depends on SYSFS
61958 + help
61959 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61960 + any filesystem normally mounted under it (e.g. debugfs) will be
61961 + mostly accessible only by root. These filesystems generally provide access
61962 + to hardware and debug information that isn't appropriate for unprivileged
61963 + users of the system. Sysfs and debugfs have also become a large source
61964 + of new vulnerabilities, ranging from infoleaks to local compromise.
61965 + There has been very little oversight with an eye toward security involved
61966 + in adding new exporters of information to these filesystems, so their
61967 + use is discouraged.
61968 + For reasons of compatibility, a few directories have been whitelisted
61969 + for access by non-root users:
61970 + /sys/fs/selinux
61971 + /sys/fs/fuse
61972 + /sys/devices/system/cpu
61973 +
61974 +config GRKERNSEC_ROFS
61975 + bool "Runtime read-only mount protection"
61976 + depends on SYSCTL
61977 + help
61978 + If you say Y here, a sysctl option with name "romount_protect" will
61979 + be created. By setting this option to 1 at runtime, filesystems
61980 + will be protected in the following ways:
61981 + * No new writable mounts will be allowed
61982 + * Existing read-only mounts won't be able to be remounted read/write
61983 + * Write operations will be denied on all block devices
61984 + This option acts independently of grsec_lock: once it is set to 1,
61985 + it cannot be turned off. Therefore, please be mindful of the resulting
61986 + behavior if this option is enabled in an init script on a read-only
61987 + filesystem. This feature is mainly intended for secure embedded systems.
61988 +
61989 +config GRKERNSEC_DEVICE_SIDECHANNEL
61990 + bool "Eliminate stat/notify-based device sidechannels"
61991 + default y if GRKERNSEC_CONFIG_AUTO
61992 + help
61993 + If you say Y here, timing analyses on block or character
61994 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61995 + will be thwarted for unprivileged users. If a process without
61996 + CAP_MKNOD stats such a device, the last access and last modify times
61997 + will match the device's create time. No access or modify events
61998 + will be triggered through inotify/dnotify/fanotify for such devices.
61999 + This feature will prevent attacks that may at a minimum
62000 + allow an attacker to determine the administrator's password length.
62001 +
62002 +config GRKERNSEC_CHROOT
62003 + bool "Chroot jail restrictions"
62004 + default y if GRKERNSEC_CONFIG_AUTO
62005 + help
62006 + If you say Y here, you will be able to choose several options that will
62007 + make breaking out of a chrooted jail much more difficult. If you
62008 + encounter no software incompatibilities with the following options, it
62009 + is recommended that you enable each one.
62010 +
62011 +config GRKERNSEC_CHROOT_MOUNT
62012 + bool "Deny mounts"
62013 + default y if GRKERNSEC_CONFIG_AUTO
62014 + depends on GRKERNSEC_CHROOT
62015 + help
62016 + If you say Y here, processes inside a chroot will not be able to
62017 + mount or remount filesystems. If the sysctl option is enabled, a
62018 + sysctl option with name "chroot_deny_mount" is created.
62019 +
62020 +config GRKERNSEC_CHROOT_DOUBLE
62021 + bool "Deny double-chroots"
62022 + default y if GRKERNSEC_CONFIG_AUTO
62023 + depends on GRKERNSEC_CHROOT
62024 + help
62025 + If you say Y here, processes inside a chroot will not be able to chroot
62026 + again outside the chroot. This is a widely used method of breaking
62027 + out of a chroot jail and should not be allowed. If the sysctl
62028 + option is enabled, a sysctl option with name
62029 + "chroot_deny_chroot" is created.
62030 +
62031 +config GRKERNSEC_CHROOT_PIVOT
62032 + bool "Deny pivot_root in chroot"
62033 + default y if GRKERNSEC_CONFIG_AUTO
62034 + depends on GRKERNSEC_CHROOT
62035 + help
62036 + If you say Y here, processes inside a chroot will not be able to use
62037 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62038 + works similar to chroot in that it changes the root filesystem. This
62039 + function could be misused in a chrooted process to attempt to break out
62040 + of the chroot, and therefore should not be allowed. If the sysctl
62041 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62042 + created.
62043 +
62044 +config GRKERNSEC_CHROOT_CHDIR
62045 + bool "Enforce chdir(\"/\") on all chroots"
62046 + default y if GRKERNSEC_CONFIG_AUTO
62047 + depends on GRKERNSEC_CHROOT
62048 + help
62049 + If you say Y here, the current working directory of all newly-chrooted
62050 + applications will be set to the the root directory of the chroot.
62051 + The man page on chroot(2) states:
62052 + Note that this call does not change the current working
62053 + directory, so that `.' can be outside the tree rooted at
62054 + `/'. In particular, the super-user can escape from a
62055 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62056 +
62057 + It is recommended that you say Y here, since it's not known to break
62058 + any software. If the sysctl option is enabled, a sysctl option with
62059 + name "chroot_enforce_chdir" is created.
62060 +
62061 +config GRKERNSEC_CHROOT_CHMOD
62062 + bool "Deny (f)chmod +s"
62063 + default y if GRKERNSEC_CONFIG_AUTO
62064 + depends on GRKERNSEC_CHROOT
62065 + help
62066 + If you say Y here, processes inside a chroot will not be able to chmod
62067 + or fchmod files to make them have suid or sgid bits. This protects
62068 + against another published method of breaking a chroot. If the sysctl
62069 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62070 + created.
62071 +
62072 +config GRKERNSEC_CHROOT_FCHDIR
62073 + bool "Deny fchdir out of chroot"
62074 + default y if GRKERNSEC_CONFIG_AUTO
62075 + depends on GRKERNSEC_CHROOT
62076 + help
62077 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62078 + to a file descriptor of the chrooting process that points to a directory
62079 + outside the filesystem will be stopped. If the sysctl option
62080 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62081 +
62082 +config GRKERNSEC_CHROOT_MKNOD
62083 + bool "Deny mknod"
62084 + default y if GRKERNSEC_CONFIG_AUTO
62085 + depends on GRKERNSEC_CHROOT
62086 + help
62087 + If you say Y here, processes inside a chroot will not be allowed to
62088 + mknod. The problem with using mknod inside a chroot is that it
62089 + would allow an attacker to create a device entry that is the same
62090 + as one on the physical root of your system, which could range from
62091 + anything from the console device to a device for your harddrive (which
62092 + they could then use to wipe the drive or steal data). It is recommended
62093 + that you say Y here, unless you run into software incompatibilities.
62094 + If the sysctl option is enabled, a sysctl option with name
62095 + "chroot_deny_mknod" is created.
62096 +
62097 +config GRKERNSEC_CHROOT_SHMAT
62098 + bool "Deny shmat() out of chroot"
62099 + default y if GRKERNSEC_CONFIG_AUTO
62100 + depends on GRKERNSEC_CHROOT
62101 + help
62102 + If you say Y here, processes inside a chroot will not be able to attach
62103 + to shared memory segments that were created outside of the chroot jail.
62104 + It is recommended that you say Y here. If the sysctl option is enabled,
62105 + a sysctl option with name "chroot_deny_shmat" is created.
62106 +
62107 +config GRKERNSEC_CHROOT_UNIX
62108 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62109 + default y if GRKERNSEC_CONFIG_AUTO
62110 + depends on GRKERNSEC_CHROOT
62111 + help
62112 + If you say Y here, processes inside a chroot will not be able to
62113 + connect to abstract (meaning not belonging to a filesystem) Unix
62114 + domain sockets that were bound outside of a chroot. It is recommended
62115 + that you say Y here. If the sysctl option is enabled, a sysctl option
62116 + with name "chroot_deny_unix" is created.
62117 +
62118 +config GRKERNSEC_CHROOT_FINDTASK
62119 + bool "Protect outside processes"
62120 + default y if GRKERNSEC_CONFIG_AUTO
62121 + depends on GRKERNSEC_CHROOT
62122 + help
62123 + If you say Y here, processes inside a chroot will not be able to
62124 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62125 + getsid, or view any process outside of the chroot. If the sysctl
62126 + option is enabled, a sysctl option with name "chroot_findtask" is
62127 + created.
62128 +
62129 +config GRKERNSEC_CHROOT_NICE
62130 + bool "Restrict priority changes"
62131 + default y if GRKERNSEC_CONFIG_AUTO
62132 + depends on GRKERNSEC_CHROOT
62133 + help
62134 + If you say Y here, processes inside a chroot will not be able to raise
62135 + the priority of processes in the chroot, or alter the priority of
62136 + processes outside the chroot. This provides more security than simply
62137 + removing CAP_SYS_NICE from the process' capability set. If the
62138 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62139 + is created.
62140 +
62141 +config GRKERNSEC_CHROOT_SYSCTL
62142 + bool "Deny sysctl writes"
62143 + default y if GRKERNSEC_CONFIG_AUTO
62144 + depends on GRKERNSEC_CHROOT
62145 + help
62146 + If you say Y here, an attacker in a chroot will not be able to
62147 + write to sysctl entries, either by sysctl(2) or through a /proc
62148 + interface. It is strongly recommended that you say Y here. If the
62149 + sysctl option is enabled, a sysctl option with name
62150 + "chroot_deny_sysctl" is created.
62151 +
62152 +config GRKERNSEC_CHROOT_CAPS
62153 + bool "Capability restrictions"
62154 + default y if GRKERNSEC_CONFIG_AUTO
62155 + depends on GRKERNSEC_CHROOT
62156 + help
62157 + If you say Y here, the capabilities on all processes within a
62158 + chroot jail will be lowered to stop module insertion, raw i/o,
62159 + system and net admin tasks, rebooting the system, modifying immutable
62160 + files, modifying IPC owned by another, and changing the system time.
62161 + This is left an option because it can break some apps. Disable this
62162 + if your chrooted apps are having problems performing those kinds of
62163 + tasks. If the sysctl option is enabled, a sysctl option with
62164 + name "chroot_caps" is created.
62165 +
62166 +config GRKERNSEC_CHROOT_INITRD
62167 + bool "Exempt initrd tasks from restrictions"
62168 + default y if GRKERNSEC_CONFIG_AUTO
62169 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
62170 + help
62171 + If you say Y here, tasks started prior to init will be exempted from
62172 + grsecurity's chroot restrictions. This option is mainly meant to
62173 + resolve Plymouth's performing privileged operations unnecessarily
62174 + in a chroot.
62175 +
62176 +endmenu
62177 +menu "Kernel Auditing"
62178 +depends on GRKERNSEC
62179 +
62180 +config GRKERNSEC_AUDIT_GROUP
62181 + bool "Single group for auditing"
62182 + help
62183 + If you say Y here, the exec and chdir logging features will only operate
62184 + on a group you specify. This option is recommended if you only want to
62185 + watch certain users instead of having a large amount of logs from the
62186 + entire system. If the sysctl option is enabled, a sysctl option with
62187 + name "audit_group" is created.
62188 +
62189 +config GRKERNSEC_AUDIT_GID
62190 + int "GID for auditing"
62191 + depends on GRKERNSEC_AUDIT_GROUP
62192 + default 1007
62193 +
62194 +config GRKERNSEC_EXECLOG
62195 + bool "Exec logging"
62196 + help
62197 + If you say Y here, all execve() calls will be logged (since the
62198 + other exec*() calls are frontends to execve(), all execution
62199 + will be logged). Useful for shell-servers that like to keep track
62200 + of their users. If the sysctl option is enabled, a sysctl option with
62201 + name "exec_logging" is created.
62202 + WARNING: This option when enabled will produce a LOT of logs, especially
62203 + on an active system.
62204 +
62205 +config GRKERNSEC_RESLOG
62206 + bool "Resource logging"
62207 + default y if GRKERNSEC_CONFIG_AUTO
62208 + help
62209 + If you say Y here, all attempts to overstep resource limits will
62210 + be logged with the resource name, the requested size, and the current
62211 + limit. It is highly recommended that you say Y here. If the sysctl
62212 + option is enabled, a sysctl option with name "resource_logging" is
62213 + created. If the RBAC system is enabled, the sysctl value is ignored.
62214 +
62215 +config GRKERNSEC_CHROOT_EXECLOG
62216 + bool "Log execs within chroot"
62217 + help
62218 + If you say Y here, all executions inside a chroot jail will be logged
62219 + to syslog. This can cause a large amount of logs if certain
62220 + applications (eg. djb's daemontools) are installed on the system, and
62221 + is therefore left as an option. If the sysctl option is enabled, a
62222 + sysctl option with name "chroot_execlog" is created.
62223 +
62224 +config GRKERNSEC_AUDIT_PTRACE
62225 + bool "Ptrace logging"
62226 + help
62227 + If you say Y here, all attempts to attach to a process via ptrace
62228 + will be logged. If the sysctl option is enabled, a sysctl option
62229 + with name "audit_ptrace" is created.
62230 +
62231 +config GRKERNSEC_AUDIT_CHDIR
62232 + bool "Chdir logging"
62233 + help
62234 + If you say Y here, all chdir() calls will be logged. If the sysctl
62235 + option is enabled, a sysctl option with name "audit_chdir" is created.
62236 +
62237 +config GRKERNSEC_AUDIT_MOUNT
62238 + bool "(Un)Mount logging"
62239 + help
62240 + If you say Y here, all mounts and unmounts will be logged. If the
62241 + sysctl option is enabled, a sysctl option with name "audit_mount" is
62242 + created.
62243 +
62244 +config GRKERNSEC_SIGNAL
62245 + bool "Signal logging"
62246 + default y if GRKERNSEC_CONFIG_AUTO
62247 + help
62248 + If you say Y here, certain important signals will be logged, such as
62249 + SIGSEGV, which will as a result inform you of when a error in a program
62250 + occurred, which in some cases could mean a possible exploit attempt.
62251 + If the sysctl option is enabled, a sysctl option with name
62252 + "signal_logging" is created.
62253 +
62254 +config GRKERNSEC_FORKFAIL
62255 + bool "Fork failure logging"
62256 + help
62257 + If you say Y here, all failed fork() attempts will be logged.
62258 + This could suggest a fork bomb, or someone attempting to overstep
62259 + their process limit. If the sysctl option is enabled, a sysctl option
62260 + with name "forkfail_logging" is created.
62261 +
62262 +config GRKERNSEC_TIME
62263 + bool "Time change logging"
62264 + default y if GRKERNSEC_CONFIG_AUTO
62265 + help
62266 + If you say Y here, any changes of the system clock will be logged.
62267 + If the sysctl option is enabled, a sysctl option with name
62268 + "timechange_logging" is created.
62269 +
62270 +config GRKERNSEC_PROC_IPADDR
62271 + bool "/proc/<pid>/ipaddr support"
62272 + default y if GRKERNSEC_CONFIG_AUTO
62273 + help
62274 + If you say Y here, a new entry will be added to each /proc/<pid>
62275 + directory that contains the IP address of the person using the task.
62276 + The IP is carried across local TCP and AF_UNIX stream sockets.
62277 + This information can be useful for IDS/IPSes to perform remote response
62278 + to a local attack. The entry is readable by only the owner of the
62279 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
62280 + the RBAC system), and thus does not create privacy concerns.
62281 +
62282 +config GRKERNSEC_RWXMAP_LOG
62283 + bool 'Denied RWX mmap/mprotect logging'
62284 + default y if GRKERNSEC_CONFIG_AUTO
62285 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
62286 + help
62287 + If you say Y here, calls to mmap() and mprotect() with explicit
62288 + usage of PROT_WRITE and PROT_EXEC together will be logged when
62289 + denied by the PAX_MPROTECT feature. This feature will also
62290 + log other problematic scenarios that can occur when PAX_MPROTECT
62291 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
62292 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
62293 + is created.
62294 +
62295 +endmenu
62296 +
62297 +menu "Executable Protections"
62298 +depends on GRKERNSEC
62299 +
62300 +config GRKERNSEC_DMESG
62301 + bool "Dmesg(8) restriction"
62302 + default y if GRKERNSEC_CONFIG_AUTO
62303 + help
62304 + If you say Y here, non-root users will not be able to use dmesg(8)
62305 + to view the contents of the kernel's circular log buffer.
62306 + The kernel's log buffer often contains kernel addresses and other
62307 + identifying information useful to an attacker in fingerprinting a
62308 + system for a targeted exploit.
62309 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
62310 + created.
62311 +
62312 +config GRKERNSEC_HARDEN_PTRACE
62313 + bool "Deter ptrace-based process snooping"
62314 + default y if GRKERNSEC_CONFIG_AUTO
62315 + help
62316 + If you say Y here, TTY sniffers and other malicious monitoring
62317 + programs implemented through ptrace will be defeated. If you
62318 + have been using the RBAC system, this option has already been
62319 + enabled for several years for all users, with the ability to make
62320 + fine-grained exceptions.
62321 +
62322 + This option only affects the ability of non-root users to ptrace
62323 + processes that are not a descendent of the ptracing process.
62324 + This means that strace ./binary and gdb ./binary will still work,
62325 + but attaching to arbitrary processes will not. If the sysctl
62326 + option is enabled, a sysctl option with name "harden_ptrace" is
62327 + created.
62328 +
62329 +config GRKERNSEC_PTRACE_READEXEC
62330 + bool "Require read access to ptrace sensitive binaries"
62331 + default y if GRKERNSEC_CONFIG_AUTO
62332 + help
62333 + If you say Y here, unprivileged users will not be able to ptrace unreadable
62334 + binaries. This option is useful in environments that
62335 + remove the read bits (e.g. file mode 4711) from suid binaries to
62336 + prevent infoleaking of their contents. This option adds
62337 + consistency to the use of that file mode, as the binary could normally
62338 + be read out when run without privileges while ptracing.
62339 +
62340 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
62341 + is created.
62342 +
62343 +config GRKERNSEC_SETXID
62344 + bool "Enforce consistent multithreaded privileges"
62345 + default y if GRKERNSEC_CONFIG_AUTO
62346 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
62347 + help
62348 + If you say Y here, a change from a root uid to a non-root uid
62349 + in a multithreaded application will cause the resulting uids,
62350 + gids, supplementary groups, and capabilities in that thread
62351 + to be propagated to the other threads of the process. In most
62352 + cases this is unnecessary, as glibc will emulate this behavior
62353 + on behalf of the application. Other libcs do not act in the
62354 + same way, allowing the other threads of the process to continue
62355 + running with root privileges. If the sysctl option is enabled,
62356 + a sysctl option with name "consistent_setxid" is created.
62357 +
62358 +config GRKERNSEC_HARDEN_IPC
62359 + bool "Disallow access to world-accessible IPC objects"
62360 + default y if GRKERNSEC_CONFIG_AUTO
62361 + depends on SYSVIPC
62362 + help
62363 + If you say Y here, access to overly-permissive IPC (shared memory,
62364 + message queues, and semaphores) will be denied for processes whose
62365 + effective user or group would not grant them permission. It's a
62366 + common error to grant too much permission to these objects, with
62367 + impact ranging from denial of service and information leaking to
62368 + privilege escalation. This feature was developed in response to
62369 + research by Tim Brown:
62370 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
62371 + who found hundreds of such insecure usages. Processes with
62372 + CAP_IPC_OWNER are still permitted to access these IPC objects.
62373 + If the sysctl option is enabled, a sysctl option with name
62374 + "harden_ipc" is created.
62375 +
62376 +config GRKERNSEC_TPE
62377 + bool "Trusted Path Execution (TPE)"
62378 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62379 + help
62380 + If you say Y here, you will be able to choose a gid to add to the
62381 + supplementary groups of users you want to mark as "untrusted."
62382 + These users will not be able to execute any files that are not in
62383 + root-owned directories writable only by root. If the sysctl option
62384 + is enabled, a sysctl option with name "tpe" is created.
62385 +
62386 +config GRKERNSEC_TPE_ALL
62387 + bool "Partially restrict all non-root users"
62388 + depends on GRKERNSEC_TPE
62389 + help
62390 + If you say Y here, all non-root users will be covered under
62391 + a weaker TPE restriction. This is separate from, and in addition to,
62392 + the main TPE options that you have selected elsewhere. Thus, if a
62393 + "trusted" GID is chosen, this restriction applies to even that GID.
62394 + Under this restriction, all non-root users will only be allowed to
62395 + execute files in directories they own that are not group or
62396 + world-writable, or in directories owned by root and writable only by
62397 + root. If the sysctl option is enabled, a sysctl option with name
62398 + "tpe_restrict_all" is created.
62399 +
62400 +config GRKERNSEC_TPE_INVERT
62401 + bool "Invert GID option"
62402 + depends on GRKERNSEC_TPE
62403 + help
62404 + If you say Y here, the group you specify in the TPE configuration will
62405 + decide what group TPE restrictions will be *disabled* for. This
62406 + option is useful if you want TPE restrictions to be applied to most
62407 + users on the system. If the sysctl option is enabled, a sysctl option
62408 + with name "tpe_invert" is created. Unlike other sysctl options, this
62409 + entry will default to on for backward-compatibility.
62410 +
62411 +config GRKERNSEC_TPE_GID
62412 + int
62413 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
62414 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
62415 +
62416 +config GRKERNSEC_TPE_UNTRUSTED_GID
62417 + int "GID for TPE-untrusted users"
62418 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
62419 + default 1005
62420 + help
62421 + Setting this GID determines what group TPE restrictions will be
62422 + *enabled* for. If the sysctl option is enabled, a sysctl option
62423 + with name "tpe_gid" is created.
62424 +
62425 +config GRKERNSEC_TPE_TRUSTED_GID
62426 + int "GID for TPE-trusted users"
62427 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
62428 + default 1005
62429 + help
62430 + Setting this GID determines what group TPE restrictions will be
62431 + *disabled* for. If the sysctl option is enabled, a sysctl option
62432 + with name "tpe_gid" is created.
62433 +
62434 +endmenu
62435 +menu "Network Protections"
62436 +depends on GRKERNSEC
62437 +
62438 +config GRKERNSEC_RANDNET
62439 + bool "Larger entropy pools"
62440 + default y if GRKERNSEC_CONFIG_AUTO
62441 + help
62442 + If you say Y here, the entropy pools used for many features of Linux
62443 + and grsecurity will be doubled in size. Since several grsecurity
62444 + features use additional randomness, it is recommended that you say Y
62445 + here. Saying Y here has a similar effect as modifying
62446 + /proc/sys/kernel/random/poolsize.
62447 +
62448 +config GRKERNSEC_BLACKHOLE
62449 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
62450 + default y if GRKERNSEC_CONFIG_AUTO
62451 + depends on NET
62452 + help
62453 + If you say Y here, neither TCP resets nor ICMP
62454 + destination-unreachable packets will be sent in response to packets
62455 + sent to ports for which no associated listening process exists.
62456 + This feature supports both IPV4 and IPV6 and exempts the
62457 + loopback interface from blackholing. Enabling this feature
62458 + makes a host more resilient to DoS attacks and reduces network
62459 + visibility against scanners.
62460 +
62461 + The blackhole feature as-implemented is equivalent to the FreeBSD
62462 + blackhole feature, as it prevents RST responses to all packets, not
62463 + just SYNs. Under most application behavior this causes no
62464 + problems, but applications (like haproxy) may not close certain
62465 + connections in a way that cleanly terminates them on the remote
62466 + end, leaving the remote host in LAST_ACK state. Because of this
62467 + side-effect and to prevent intentional LAST_ACK DoSes, this
62468 + feature also adds automatic mitigation against such attacks.
62469 + The mitigation drastically reduces the amount of time a socket
62470 + can spend in LAST_ACK state. If you're using haproxy and not
62471 + all servers it connects to have this option enabled, consider
62472 + disabling this feature on the haproxy host.
62473 +
62474 + If the sysctl option is enabled, two sysctl options with names
62475 + "ip_blackhole" and "lastack_retries" will be created.
62476 + While "ip_blackhole" takes the standard zero/non-zero on/off
62477 + toggle, "lastack_retries" uses the same kinds of values as
62478 + "tcp_retries1" and "tcp_retries2". The default value of 4
62479 + prevents a socket from lasting more than 45 seconds in LAST_ACK
62480 + state.
62481 +
62482 +config GRKERNSEC_NO_SIMULT_CONNECT
62483 + bool "Disable TCP Simultaneous Connect"
62484 + default y if GRKERNSEC_CONFIG_AUTO
62485 + depends on NET
62486 + help
62487 + If you say Y here, a feature by Willy Tarreau will be enabled that
62488 + removes a weakness in Linux's strict implementation of TCP that
62489 + allows two clients to connect to each other without either entering
62490 + a listening state. The weakness allows an attacker to easily prevent
62491 + a client from connecting to a known server provided the source port
62492 + for the connection is guessed correctly.
62493 +
62494 + As the weakness could be used to prevent an antivirus or IPS from
62495 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62496 + it should be eliminated by enabling this option. Though Linux is
62497 + one of few operating systems supporting simultaneous connect, it
62498 + has no legitimate use in practice and is rarely supported by firewalls.
62499 +
62500 +config GRKERNSEC_SOCKET
62501 + bool "Socket restrictions"
62502 + depends on NET
62503 + help
62504 + If you say Y here, you will be able to choose from several options.
62505 + If you assign a GID on your system and add it to the supplementary
62506 + groups of users you want to restrict socket access to, this patch
62507 + will perform up to three things, based on the option(s) you choose.
62508 +
62509 +config GRKERNSEC_SOCKET_ALL
62510 + bool "Deny any sockets to group"
62511 + depends on GRKERNSEC_SOCKET
62512 + help
62513 + If you say Y here, you will be able to choose a GID of whose users will
62514 + be unable to connect to other hosts from your machine or run server
62515 + applications from your machine. If the sysctl option is enabled, a
62516 + sysctl option with name "socket_all" is created.
62517 +
62518 +config GRKERNSEC_SOCKET_ALL_GID
62519 + int "GID to deny all sockets for"
62520 + depends on GRKERNSEC_SOCKET_ALL
62521 + default 1004
62522 + help
62523 + Here you can choose the GID to disable socket access for. Remember to
62524 + add the users you want socket access disabled for to the GID
62525 + specified here. If the sysctl option is enabled, a sysctl option
62526 + with name "socket_all_gid" is created.
62527 +
62528 +config GRKERNSEC_SOCKET_CLIENT
62529 + bool "Deny client sockets to group"
62530 + depends on GRKERNSEC_SOCKET
62531 + help
62532 + If you say Y here, you will be able to choose a GID of whose users will
62533 + be unable to connect to other hosts from your machine, but will be
62534 + able to run servers. If this option is enabled, all users in the group
62535 + you specify will have to use passive mode when initiating ftp transfers
62536 + from the shell on your machine. If the sysctl option is enabled, a
62537 + sysctl option with name "socket_client" is created.
62538 +
62539 +config GRKERNSEC_SOCKET_CLIENT_GID
62540 + int "GID to deny client sockets for"
62541 + depends on GRKERNSEC_SOCKET_CLIENT
62542 + default 1003
62543 + help
62544 + Here you can choose the GID to disable client socket access for.
62545 + Remember to add the users you want client socket access disabled for to
62546 + the GID specified here. If the sysctl option is enabled, a sysctl
62547 + option with name "socket_client_gid" is created.
62548 +
62549 +config GRKERNSEC_SOCKET_SERVER
62550 + bool "Deny server sockets to group"
62551 + depends on GRKERNSEC_SOCKET
62552 + help
62553 + If you say Y here, you will be able to choose a GID of whose users will
62554 + be unable to run server applications from your machine. If the sysctl
62555 + option is enabled, a sysctl option with name "socket_server" is created.
62556 +
62557 +config GRKERNSEC_SOCKET_SERVER_GID
62558 + int "GID to deny server sockets for"
62559 + depends on GRKERNSEC_SOCKET_SERVER
62560 + default 1002
62561 + help
62562 + Here you can choose the GID to disable server socket access for.
62563 + Remember to add the users you want server socket access disabled for to
62564 + the GID specified here. If the sysctl option is enabled, a sysctl
62565 + option with name "socket_server_gid" is created.
62566 +
62567 +endmenu
62568 +
62569 +menu "Physical Protections"
62570 +depends on GRKERNSEC
62571 +
62572 +config GRKERNSEC_DENYUSB
62573 + bool "Deny new USB connections after toggle"
62574 + default y if GRKERNSEC_CONFIG_AUTO
62575 + depends on SYSCTL && USB_SUPPORT
62576 + help
62577 + If you say Y here, a new sysctl option with name "deny_new_usb"
62578 + will be created. Setting its value to 1 will prevent any new
62579 + USB devices from being recognized by the OS. Any attempted USB
62580 + device insertion will be logged. This option is intended to be
62581 + used against custom USB devices designed to exploit vulnerabilities
62582 + in various USB device drivers.
62583 +
62584 + For greatest effectiveness, this sysctl should be set after any
62585 + relevant init scripts. This option is safe to enable in distros
62586 + as each user can choose whether or not to toggle the sysctl.
62587 +
62588 +config GRKERNSEC_DENYUSB_FORCE
62589 + bool "Reject all USB devices not connected at boot"
62590 + select USB
62591 + depends on GRKERNSEC_DENYUSB
62592 + help
62593 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62594 + that doesn't involve a sysctl entry. This option should only be
62595 + enabled if you're sure you want to deny all new USB connections
62596 + at runtime and don't want to modify init scripts. This should not
62597 + be enabled by distros. It forces the core USB code to be built
62598 + into the kernel image so that all devices connected at boot time
62599 + can be recognized and new USB device connections can be prevented
62600 + prior to init running.
62601 +
62602 +endmenu
62603 +
62604 +menu "Sysctl Support"
62605 +depends on GRKERNSEC && SYSCTL
62606 +
62607 +config GRKERNSEC_SYSCTL
62608 + bool "Sysctl support"
62609 + default y if GRKERNSEC_CONFIG_AUTO
62610 + help
62611 + If you say Y here, you will be able to change the options that
62612 + grsecurity runs with at bootup, without having to recompile your
62613 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62614 + to enable (1) or disable (0) various features. All the sysctl entries
62615 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62616 + All features enabled in the kernel configuration are disabled at boot
62617 + if you do not say Y to the "Turn on features by default" option.
62618 + All options should be set at startup, and the grsec_lock entry should
62619 + be set to a non-zero value after all the options are set.
62620 + *THIS IS EXTREMELY IMPORTANT*
62621 +
62622 +config GRKERNSEC_SYSCTL_DISTRO
62623 + bool "Extra sysctl support for distro makers (READ HELP)"
62624 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62625 + help
62626 + If you say Y here, additional sysctl options will be created
62627 + for features that affect processes running as root. Therefore,
62628 + it is critical when using this option that the grsec_lock entry be
62629 + enabled after boot. Only distros with prebuilt kernel packages
62630 + with this option enabled that can ensure grsec_lock is enabled
62631 + after boot should use this option.
62632 + *Failure to set grsec_lock after boot makes all grsec features
62633 + this option covers useless*
62634 +
62635 + Currently this option creates the following sysctl entries:
62636 + "Disable Privileged I/O": "disable_priv_io"
62637 +
62638 +config GRKERNSEC_SYSCTL_ON
62639 + bool "Turn on features by default"
62640 + default y if GRKERNSEC_CONFIG_AUTO
62641 + depends on GRKERNSEC_SYSCTL
62642 + help
62643 + If you say Y here, instead of having all features enabled in the
62644 + kernel configuration disabled at boot time, the features will be
62645 + enabled at boot time. It is recommended you say Y here unless
62646 + there is some reason you would want all sysctl-tunable features to
62647 + be disabled by default. As mentioned elsewhere, it is important
62648 + to enable the grsec_lock entry once you have finished modifying
62649 + the sysctl entries.
62650 +
62651 +endmenu
62652 +menu "Logging Options"
62653 +depends on GRKERNSEC
62654 +
62655 +config GRKERNSEC_FLOODTIME
62656 + int "Seconds in between log messages (minimum)"
62657 + default 10
62658 + help
62659 + This option allows you to enforce the number of seconds between
62660 + grsecurity log messages. The default should be suitable for most
62661 + people, however, if you choose to change it, choose a value small enough
62662 + to allow informative logs to be produced, but large enough to
62663 + prevent flooding.
62664 +
62665 +config GRKERNSEC_FLOODBURST
62666 + int "Number of messages in a burst (maximum)"
62667 + default 6
62668 + help
62669 + This option allows you to choose the maximum number of messages allowed
62670 + within the flood time interval you chose in a separate option. The
62671 + default should be suitable for most people, however if you find that
62672 + many of your logs are being interpreted as flooding, you may want to
62673 + raise this value.
62674 +
62675 +endmenu
62676 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62677 new file mode 100644
62678 index 0000000..85beb79
62679 --- /dev/null
62680 +++ b/grsecurity/Makefile
62681 @@ -0,0 +1,43 @@
62682 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62683 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62684 +# into an RBAC system
62685 +#
62686 +# All code in this directory and various hooks inserted throughout the kernel
62687 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62688 +# under the GPL v2 or higher
62689 +
62690 +KBUILD_CFLAGS += -Werror
62691 +
62692 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62693 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62694 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62695 + grsec_usb.o grsec_ipc.o
62696 +
62697 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62698 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62699 + gracl_learn.o grsec_log.o gracl_policy.o
62700 +ifdef CONFIG_COMPAT
62701 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62702 +endif
62703 +
62704 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62705 +
62706 +ifdef CONFIG_NET
62707 +obj-y += grsec_sock.o
62708 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62709 +endif
62710 +
62711 +ifndef CONFIG_GRKERNSEC
62712 +obj-y += grsec_disabled.o
62713 +endif
62714 +
62715 +ifdef CONFIG_GRKERNSEC_HIDESYM
62716 +extra-y := grsec_hidesym.o
62717 +$(obj)/grsec_hidesym.o:
62718 + @-chmod -f 500 /boot
62719 + @-chmod -f 500 /lib/modules
62720 + @-chmod -f 500 /lib64/modules
62721 + @-chmod -f 500 /lib32/modules
62722 + @-chmod -f 700 .
62723 + @echo ' grsec: protected kernel image paths'
62724 +endif
62725 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62726 new file mode 100644
62727 index 0000000..6affeea
62728 --- /dev/null
62729 +++ b/grsecurity/gracl.c
62730 @@ -0,0 +1,2679 @@
62731 +#include <linux/kernel.h>
62732 +#include <linux/module.h>
62733 +#include <linux/sched.h>
62734 +#include <linux/mm.h>
62735 +#include <linux/file.h>
62736 +#include <linux/fs.h>
62737 +#include <linux/namei.h>
62738 +#include <linux/mount.h>
62739 +#include <linux/tty.h>
62740 +#include <linux/proc_fs.h>
62741 +#include <linux/lglock.h>
62742 +#include <linux/slab.h>
62743 +#include <linux/vmalloc.h>
62744 +#include <linux/types.h>
62745 +#include <linux/sysctl.h>
62746 +#include <linux/netdevice.h>
62747 +#include <linux/ptrace.h>
62748 +#include <linux/gracl.h>
62749 +#include <linux/gralloc.h>
62750 +#include <linux/security.h>
62751 +#include <linux/grinternal.h>
62752 +#include <linux/pid_namespace.h>
62753 +#include <linux/stop_machine.h>
62754 +#include <linux/fdtable.h>
62755 +#include <linux/percpu.h>
62756 +#include <linux/lglock.h>
62757 +#include <linux/hugetlb.h>
62758 +#include <linux/posix-timers.h>
62759 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62760 +#include <linux/magic.h>
62761 +#include <linux/pagemap.h>
62762 +#include "../fs/btrfs/async-thread.h"
62763 +#include "../fs/btrfs/ctree.h"
62764 +#include "../fs/btrfs/btrfs_inode.h"
62765 +#endif
62766 +#include "../fs/mount.h"
62767 +
62768 +#include <asm/uaccess.h>
62769 +#include <asm/errno.h>
62770 +#include <asm/mman.h>
62771 +
62772 +#define FOR_EACH_ROLE_START(role) \
62773 + role = running_polstate.role_list; \
62774 + while (role) {
62775 +
62776 +#define FOR_EACH_ROLE_END(role) \
62777 + role = role->prev; \
62778 + }
62779 +
62780 +extern struct lglock vfsmount_lock;
62781 +
62782 +extern struct path gr_real_root;
62783 +
62784 +static struct gr_policy_state running_polstate;
62785 +struct gr_policy_state *polstate = &running_polstate;
62786 +extern struct gr_alloc_state *current_alloc_state;
62787 +
62788 +extern char *gr_shared_page[4];
62789 +DEFINE_RWLOCK(gr_inode_lock);
62790 +
62791 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62792 +
62793 +#ifdef CONFIG_NET
62794 +extern struct vfsmount *sock_mnt;
62795 +#endif
62796 +
62797 +extern struct vfsmount *pipe_mnt;
62798 +extern struct vfsmount *shm_mnt;
62799 +
62800 +#ifdef CONFIG_HUGETLBFS
62801 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62802 +#endif
62803 +
62804 +extern u16 acl_sp_role_value;
62805 +extern struct acl_object_label *fakefs_obj_rw;
62806 +extern struct acl_object_label *fakefs_obj_rwx;
62807 +
62808 +int gr_acl_is_enabled(void)
62809 +{
62810 + return (gr_status & GR_READY);
62811 +}
62812 +
62813 +void gr_enable_rbac_system(void)
62814 +{
62815 + pax_open_kernel();
62816 + gr_status |= GR_READY;
62817 + pax_close_kernel();
62818 +}
62819 +
62820 +int gr_rbac_disable(void *unused)
62821 +{
62822 + pax_open_kernel();
62823 + gr_status &= ~GR_READY;
62824 + pax_close_kernel();
62825 +
62826 + return 0;
62827 +}
62828 +
62829 +static inline dev_t __get_dev(const struct dentry *dentry)
62830 +{
62831 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62832 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62833 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62834 + else
62835 +#endif
62836 + return dentry->d_sb->s_dev;
62837 +}
62838 +
62839 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62840 +{
62841 + return __get_dev(dentry);
62842 +}
62843 +
62844 +static char gr_task_roletype_to_char(struct task_struct *task)
62845 +{
62846 + switch (task->role->roletype &
62847 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62848 + GR_ROLE_SPECIAL)) {
62849 + case GR_ROLE_DEFAULT:
62850 + return 'D';
62851 + case GR_ROLE_USER:
62852 + return 'U';
62853 + case GR_ROLE_GROUP:
62854 + return 'G';
62855 + case GR_ROLE_SPECIAL:
62856 + return 'S';
62857 + }
62858 +
62859 + return 'X';
62860 +}
62861 +
62862 +char gr_roletype_to_char(void)
62863 +{
62864 + return gr_task_roletype_to_char(current);
62865 +}
62866 +
62867 +__inline__ int
62868 +gr_acl_tpe_check(void)
62869 +{
62870 + if (unlikely(!(gr_status & GR_READY)))
62871 + return 0;
62872 + if (current->role->roletype & GR_ROLE_TPE)
62873 + return 1;
62874 + else
62875 + return 0;
62876 +}
62877 +
62878 +int
62879 +gr_handle_rawio(const struct inode *inode)
62880 +{
62881 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62882 + if (inode && S_ISBLK(inode->i_mode) &&
62883 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62884 + !capable(CAP_SYS_RAWIO))
62885 + return 1;
62886 +#endif
62887 + return 0;
62888 +}
62889 +
62890 +int
62891 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62892 +{
62893 + if (likely(lena != lenb))
62894 + return 0;
62895 +
62896 + return !memcmp(a, b, lena);
62897 +}
62898 +
62899 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62900 +{
62901 + *buflen -= namelen;
62902 + if (*buflen < 0)
62903 + return -ENAMETOOLONG;
62904 + *buffer -= namelen;
62905 + memcpy(*buffer, str, namelen);
62906 + return 0;
62907 +}
62908 +
62909 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62910 +{
62911 + return prepend(buffer, buflen, name->name, name->len);
62912 +}
62913 +
62914 +static int prepend_path(const struct path *path, struct path *root,
62915 + char **buffer, int *buflen)
62916 +{
62917 + struct dentry *dentry = path->dentry;
62918 + struct vfsmount *vfsmnt = path->mnt;
62919 + struct mount *mnt = real_mount(vfsmnt);
62920 + bool slash = false;
62921 + int error = 0;
62922 +
62923 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62924 + struct dentry * parent;
62925 +
62926 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62927 + /* Global root? */
62928 + if (!mnt_has_parent(mnt)) {
62929 + goto out;
62930 + }
62931 + dentry = mnt->mnt_mountpoint;
62932 + mnt = mnt->mnt_parent;
62933 + vfsmnt = &mnt->mnt;
62934 + continue;
62935 + }
62936 + parent = dentry->d_parent;
62937 + prefetch(parent);
62938 + spin_lock(&dentry->d_lock);
62939 + error = prepend_name(buffer, buflen, &dentry->d_name);
62940 + spin_unlock(&dentry->d_lock);
62941 + if (!error)
62942 + error = prepend(buffer, buflen, "/", 1);
62943 + if (error)
62944 + break;
62945 +
62946 + slash = true;
62947 + dentry = parent;
62948 + }
62949 +
62950 +out:
62951 + if (!error && !slash)
62952 + error = prepend(buffer, buflen, "/", 1);
62953 +
62954 + return error;
62955 +}
62956 +
62957 +/* this must be called with vfsmount_lock and rename_lock held */
62958 +
62959 +static char *__our_d_path(const struct path *path, struct path *root,
62960 + char *buf, int buflen)
62961 +{
62962 + char *res = buf + buflen;
62963 + int error;
62964 +
62965 + prepend(&res, &buflen, "\0", 1);
62966 + error = prepend_path(path, root, &res, &buflen);
62967 + if (error)
62968 + return ERR_PTR(error);
62969 +
62970 + return res;
62971 +}
62972 +
62973 +static char *
62974 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62975 +{
62976 + char *retval;
62977 +
62978 + retval = __our_d_path(path, root, buf, buflen);
62979 + if (unlikely(IS_ERR(retval)))
62980 + retval = strcpy(buf, "<path too long>");
62981 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62982 + retval[1] = '\0';
62983 +
62984 + return retval;
62985 +}
62986 +
62987 +static char *
62988 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62989 + char *buf, int buflen)
62990 +{
62991 + struct path path;
62992 + char *res;
62993 +
62994 + path.dentry = (struct dentry *)dentry;
62995 + path.mnt = (struct vfsmount *)vfsmnt;
62996 +
62997 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
62998 + by the RBAC system */
62999 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63000 +
63001 + return res;
63002 +}
63003 +
63004 +static char *
63005 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63006 + char *buf, int buflen)
63007 +{
63008 + char *res;
63009 + struct path path;
63010 + struct path root;
63011 + struct task_struct *reaper = init_pid_ns.child_reaper;
63012 +
63013 + path.dentry = (struct dentry *)dentry;
63014 + path.mnt = (struct vfsmount *)vfsmnt;
63015 +
63016 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63017 + get_fs_root(reaper->fs, &root);
63018 +
63019 + br_read_lock(&vfsmount_lock);
63020 + write_seqlock(&rename_lock);
63021 + res = gen_full_path(&path, &root, buf, buflen);
63022 + write_sequnlock(&rename_lock);
63023 + br_read_unlock(&vfsmount_lock);
63024 +
63025 + path_put(&root);
63026 + return res;
63027 +}
63028 +
63029 +char *
63030 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63031 +{
63032 + char *ret;
63033 + br_read_lock(&vfsmount_lock);
63034 + write_seqlock(&rename_lock);
63035 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63036 + PAGE_SIZE);
63037 + write_sequnlock(&rename_lock);
63038 + br_read_unlock(&vfsmount_lock);
63039 + return ret;
63040 +}
63041 +
63042 +static char *
63043 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63044 +{
63045 + char *ret;
63046 + char *buf;
63047 + int buflen;
63048 +
63049 + br_read_lock(&vfsmount_lock);
63050 + write_seqlock(&rename_lock);
63051 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
63052 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
63053 + buflen = (int)(ret - buf);
63054 + if (buflen >= 5)
63055 + prepend(&ret, &buflen, "/proc", 5);
63056 + else
63057 + ret = strcpy(buf, "<path too long>");
63058 + write_sequnlock(&rename_lock);
63059 + br_read_unlock(&vfsmount_lock);
63060 + return ret;
63061 +}
63062 +
63063 +char *
63064 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
63065 +{
63066 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63067 + PAGE_SIZE);
63068 +}
63069 +
63070 +char *
63071 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
63072 +{
63073 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
63074 + PAGE_SIZE);
63075 +}
63076 +
63077 +char *
63078 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
63079 +{
63080 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
63081 + PAGE_SIZE);
63082 +}
63083 +
63084 +char *
63085 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
63086 +{
63087 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
63088 + PAGE_SIZE);
63089 +}
63090 +
63091 +char *
63092 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
63093 +{
63094 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
63095 + PAGE_SIZE);
63096 +}
63097 +
63098 +__inline__ __u32
63099 +to_gr_audit(const __u32 reqmode)
63100 +{
63101 + /* masks off auditable permission flags, then shifts them to create
63102 + auditing flags, and adds the special case of append auditing if
63103 + we're requesting write */
63104 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
63105 +}
63106 +
63107 +struct acl_role_label *
63108 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
63109 + const gid_t gid)
63110 +{
63111 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
63112 + struct acl_role_label *match;
63113 + struct role_allowed_ip *ipp;
63114 + unsigned int x;
63115 + u32 curr_ip = task->signal->saved_ip;
63116 +
63117 + match = state->acl_role_set.r_hash[index];
63118 +
63119 + while (match) {
63120 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
63121 + for (x = 0; x < match->domain_child_num; x++) {
63122 + if (match->domain_children[x] == uid)
63123 + goto found;
63124 + }
63125 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
63126 + break;
63127 + match = match->next;
63128 + }
63129 +found:
63130 + if (match == NULL) {
63131 + try_group:
63132 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
63133 + match = state->acl_role_set.r_hash[index];
63134 +
63135 + while (match) {
63136 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
63137 + for (x = 0; x < match->domain_child_num; x++) {
63138 + if (match->domain_children[x] == gid)
63139 + goto found2;
63140 + }
63141 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
63142 + break;
63143 + match = match->next;
63144 + }
63145 +found2:
63146 + if (match == NULL)
63147 + match = state->default_role;
63148 + if (match->allowed_ips == NULL)
63149 + return match;
63150 + else {
63151 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63152 + if (likely
63153 + ((ntohl(curr_ip) & ipp->netmask) ==
63154 + (ntohl(ipp->addr) & ipp->netmask)))
63155 + return match;
63156 + }
63157 + match = state->default_role;
63158 + }
63159 + } else if (match->allowed_ips == NULL) {
63160 + return match;
63161 + } else {
63162 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63163 + if (likely
63164 + ((ntohl(curr_ip) & ipp->netmask) ==
63165 + (ntohl(ipp->addr) & ipp->netmask)))
63166 + return match;
63167 + }
63168 + goto try_group;
63169 + }
63170 +
63171 + return match;
63172 +}
63173 +
63174 +static struct acl_role_label *
63175 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
63176 + const gid_t gid)
63177 +{
63178 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
63179 +}
63180 +
63181 +struct acl_subject_label *
63182 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
63183 + const struct acl_role_label *role)
63184 +{
63185 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63186 + struct acl_subject_label *match;
63187 +
63188 + match = role->subj_hash[index];
63189 +
63190 + while (match && (match->inode != ino || match->device != dev ||
63191 + (match->mode & GR_DELETED))) {
63192 + match = match->next;
63193 + }
63194 +
63195 + if (match && !(match->mode & GR_DELETED))
63196 + return match;
63197 + else
63198 + return NULL;
63199 +}
63200 +
63201 +struct acl_subject_label *
63202 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
63203 + const struct acl_role_label *role)
63204 +{
63205 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63206 + struct acl_subject_label *match;
63207 +
63208 + match = role->subj_hash[index];
63209 +
63210 + while (match && (match->inode != ino || match->device != dev ||
63211 + !(match->mode & GR_DELETED))) {
63212 + match = match->next;
63213 + }
63214 +
63215 + if (match && (match->mode & GR_DELETED))
63216 + return match;
63217 + else
63218 + return NULL;
63219 +}
63220 +
63221 +static struct acl_object_label *
63222 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
63223 + const struct acl_subject_label *subj)
63224 +{
63225 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63226 + struct acl_object_label *match;
63227 +
63228 + match = subj->obj_hash[index];
63229 +
63230 + while (match && (match->inode != ino || match->device != dev ||
63231 + (match->mode & GR_DELETED))) {
63232 + match = match->next;
63233 + }
63234 +
63235 + if (match && !(match->mode & GR_DELETED))
63236 + return match;
63237 + else
63238 + return NULL;
63239 +}
63240 +
63241 +static struct acl_object_label *
63242 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
63243 + const struct acl_subject_label *subj)
63244 +{
63245 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63246 + struct acl_object_label *match;
63247 +
63248 + match = subj->obj_hash[index];
63249 +
63250 + while (match && (match->inode != ino || match->device != dev ||
63251 + !(match->mode & GR_DELETED))) {
63252 + match = match->next;
63253 + }
63254 +
63255 + if (match && (match->mode & GR_DELETED))
63256 + return match;
63257 +
63258 + match = subj->obj_hash[index];
63259 +
63260 + while (match && (match->inode != ino || match->device != dev ||
63261 + (match->mode & GR_DELETED))) {
63262 + match = match->next;
63263 + }
63264 +
63265 + if (match && !(match->mode & GR_DELETED))
63266 + return match;
63267 + else
63268 + return NULL;
63269 +}
63270 +
63271 +struct name_entry *
63272 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
63273 +{
63274 + unsigned int len = strlen(name);
63275 + unsigned int key = full_name_hash(name, len);
63276 + unsigned int index = key % state->name_set.n_size;
63277 + struct name_entry *match;
63278 +
63279 + match = state->name_set.n_hash[index];
63280 +
63281 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63282 + match = match->next;
63283 +
63284 + return match;
63285 +}
63286 +
63287 +static struct name_entry *
63288 +lookup_name_entry(const char *name)
63289 +{
63290 + return __lookup_name_entry(&running_polstate, name);
63291 +}
63292 +
63293 +static struct name_entry *
63294 +lookup_name_entry_create(const char *name)
63295 +{
63296 + unsigned int len = strlen(name);
63297 + unsigned int key = full_name_hash(name, len);
63298 + unsigned int index = key % running_polstate.name_set.n_size;
63299 + struct name_entry *match;
63300 +
63301 + match = running_polstate.name_set.n_hash[index];
63302 +
63303 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63304 + !match->deleted))
63305 + match = match->next;
63306 +
63307 + if (match && match->deleted)
63308 + return match;
63309 +
63310 + match = running_polstate.name_set.n_hash[index];
63311 +
63312 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63313 + match->deleted))
63314 + match = match->next;
63315 +
63316 + if (match && !match->deleted)
63317 + return match;
63318 + else
63319 + return NULL;
63320 +}
63321 +
63322 +static struct inodev_entry *
63323 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
63324 +{
63325 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
63326 + struct inodev_entry *match;
63327 +
63328 + match = running_polstate.inodev_set.i_hash[index];
63329 +
63330 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63331 + match = match->next;
63332 +
63333 + return match;
63334 +}
63335 +
63336 +void
63337 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
63338 +{
63339 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63340 + state->inodev_set.i_size);
63341 + struct inodev_entry **curr;
63342 +
63343 + entry->prev = NULL;
63344 +
63345 + curr = &state->inodev_set.i_hash[index];
63346 + if (*curr != NULL)
63347 + (*curr)->prev = entry;
63348 +
63349 + entry->next = *curr;
63350 + *curr = entry;
63351 +
63352 + return;
63353 +}
63354 +
63355 +static void
63356 +insert_inodev_entry(struct inodev_entry *entry)
63357 +{
63358 + __insert_inodev_entry(&running_polstate, entry);
63359 +}
63360 +
63361 +void
63362 +insert_acl_obj_label(struct acl_object_label *obj,
63363 + struct acl_subject_label *subj)
63364 +{
63365 + unsigned int index =
63366 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63367 + struct acl_object_label **curr;
63368 +
63369 + obj->prev = NULL;
63370 +
63371 + curr = &subj->obj_hash[index];
63372 + if (*curr != NULL)
63373 + (*curr)->prev = obj;
63374 +
63375 + obj->next = *curr;
63376 + *curr = obj;
63377 +
63378 + return;
63379 +}
63380 +
63381 +void
63382 +insert_acl_subj_label(struct acl_subject_label *obj,
63383 + struct acl_role_label *role)
63384 +{
63385 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63386 + struct acl_subject_label **curr;
63387 +
63388 + obj->prev = NULL;
63389 +
63390 + curr = &role->subj_hash[index];
63391 + if (*curr != NULL)
63392 + (*curr)->prev = obj;
63393 +
63394 + obj->next = *curr;
63395 + *curr = obj;
63396 +
63397 + return;
63398 +}
63399 +
63400 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63401 +
63402 +static int
63403 +glob_match(const char *p, const char *n)
63404 +{
63405 + char c;
63406 +
63407 + while ((c = *p++) != '\0') {
63408 + switch (c) {
63409 + case '?':
63410 + if (*n == '\0')
63411 + return 1;
63412 + else if (*n == '/')
63413 + return 1;
63414 + break;
63415 + case '\\':
63416 + if (*n != c)
63417 + return 1;
63418 + break;
63419 + case '*':
63420 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63421 + if (*n == '/')
63422 + return 1;
63423 + else if (c == '?') {
63424 + if (*n == '\0')
63425 + return 1;
63426 + else
63427 + ++n;
63428 + }
63429 + }
63430 + if (c == '\0') {
63431 + return 0;
63432 + } else {
63433 + const char *endp;
63434 +
63435 + if ((endp = strchr(n, '/')) == NULL)
63436 + endp = n + strlen(n);
63437 +
63438 + if (c == '[') {
63439 + for (--p; n < endp; ++n)
63440 + if (!glob_match(p, n))
63441 + return 0;
63442 + } else if (c == '/') {
63443 + while (*n != '\0' && *n != '/')
63444 + ++n;
63445 + if (*n == '/' && !glob_match(p, n + 1))
63446 + return 0;
63447 + } else {
63448 + for (--p; n < endp; ++n)
63449 + if (*n == c && !glob_match(p, n))
63450 + return 0;
63451 + }
63452 +
63453 + return 1;
63454 + }
63455 + case '[':
63456 + {
63457 + int not;
63458 + char cold;
63459 +
63460 + if (*n == '\0' || *n == '/')
63461 + return 1;
63462 +
63463 + not = (*p == '!' || *p == '^');
63464 + if (not)
63465 + ++p;
63466 +
63467 + c = *p++;
63468 + for (;;) {
63469 + unsigned char fn = (unsigned char)*n;
63470 +
63471 + if (c == '\0')
63472 + return 1;
63473 + else {
63474 + if (c == fn)
63475 + goto matched;
63476 + cold = c;
63477 + c = *p++;
63478 +
63479 + if (c == '-' && *p != ']') {
63480 + unsigned char cend = *p++;
63481 +
63482 + if (cend == '\0')
63483 + return 1;
63484 +
63485 + if (cold <= fn && fn <= cend)
63486 + goto matched;
63487 +
63488 + c = *p++;
63489 + }
63490 + }
63491 +
63492 + if (c == ']')
63493 + break;
63494 + }
63495 + if (!not)
63496 + return 1;
63497 + break;
63498 + matched:
63499 + while (c != ']') {
63500 + if (c == '\0')
63501 + return 1;
63502 +
63503 + c = *p++;
63504 + }
63505 + if (not)
63506 + return 1;
63507 + }
63508 + break;
63509 + default:
63510 + if (c != *n)
63511 + return 1;
63512 + }
63513 +
63514 + ++n;
63515 + }
63516 +
63517 + if (*n == '\0')
63518 + return 0;
63519 +
63520 + if (*n == '/')
63521 + return 0;
63522 +
63523 + return 1;
63524 +}
63525 +
63526 +static struct acl_object_label *
63527 +chk_glob_label(struct acl_object_label *globbed,
63528 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63529 +{
63530 + struct acl_object_label *tmp;
63531 +
63532 + if (*path == NULL)
63533 + *path = gr_to_filename_nolock(dentry, mnt);
63534 +
63535 + tmp = globbed;
63536 +
63537 + while (tmp) {
63538 + if (!glob_match(tmp->filename, *path))
63539 + return tmp;
63540 + tmp = tmp->next;
63541 + }
63542 +
63543 + return NULL;
63544 +}
63545 +
63546 +static struct acl_object_label *
63547 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63548 + const ino_t curr_ino, const dev_t curr_dev,
63549 + const struct acl_subject_label *subj, char **path, const int checkglob)
63550 +{
63551 + struct acl_subject_label *tmpsubj;
63552 + struct acl_object_label *retval;
63553 + struct acl_object_label *retval2;
63554 +
63555 + tmpsubj = (struct acl_subject_label *) subj;
63556 + read_lock(&gr_inode_lock);
63557 + do {
63558 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63559 + if (retval) {
63560 + if (checkglob && retval->globbed) {
63561 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63562 + if (retval2)
63563 + retval = retval2;
63564 + }
63565 + break;
63566 + }
63567 + } while ((tmpsubj = tmpsubj->parent_subject));
63568 + read_unlock(&gr_inode_lock);
63569 +
63570 + return retval;
63571 +}
63572 +
63573 +static __inline__ struct acl_object_label *
63574 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63575 + struct dentry *curr_dentry,
63576 + const struct acl_subject_label *subj, char **path, const int checkglob)
63577 +{
63578 + int newglob = checkglob;
63579 + ino_t inode;
63580 + dev_t device;
63581 +
63582 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63583 + as we don't want a / * rule to match instead of the / object
63584 + don't do this for create lookups that call this function though, since they're looking up
63585 + on the parent and thus need globbing checks on all paths
63586 + */
63587 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63588 + newglob = GR_NO_GLOB;
63589 +
63590 + spin_lock(&curr_dentry->d_lock);
63591 + inode = curr_dentry->d_inode->i_ino;
63592 + device = __get_dev(curr_dentry);
63593 + spin_unlock(&curr_dentry->d_lock);
63594 +
63595 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63596 +}
63597 +
63598 +#ifdef CONFIG_HUGETLBFS
63599 +static inline bool
63600 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63601 +{
63602 + int i;
63603 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63604 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63605 + return true;
63606 + }
63607 +
63608 + return false;
63609 +}
63610 +#endif
63611 +
63612 +static struct acl_object_label *
63613 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63614 + const struct acl_subject_label *subj, char *path, const int checkglob)
63615 +{
63616 + struct dentry *dentry = (struct dentry *) l_dentry;
63617 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63618 + struct mount *real_mnt = real_mount(mnt);
63619 + struct acl_object_label *retval;
63620 + struct dentry *parent;
63621 +
63622 + br_read_lock(&vfsmount_lock);
63623 + write_seqlock(&rename_lock);
63624 +
63625 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63626 +#ifdef CONFIG_NET
63627 + mnt == sock_mnt ||
63628 +#endif
63629 +#ifdef CONFIG_HUGETLBFS
63630 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
63631 +#endif
63632 + /* ignore Eric Biederman */
63633 + IS_PRIVATE(l_dentry->d_inode))) {
63634 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
63635 + goto out;
63636 + }
63637 +
63638 + for (;;) {
63639 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63640 + break;
63641 +
63642 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63643 + if (!mnt_has_parent(real_mnt))
63644 + break;
63645 +
63646 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63647 + if (retval != NULL)
63648 + goto out;
63649 +
63650 + dentry = real_mnt->mnt_mountpoint;
63651 + real_mnt = real_mnt->mnt_parent;
63652 + mnt = &real_mnt->mnt;
63653 + continue;
63654 + }
63655 +
63656 + parent = dentry->d_parent;
63657 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63658 + if (retval != NULL)
63659 + goto out;
63660 +
63661 + dentry = parent;
63662 + }
63663 +
63664 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63665 +
63666 + /* gr_real_root is pinned so we don't have to hold a reference */
63667 + if (retval == NULL)
63668 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
63669 +out:
63670 + write_sequnlock(&rename_lock);
63671 + br_read_unlock(&vfsmount_lock);
63672 +
63673 + BUG_ON(retval == NULL);
63674 +
63675 + return retval;
63676 +}
63677 +
63678 +static __inline__ struct acl_object_label *
63679 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63680 + const struct acl_subject_label *subj)
63681 +{
63682 + char *path = NULL;
63683 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
63684 +}
63685 +
63686 +static __inline__ struct acl_object_label *
63687 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63688 + const struct acl_subject_label *subj)
63689 +{
63690 + char *path = NULL;
63691 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
63692 +}
63693 +
63694 +static __inline__ struct acl_object_label *
63695 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63696 + const struct acl_subject_label *subj, char *path)
63697 +{
63698 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
63699 +}
63700 +
63701 +struct acl_subject_label *
63702 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63703 + const struct acl_role_label *role)
63704 +{
63705 + struct dentry *dentry = (struct dentry *) l_dentry;
63706 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63707 + struct mount *real_mnt = real_mount(mnt);
63708 + struct acl_subject_label *retval;
63709 + struct dentry *parent;
63710 +
63711 + br_read_lock(&vfsmount_lock);
63712 + write_seqlock(&rename_lock);
63713 +
63714 + for (;;) {
63715 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63716 + break;
63717 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63718 + if (!mnt_has_parent(real_mnt))
63719 + break;
63720 +
63721 + spin_lock(&dentry->d_lock);
63722 + read_lock(&gr_inode_lock);
63723 + retval =
63724 + lookup_acl_subj_label(dentry->d_inode->i_ino,
63725 + __get_dev(dentry), role);
63726 + read_unlock(&gr_inode_lock);
63727 + spin_unlock(&dentry->d_lock);
63728 + if (retval != NULL)
63729 + goto out;
63730 +
63731 + dentry = real_mnt->mnt_mountpoint;
63732 + real_mnt = real_mnt->mnt_parent;
63733 + mnt = &real_mnt->mnt;
63734 + continue;
63735 + }
63736 +
63737 + spin_lock(&dentry->d_lock);
63738 + read_lock(&gr_inode_lock);
63739 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63740 + __get_dev(dentry), role);
63741 + read_unlock(&gr_inode_lock);
63742 + parent = dentry->d_parent;
63743 + spin_unlock(&dentry->d_lock);
63744 +
63745 + if (retval != NULL)
63746 + goto out;
63747 +
63748 + dentry = parent;
63749 + }
63750 +
63751 + spin_lock(&dentry->d_lock);
63752 + read_lock(&gr_inode_lock);
63753 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63754 + __get_dev(dentry), role);
63755 + read_unlock(&gr_inode_lock);
63756 + spin_unlock(&dentry->d_lock);
63757 +
63758 + if (unlikely(retval == NULL)) {
63759 + /* gr_real_root is pinned, we don't need to hold a reference */
63760 + read_lock(&gr_inode_lock);
63761 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
63762 + __get_dev(gr_real_root.dentry), role);
63763 + read_unlock(&gr_inode_lock);
63764 + }
63765 +out:
63766 + write_sequnlock(&rename_lock);
63767 + br_read_unlock(&vfsmount_lock);
63768 +
63769 + BUG_ON(retval == NULL);
63770 +
63771 + return retval;
63772 +}
63773 +
63774 +void
63775 +assign_special_role(const char *rolename)
63776 +{
63777 + struct acl_object_label *obj;
63778 + struct acl_role_label *r;
63779 + struct acl_role_label *assigned = NULL;
63780 + struct task_struct *tsk;
63781 + struct file *filp;
63782 +
63783 + FOR_EACH_ROLE_START(r)
63784 + if (!strcmp(rolename, r->rolename) &&
63785 + (r->roletype & GR_ROLE_SPECIAL)) {
63786 + assigned = r;
63787 + break;
63788 + }
63789 + FOR_EACH_ROLE_END(r)
63790 +
63791 + if (!assigned)
63792 + return;
63793 +
63794 + read_lock(&tasklist_lock);
63795 + read_lock(&grsec_exec_file_lock);
63796 +
63797 + tsk = current->real_parent;
63798 + if (tsk == NULL)
63799 + goto out_unlock;
63800 +
63801 + filp = tsk->exec_file;
63802 + if (filp == NULL)
63803 + goto out_unlock;
63804 +
63805 + tsk->is_writable = 0;
63806 + tsk->inherited = 0;
63807 +
63808 + tsk->acl_sp_role = 1;
63809 + tsk->acl_role_id = ++acl_sp_role_value;
63810 + tsk->role = assigned;
63811 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63812 +
63813 + /* ignore additional mmap checks for processes that are writable
63814 + by the default ACL */
63815 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
63816 + if (unlikely(obj->mode & GR_WRITE))
63817 + tsk->is_writable = 1;
63818 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63819 + if (unlikely(obj->mode & GR_WRITE))
63820 + tsk->is_writable = 1;
63821 +
63822 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63823 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
63824 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
63825 +#endif
63826 +
63827 +out_unlock:
63828 + read_unlock(&grsec_exec_file_lock);
63829 + read_unlock(&tasklist_lock);
63830 + return;
63831 +}
63832 +
63833 +
63834 +static void
63835 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
63836 +{
63837 + struct task_struct *task = current;
63838 + const struct cred *cred = current_cred();
63839 +
63840 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
63841 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63842 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63843 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
63844 +
63845 + return;
63846 +}
63847 +
63848 +static void
63849 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
63850 +{
63851 + struct task_struct *task = current;
63852 + const struct cred *cred = current_cred();
63853 +
63854 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63855 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63856 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63857 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
63858 +
63859 + return;
63860 +}
63861 +
63862 +static void
63863 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
63864 +{
63865 + struct task_struct *task = current;
63866 + const struct cred *cred = current_cred();
63867 +
63868 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63869 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63870 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63871 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
63872 +
63873 + return;
63874 +}
63875 +
63876 +static void
63877 +gr_set_proc_res(struct task_struct *task)
63878 +{
63879 + struct acl_subject_label *proc;
63880 + unsigned short i;
63881 +
63882 + proc = task->acl;
63883 +
63884 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
63885 + return;
63886 +
63887 + for (i = 0; i < RLIM_NLIMITS; i++) {
63888 + if (!(proc->resmask & (1U << i)))
63889 + continue;
63890 +
63891 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
63892 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
63893 +
63894 + if (i == RLIMIT_CPU)
63895 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
63896 + }
63897 +
63898 + return;
63899 +}
63900 +
63901 +/* both of the below must be called with
63902 + rcu_read_lock();
63903 + read_lock(&tasklist_lock);
63904 + read_lock(&grsec_exec_file_lock);
63905 +*/
63906 +
63907 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
63908 +{
63909 + char *tmpname;
63910 + struct acl_subject_label *tmpsubj;
63911 + struct file *filp;
63912 + struct name_entry *nmatch;
63913 +
63914 + filp = task->exec_file;
63915 + if (filp == NULL)
63916 + return NULL;
63917 +
63918 + /* the following is to apply the correct subject
63919 + on binaries running when the RBAC system
63920 + is enabled, when the binaries have been
63921 + replaced or deleted since their execution
63922 + -----
63923 + when the RBAC system starts, the inode/dev
63924 + from exec_file will be one the RBAC system
63925 + is unaware of. It only knows the inode/dev
63926 + of the present file on disk, or the absence
63927 + of it.
63928 + */
63929 +
63930 + if (filename)
63931 + nmatch = __lookup_name_entry(state, filename);
63932 + else {
63933 + preempt_disable();
63934 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
63935 +
63936 + nmatch = __lookup_name_entry(state, tmpname);
63937 + preempt_enable();
63938 + }
63939 + tmpsubj = NULL;
63940 + if (nmatch) {
63941 + if (nmatch->deleted)
63942 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
63943 + else
63944 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
63945 + }
63946 + /* this also works for the reload case -- if we don't match a potentially inherited subject
63947 + then we fall back to a normal lookup based on the binary's ino/dev
63948 + */
63949 + if (tmpsubj == NULL)
63950 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
63951 +
63952 + return tmpsubj;
63953 +}
63954 +
63955 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
63956 +{
63957 + return __gr_get_subject_for_task(&running_polstate, task, filename);
63958 +}
63959 +
63960 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
63961 +{
63962 + struct acl_object_label *obj;
63963 + struct file *filp;
63964 +
63965 + filp = task->exec_file;
63966 +
63967 + task->acl = subj;
63968 + task->is_writable = 0;
63969 + /* ignore additional mmap checks for processes that are writable
63970 + by the default ACL */
63971 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
63972 + if (unlikely(obj->mode & GR_WRITE))
63973 + task->is_writable = 1;
63974 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63975 + if (unlikely(obj->mode & GR_WRITE))
63976 + task->is_writable = 1;
63977 +
63978 + gr_set_proc_res(task);
63979 +
63980 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63981 + 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);
63982 +#endif
63983 +}
63984 +
63985 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
63986 +{
63987 + __gr_apply_subject_to_task(&running_polstate, task, subj);
63988 +}
63989 +
63990 +__u32
63991 +gr_search_file(const struct dentry * dentry, const __u32 mode,
63992 + const struct vfsmount * mnt)
63993 +{
63994 + __u32 retval = mode;
63995 + struct acl_subject_label *curracl;
63996 + struct acl_object_label *currobj;
63997 +
63998 + if (unlikely(!(gr_status & GR_READY)))
63999 + return (mode & ~GR_AUDITS);
64000 +
64001 + curracl = current->acl;
64002 +
64003 + currobj = chk_obj_label(dentry, mnt, curracl);
64004 + retval = currobj->mode & mode;
64005 +
64006 + /* if we're opening a specified transfer file for writing
64007 + (e.g. /dev/initctl), then transfer our role to init
64008 + */
64009 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64010 + current->role->roletype & GR_ROLE_PERSIST)) {
64011 + struct task_struct *task = init_pid_ns.child_reaper;
64012 +
64013 + if (task->role != current->role) {
64014 + struct acl_subject_label *subj;
64015 +
64016 + task->acl_sp_role = 0;
64017 + task->acl_role_id = current->acl_role_id;
64018 + task->role = current->role;
64019 + rcu_read_lock();
64020 + read_lock(&grsec_exec_file_lock);
64021 + subj = gr_get_subject_for_task(task, NULL);
64022 + gr_apply_subject_to_task(task, subj);
64023 + read_unlock(&grsec_exec_file_lock);
64024 + rcu_read_unlock();
64025 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64026 + }
64027 + }
64028 +
64029 + if (unlikely
64030 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64031 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64032 + __u32 new_mode = mode;
64033 +
64034 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64035 +
64036 + retval = new_mode;
64037 +
64038 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64039 + new_mode |= GR_INHERIT;
64040 +
64041 + if (!(mode & GR_NOLEARN))
64042 + gr_log_learn(dentry, mnt, new_mode);
64043 + }
64044 +
64045 + return retval;
64046 +}
64047 +
64048 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64049 + const struct dentry *parent,
64050 + const struct vfsmount *mnt)
64051 +{
64052 + struct name_entry *match;
64053 + struct acl_object_label *matchpo;
64054 + struct acl_subject_label *curracl;
64055 + char *path;
64056 +
64057 + if (unlikely(!(gr_status & GR_READY)))
64058 + return NULL;
64059 +
64060 + preempt_disable();
64061 + path = gr_to_filename_rbac(new_dentry, mnt);
64062 + match = lookup_name_entry_create(path);
64063 +
64064 + curracl = current->acl;
64065 +
64066 + if (match) {
64067 + read_lock(&gr_inode_lock);
64068 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64069 + read_unlock(&gr_inode_lock);
64070 +
64071 + if (matchpo) {
64072 + preempt_enable();
64073 + return matchpo;
64074 + }
64075 + }
64076 +
64077 + // lookup parent
64078 +
64079 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64080 +
64081 + preempt_enable();
64082 + return matchpo;
64083 +}
64084 +
64085 +__u32
64086 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64087 + const struct vfsmount * mnt, const __u32 mode)
64088 +{
64089 + struct acl_object_label *matchpo;
64090 + __u32 retval;
64091 +
64092 + if (unlikely(!(gr_status & GR_READY)))
64093 + return (mode & ~GR_AUDITS);
64094 +
64095 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64096 +
64097 + retval = matchpo->mode & mode;
64098 +
64099 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64100 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64101 + __u32 new_mode = mode;
64102 +
64103 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64104 +
64105 + gr_log_learn(new_dentry, mnt, new_mode);
64106 + return new_mode;
64107 + }
64108 +
64109 + return retval;
64110 +}
64111 +
64112 +__u32
64113 +gr_check_link(const struct dentry * new_dentry,
64114 + const struct dentry * parent_dentry,
64115 + const struct vfsmount * parent_mnt,
64116 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64117 +{
64118 + struct acl_object_label *obj;
64119 + __u32 oldmode, newmode;
64120 + __u32 needmode;
64121 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64122 + GR_DELETE | GR_INHERIT;
64123 +
64124 + if (unlikely(!(gr_status & GR_READY)))
64125 + return (GR_CREATE | GR_LINK);
64126 +
64127 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64128 + oldmode = obj->mode;
64129 +
64130 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64131 + newmode = obj->mode;
64132 +
64133 + needmode = newmode & checkmodes;
64134 +
64135 + // old name for hardlink must have at least the permissions of the new name
64136 + if ((oldmode & needmode) != needmode)
64137 + goto bad;
64138 +
64139 + // if old name had restrictions/auditing, make sure the new name does as well
64140 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64141 +
64142 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64143 + if (is_privileged_binary(old_dentry))
64144 + needmode |= GR_SETID;
64145 +
64146 + if ((newmode & needmode) != needmode)
64147 + goto bad;
64148 +
64149 + // enforce minimum permissions
64150 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64151 + return newmode;
64152 +bad:
64153 + needmode = oldmode;
64154 + if (is_privileged_binary(old_dentry))
64155 + needmode |= GR_SETID;
64156 +
64157 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64158 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64159 + return (GR_CREATE | GR_LINK);
64160 + } else if (newmode & GR_SUPPRESS)
64161 + return GR_SUPPRESS;
64162 + else
64163 + return 0;
64164 +}
64165 +
64166 +int
64167 +gr_check_hidden_task(const struct task_struct *task)
64168 +{
64169 + if (unlikely(!(gr_status & GR_READY)))
64170 + return 0;
64171 +
64172 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64173 + return 1;
64174 +
64175 + return 0;
64176 +}
64177 +
64178 +int
64179 +gr_check_protected_task(const struct task_struct *task)
64180 +{
64181 + if (unlikely(!(gr_status & GR_READY) || !task))
64182 + return 0;
64183 +
64184 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64185 + task->acl != current->acl)
64186 + return 1;
64187 +
64188 + return 0;
64189 +}
64190 +
64191 +int
64192 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64193 +{
64194 + struct task_struct *p;
64195 + int ret = 0;
64196 +
64197 + if (unlikely(!(gr_status & GR_READY) || !pid))
64198 + return ret;
64199 +
64200 + read_lock(&tasklist_lock);
64201 + do_each_pid_task(pid, type, p) {
64202 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64203 + p->acl != current->acl) {
64204 + ret = 1;
64205 + goto out;
64206 + }
64207 + } while_each_pid_task(pid, type, p);
64208 +out:
64209 + read_unlock(&tasklist_lock);
64210 +
64211 + return ret;
64212 +}
64213 +
64214 +void
64215 +gr_copy_label(struct task_struct *tsk)
64216 +{
64217 + struct task_struct *p = current;
64218 +
64219 + tsk->inherited = p->inherited;
64220 + tsk->acl_sp_role = 0;
64221 + tsk->acl_role_id = p->acl_role_id;
64222 + tsk->acl = p->acl;
64223 + tsk->role = p->role;
64224 + tsk->signal->used_accept = 0;
64225 + tsk->signal->curr_ip = p->signal->curr_ip;
64226 + tsk->signal->saved_ip = p->signal->saved_ip;
64227 + if (p->exec_file)
64228 + get_file(p->exec_file);
64229 + tsk->exec_file = p->exec_file;
64230 + tsk->is_writable = p->is_writable;
64231 + if (unlikely(p->signal->used_accept)) {
64232 + p->signal->curr_ip = 0;
64233 + p->signal->saved_ip = 0;
64234 + }
64235 +
64236 + return;
64237 +}
64238 +
64239 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64240 +
64241 +int
64242 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64243 +{
64244 + unsigned int i;
64245 + __u16 num;
64246 + uid_t *uidlist;
64247 + uid_t curuid;
64248 + int realok = 0;
64249 + int effectiveok = 0;
64250 + int fsok = 0;
64251 + uid_t globalreal, globaleffective, globalfs;
64252 +
64253 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64254 + struct user_struct *user;
64255 +
64256 + if (!uid_valid(real))
64257 + goto skipit;
64258 +
64259 + /* find user based on global namespace */
64260 +
64261 + globalreal = GR_GLOBAL_UID(real);
64262 +
64263 + user = find_user(make_kuid(&init_user_ns, globalreal));
64264 + if (user == NULL)
64265 + goto skipit;
64266 +
64267 + if (gr_process_kernel_setuid_ban(user)) {
64268 + /* for find_user */
64269 + free_uid(user);
64270 + return 1;
64271 + }
64272 +
64273 + /* for find_user */
64274 + free_uid(user);
64275 +
64276 +skipit:
64277 +#endif
64278 +
64279 + if (unlikely(!(gr_status & GR_READY)))
64280 + return 0;
64281 +
64282 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64283 + gr_log_learn_uid_change(real, effective, fs);
64284 +
64285 + num = current->acl->user_trans_num;
64286 + uidlist = current->acl->user_transitions;
64287 +
64288 + if (uidlist == NULL)
64289 + return 0;
64290 +
64291 + if (!uid_valid(real)) {
64292 + realok = 1;
64293 + globalreal = (uid_t)-1;
64294 + } else {
64295 + globalreal = GR_GLOBAL_UID(real);
64296 + }
64297 + if (!uid_valid(effective)) {
64298 + effectiveok = 1;
64299 + globaleffective = (uid_t)-1;
64300 + } else {
64301 + globaleffective = GR_GLOBAL_UID(effective);
64302 + }
64303 + if (!uid_valid(fs)) {
64304 + fsok = 1;
64305 + globalfs = (uid_t)-1;
64306 + } else {
64307 + globalfs = GR_GLOBAL_UID(fs);
64308 + }
64309 +
64310 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64311 + for (i = 0; i < num; i++) {
64312 + curuid = uidlist[i];
64313 + if (globalreal == curuid)
64314 + realok = 1;
64315 + if (globaleffective == curuid)
64316 + effectiveok = 1;
64317 + if (globalfs == curuid)
64318 + fsok = 1;
64319 + }
64320 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64321 + for (i = 0; i < num; i++) {
64322 + curuid = uidlist[i];
64323 + if (globalreal == curuid)
64324 + break;
64325 + if (globaleffective == curuid)
64326 + break;
64327 + if (globalfs == curuid)
64328 + break;
64329 + }
64330 + /* not in deny list */
64331 + if (i == num) {
64332 + realok = 1;
64333 + effectiveok = 1;
64334 + fsok = 1;
64335 + }
64336 + }
64337 +
64338 + if (realok && effectiveok && fsok)
64339 + return 0;
64340 + else {
64341 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64342 + return 1;
64343 + }
64344 +}
64345 +
64346 +int
64347 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64348 +{
64349 + unsigned int i;
64350 + __u16 num;
64351 + gid_t *gidlist;
64352 + gid_t curgid;
64353 + int realok = 0;
64354 + int effectiveok = 0;
64355 + int fsok = 0;
64356 + gid_t globalreal, globaleffective, globalfs;
64357 +
64358 + if (unlikely(!(gr_status & GR_READY)))
64359 + return 0;
64360 +
64361 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64362 + gr_log_learn_gid_change(real, effective, fs);
64363 +
64364 + num = current->acl->group_trans_num;
64365 + gidlist = current->acl->group_transitions;
64366 +
64367 + if (gidlist == NULL)
64368 + return 0;
64369 +
64370 + if (!gid_valid(real)) {
64371 + realok = 1;
64372 + globalreal = (gid_t)-1;
64373 + } else {
64374 + globalreal = GR_GLOBAL_GID(real);
64375 + }
64376 + if (!gid_valid(effective)) {
64377 + effectiveok = 1;
64378 + globaleffective = (gid_t)-1;
64379 + } else {
64380 + globaleffective = GR_GLOBAL_GID(effective);
64381 + }
64382 + if (!gid_valid(fs)) {
64383 + fsok = 1;
64384 + globalfs = (gid_t)-1;
64385 + } else {
64386 + globalfs = GR_GLOBAL_GID(fs);
64387 + }
64388 +
64389 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64390 + for (i = 0; i < num; i++) {
64391 + curgid = gidlist[i];
64392 + if (globalreal == curgid)
64393 + realok = 1;
64394 + if (globaleffective == curgid)
64395 + effectiveok = 1;
64396 + if (globalfs == curgid)
64397 + fsok = 1;
64398 + }
64399 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64400 + for (i = 0; i < num; i++) {
64401 + curgid = gidlist[i];
64402 + if (globalreal == curgid)
64403 + break;
64404 + if (globaleffective == curgid)
64405 + break;
64406 + if (globalfs == curgid)
64407 + break;
64408 + }
64409 + /* not in deny list */
64410 + if (i == num) {
64411 + realok = 1;
64412 + effectiveok = 1;
64413 + fsok = 1;
64414 + }
64415 + }
64416 +
64417 + if (realok && effectiveok && fsok)
64418 + return 0;
64419 + else {
64420 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64421 + return 1;
64422 + }
64423 +}
64424 +
64425 +extern int gr_acl_is_capable(const int cap);
64426 +
64427 +void
64428 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64429 +{
64430 + struct acl_role_label *role = task->role;
64431 + struct acl_subject_label *subj = NULL;
64432 + struct acl_object_label *obj;
64433 + struct file *filp;
64434 + uid_t uid;
64435 + gid_t gid;
64436 +
64437 + if (unlikely(!(gr_status & GR_READY)))
64438 + return;
64439 +
64440 + uid = GR_GLOBAL_UID(kuid);
64441 + gid = GR_GLOBAL_GID(kgid);
64442 +
64443 + filp = task->exec_file;
64444 +
64445 + /* kernel process, we'll give them the kernel role */
64446 + if (unlikely(!filp)) {
64447 + task->role = running_polstate.kernel_role;
64448 + task->acl = running_polstate.kernel_role->root_label;
64449 + return;
64450 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
64451 + /* save the current ip at time of role lookup so that the proper
64452 + IP will be learned for role_allowed_ip */
64453 + task->signal->saved_ip = task->signal->curr_ip;
64454 + role = lookup_acl_role_label(task, uid, gid);
64455 + }
64456 +
64457 + /* don't change the role if we're not a privileged process */
64458 + if (role && task->role != role &&
64459 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64460 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64461 + return;
64462 +
64463 + /* perform subject lookup in possibly new role
64464 + we can use this result below in the case where role == task->role
64465 + */
64466 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64467 +
64468 + /* if we changed uid/gid, but result in the same role
64469 + and are using inheritance, don't lose the inherited subject
64470 + if current subject is other than what normal lookup
64471 + would result in, we arrived via inheritance, don't
64472 + lose subject
64473 + */
64474 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64475 + (subj == task->acl)))
64476 + task->acl = subj;
64477 +
64478 + /* leave task->inherited unaffected */
64479 +
64480 + task->role = role;
64481 +
64482 + task->is_writable = 0;
64483 +
64484 + /* ignore additional mmap checks for processes that are writable
64485 + by the default ACL */
64486 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64487 + if (unlikely(obj->mode & GR_WRITE))
64488 + task->is_writable = 1;
64489 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64490 + if (unlikely(obj->mode & GR_WRITE))
64491 + task->is_writable = 1;
64492 +
64493 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64494 + 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);
64495 +#endif
64496 +
64497 + gr_set_proc_res(task);
64498 +
64499 + return;
64500 +}
64501 +
64502 +int
64503 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64504 + const int unsafe_flags)
64505 +{
64506 + struct task_struct *task = current;
64507 + struct acl_subject_label *newacl;
64508 + struct acl_object_label *obj;
64509 + __u32 retmode;
64510 +
64511 + if (unlikely(!(gr_status & GR_READY)))
64512 + return 0;
64513 +
64514 + newacl = chk_subj_label(dentry, mnt, task->role);
64515 +
64516 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64517 + did an exec
64518 + */
64519 + rcu_read_lock();
64520 + read_lock(&tasklist_lock);
64521 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64522 + (task->parent->acl->mode & GR_POVERRIDE))) {
64523 + read_unlock(&tasklist_lock);
64524 + rcu_read_unlock();
64525 + goto skip_check;
64526 + }
64527 + read_unlock(&tasklist_lock);
64528 + rcu_read_unlock();
64529 +
64530 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64531 + !(task->role->roletype & GR_ROLE_GOD) &&
64532 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64533 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64534 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64535 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64536 + else
64537 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64538 + return -EACCES;
64539 + }
64540 +
64541 +skip_check:
64542 +
64543 + obj = chk_obj_label(dentry, mnt, task->acl);
64544 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64545 +
64546 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64547 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64548 + if (obj->nested)
64549 + task->acl = obj->nested;
64550 + else
64551 + task->acl = newacl;
64552 + task->inherited = 0;
64553 + } else {
64554 + task->inherited = 1;
64555 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64556 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64557 + }
64558 +
64559 + task->is_writable = 0;
64560 +
64561 + /* ignore additional mmap checks for processes that are writable
64562 + by the default ACL */
64563 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
64564 + if (unlikely(obj->mode & GR_WRITE))
64565 + task->is_writable = 1;
64566 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64567 + if (unlikely(obj->mode & GR_WRITE))
64568 + task->is_writable = 1;
64569 +
64570 + gr_set_proc_res(task);
64571 +
64572 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64573 + 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);
64574 +#endif
64575 + return 0;
64576 +}
64577 +
64578 +/* always called with valid inodev ptr */
64579 +static void
64580 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64581 +{
64582 + struct acl_object_label *matchpo;
64583 + struct acl_subject_label *matchps;
64584 + struct acl_subject_label *subj;
64585 + struct acl_role_label *role;
64586 + unsigned int x;
64587 +
64588 + FOR_EACH_ROLE_START(role)
64589 + FOR_EACH_SUBJECT_START(role, subj, x)
64590 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64591 + matchpo->mode |= GR_DELETED;
64592 + FOR_EACH_SUBJECT_END(subj,x)
64593 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64594 + /* nested subjects aren't in the role's subj_hash table */
64595 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64596 + matchpo->mode |= GR_DELETED;
64597 + FOR_EACH_NESTED_SUBJECT_END(subj)
64598 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64599 + matchps->mode |= GR_DELETED;
64600 + FOR_EACH_ROLE_END(role)
64601 +
64602 + inodev->nentry->deleted = 1;
64603 +
64604 + return;
64605 +}
64606 +
64607 +void
64608 +gr_handle_delete(const ino_t ino, const dev_t dev)
64609 +{
64610 + struct inodev_entry *inodev;
64611 +
64612 + if (unlikely(!(gr_status & GR_READY)))
64613 + return;
64614 +
64615 + write_lock(&gr_inode_lock);
64616 + inodev = lookup_inodev_entry(ino, dev);
64617 + if (inodev != NULL)
64618 + do_handle_delete(inodev, ino, dev);
64619 + write_unlock(&gr_inode_lock);
64620 +
64621 + return;
64622 +}
64623 +
64624 +static void
64625 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64626 + const ino_t newinode, const dev_t newdevice,
64627 + struct acl_subject_label *subj)
64628 +{
64629 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64630 + struct acl_object_label *match;
64631 +
64632 + match = subj->obj_hash[index];
64633 +
64634 + while (match && (match->inode != oldinode ||
64635 + match->device != olddevice ||
64636 + !(match->mode & GR_DELETED)))
64637 + match = match->next;
64638 +
64639 + if (match && (match->inode == oldinode)
64640 + && (match->device == olddevice)
64641 + && (match->mode & GR_DELETED)) {
64642 + if (match->prev == NULL) {
64643 + subj->obj_hash[index] = match->next;
64644 + if (match->next != NULL)
64645 + match->next->prev = NULL;
64646 + } else {
64647 + match->prev->next = match->next;
64648 + if (match->next != NULL)
64649 + match->next->prev = match->prev;
64650 + }
64651 + match->prev = NULL;
64652 + match->next = NULL;
64653 + match->inode = newinode;
64654 + match->device = newdevice;
64655 + match->mode &= ~GR_DELETED;
64656 +
64657 + insert_acl_obj_label(match, subj);
64658 + }
64659 +
64660 + return;
64661 +}
64662 +
64663 +static void
64664 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64665 + const ino_t newinode, const dev_t newdevice,
64666 + struct acl_role_label *role)
64667 +{
64668 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64669 + struct acl_subject_label *match;
64670 +
64671 + match = role->subj_hash[index];
64672 +
64673 + while (match && (match->inode != oldinode ||
64674 + match->device != olddevice ||
64675 + !(match->mode & GR_DELETED)))
64676 + match = match->next;
64677 +
64678 + if (match && (match->inode == oldinode)
64679 + && (match->device == olddevice)
64680 + && (match->mode & GR_DELETED)) {
64681 + if (match->prev == NULL) {
64682 + role->subj_hash[index] = match->next;
64683 + if (match->next != NULL)
64684 + match->next->prev = NULL;
64685 + } else {
64686 + match->prev->next = match->next;
64687 + if (match->next != NULL)
64688 + match->next->prev = match->prev;
64689 + }
64690 + match->prev = NULL;
64691 + match->next = NULL;
64692 + match->inode = newinode;
64693 + match->device = newdevice;
64694 + match->mode &= ~GR_DELETED;
64695 +
64696 + insert_acl_subj_label(match, role);
64697 + }
64698 +
64699 + return;
64700 +}
64701 +
64702 +static void
64703 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64704 + const ino_t newinode, const dev_t newdevice)
64705 +{
64706 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
64707 + struct inodev_entry *match;
64708 +
64709 + match = running_polstate.inodev_set.i_hash[index];
64710 +
64711 + while (match && (match->nentry->inode != oldinode ||
64712 + match->nentry->device != olddevice || !match->nentry->deleted))
64713 + match = match->next;
64714 +
64715 + if (match && (match->nentry->inode == oldinode)
64716 + && (match->nentry->device == olddevice) &&
64717 + match->nentry->deleted) {
64718 + if (match->prev == NULL) {
64719 + running_polstate.inodev_set.i_hash[index] = match->next;
64720 + if (match->next != NULL)
64721 + match->next->prev = NULL;
64722 + } else {
64723 + match->prev->next = match->next;
64724 + if (match->next != NULL)
64725 + match->next->prev = match->prev;
64726 + }
64727 + match->prev = NULL;
64728 + match->next = NULL;
64729 + match->nentry->inode = newinode;
64730 + match->nentry->device = newdevice;
64731 + match->nentry->deleted = 0;
64732 +
64733 + insert_inodev_entry(match);
64734 + }
64735 +
64736 + return;
64737 +}
64738 +
64739 +static void
64740 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64741 +{
64742 + struct acl_subject_label *subj;
64743 + struct acl_role_label *role;
64744 + unsigned int x;
64745 +
64746 + FOR_EACH_ROLE_START(role)
64747 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64748 +
64749 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64750 + if ((subj->inode == ino) && (subj->device == dev)) {
64751 + subj->inode = ino;
64752 + subj->device = dev;
64753 + }
64754 + /* nested subjects aren't in the role's subj_hash table */
64755 + update_acl_obj_label(matchn->inode, matchn->device,
64756 + ino, dev, subj);
64757 + FOR_EACH_NESTED_SUBJECT_END(subj)
64758 + FOR_EACH_SUBJECT_START(role, subj, x)
64759 + update_acl_obj_label(matchn->inode, matchn->device,
64760 + ino, dev, subj);
64761 + FOR_EACH_SUBJECT_END(subj,x)
64762 + FOR_EACH_ROLE_END(role)
64763 +
64764 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64765 +
64766 + return;
64767 +}
64768 +
64769 +static void
64770 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64771 + const struct vfsmount *mnt)
64772 +{
64773 + ino_t ino = dentry->d_inode->i_ino;
64774 + dev_t dev = __get_dev(dentry);
64775 +
64776 + __do_handle_create(matchn, ino, dev);
64777 +
64778 + return;
64779 +}
64780 +
64781 +void
64782 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64783 +{
64784 + struct name_entry *matchn;
64785 +
64786 + if (unlikely(!(gr_status & GR_READY)))
64787 + return;
64788 +
64789 + preempt_disable();
64790 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64791 +
64792 + if (unlikely((unsigned long)matchn)) {
64793 + write_lock(&gr_inode_lock);
64794 + do_handle_create(matchn, dentry, mnt);
64795 + write_unlock(&gr_inode_lock);
64796 + }
64797 + preempt_enable();
64798 +
64799 + return;
64800 +}
64801 +
64802 +void
64803 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64804 +{
64805 + struct name_entry *matchn;
64806 +
64807 + if (unlikely(!(gr_status & GR_READY)))
64808 + return;
64809 +
64810 + preempt_disable();
64811 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
64812 +
64813 + if (unlikely((unsigned long)matchn)) {
64814 + write_lock(&gr_inode_lock);
64815 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
64816 + write_unlock(&gr_inode_lock);
64817 + }
64818 + preempt_enable();
64819 +
64820 + return;
64821 +}
64822 +
64823 +void
64824 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64825 + struct dentry *old_dentry,
64826 + struct dentry *new_dentry,
64827 + struct vfsmount *mnt, const __u8 replace)
64828 +{
64829 + struct name_entry *matchn;
64830 + struct inodev_entry *inodev;
64831 + struct inode *inode = new_dentry->d_inode;
64832 + ino_t old_ino = old_dentry->d_inode->i_ino;
64833 + dev_t old_dev = __get_dev(old_dentry);
64834 +
64835 + /* vfs_rename swaps the name and parent link for old_dentry and
64836 + new_dentry
64837 + at this point, old_dentry has the new name, parent link, and inode
64838 + for the renamed file
64839 + if a file is being replaced by a rename, new_dentry has the inode
64840 + and name for the replaced file
64841 + */
64842 +
64843 + if (unlikely(!(gr_status & GR_READY)))
64844 + return;
64845 +
64846 + preempt_disable();
64847 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
64848 +
64849 + /* we wouldn't have to check d_inode if it weren't for
64850 + NFS silly-renaming
64851 + */
64852 +
64853 + write_lock(&gr_inode_lock);
64854 + if (unlikely(replace && inode)) {
64855 + ino_t new_ino = inode->i_ino;
64856 + dev_t new_dev = __get_dev(new_dentry);
64857 +
64858 + inodev = lookup_inodev_entry(new_ino, new_dev);
64859 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
64860 + do_handle_delete(inodev, new_ino, new_dev);
64861 + }
64862 +
64863 + inodev = lookup_inodev_entry(old_ino, old_dev);
64864 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
64865 + do_handle_delete(inodev, old_ino, old_dev);
64866 +
64867 + if (unlikely((unsigned long)matchn))
64868 + do_handle_create(matchn, old_dentry, mnt);
64869 +
64870 + write_unlock(&gr_inode_lock);
64871 + preempt_enable();
64872 +
64873 + return;
64874 +}
64875 +
64876 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
64877 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
64878 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
64879 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
64880 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
64881 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
64882 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
64883 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
64884 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
64885 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
64886 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
64887 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
64888 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
64889 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
64890 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
64891 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
64892 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
64893 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
64894 +};
64895 +
64896 +void
64897 +gr_learn_resource(const struct task_struct *task,
64898 + const int res, const unsigned long wanted, const int gt)
64899 +{
64900 + struct acl_subject_label *acl;
64901 + const struct cred *cred;
64902 +
64903 + if (unlikely((gr_status & GR_READY) &&
64904 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
64905 + goto skip_reslog;
64906 +
64907 + gr_log_resource(task, res, wanted, gt);
64908 +skip_reslog:
64909 +
64910 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
64911 + return;
64912 +
64913 + acl = task->acl;
64914 +
64915 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
64916 + !(acl->resmask & (1U << (unsigned short) res))))
64917 + return;
64918 +
64919 + if (wanted >= acl->res[res].rlim_cur) {
64920 + unsigned long res_add;
64921 +
64922 + res_add = wanted + res_learn_bumps[res];
64923 +
64924 + acl->res[res].rlim_cur = res_add;
64925 +
64926 + if (wanted > acl->res[res].rlim_max)
64927 + acl->res[res].rlim_max = res_add;
64928 +
64929 + /* only log the subject filename, since resource logging is supported for
64930 + single-subject learning only */
64931 + rcu_read_lock();
64932 + cred = __task_cred(task);
64933 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64934 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
64935 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
64936 + "", (unsigned long) res, &task->signal->saved_ip);
64937 + rcu_read_unlock();
64938 + }
64939 +
64940 + return;
64941 +}
64942 +EXPORT_SYMBOL(gr_learn_resource);
64943 +#endif
64944 +
64945 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
64946 +void
64947 +pax_set_initial_flags(struct linux_binprm *bprm)
64948 +{
64949 + struct task_struct *task = current;
64950 + struct acl_subject_label *proc;
64951 + unsigned long flags;
64952 +
64953 + if (unlikely(!(gr_status & GR_READY)))
64954 + return;
64955 +
64956 + flags = pax_get_flags(task);
64957 +
64958 + proc = task->acl;
64959 +
64960 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
64961 + flags &= ~MF_PAX_PAGEEXEC;
64962 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
64963 + flags &= ~MF_PAX_SEGMEXEC;
64964 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
64965 + flags &= ~MF_PAX_RANDMMAP;
64966 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
64967 + flags &= ~MF_PAX_EMUTRAMP;
64968 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
64969 + flags &= ~MF_PAX_MPROTECT;
64970 +
64971 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
64972 + flags |= MF_PAX_PAGEEXEC;
64973 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
64974 + flags |= MF_PAX_SEGMEXEC;
64975 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
64976 + flags |= MF_PAX_RANDMMAP;
64977 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
64978 + flags |= MF_PAX_EMUTRAMP;
64979 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
64980 + flags |= MF_PAX_MPROTECT;
64981 +
64982 + pax_set_flags(task, flags);
64983 +
64984 + return;
64985 +}
64986 +#endif
64987 +
64988 +int
64989 +gr_handle_proc_ptrace(struct task_struct *task)
64990 +{
64991 + struct file *filp;
64992 + struct task_struct *tmp = task;
64993 + struct task_struct *curtemp = current;
64994 + __u32 retmode;
64995 +
64996 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64997 + if (unlikely(!(gr_status & GR_READY)))
64998 + return 0;
64999 +#endif
65000 +
65001 + read_lock(&tasklist_lock);
65002 + read_lock(&grsec_exec_file_lock);
65003 + filp = task->exec_file;
65004 +
65005 + while (task_pid_nr(tmp) > 0) {
65006 + if (tmp == curtemp)
65007 + break;
65008 + tmp = tmp->real_parent;
65009 + }
65010 +
65011 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65012 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65013 + read_unlock(&grsec_exec_file_lock);
65014 + read_unlock(&tasklist_lock);
65015 + return 1;
65016 + }
65017 +
65018 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65019 + if (!(gr_status & GR_READY)) {
65020 + read_unlock(&grsec_exec_file_lock);
65021 + read_unlock(&tasklist_lock);
65022 + return 0;
65023 + }
65024 +#endif
65025 +
65026 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65027 + read_unlock(&grsec_exec_file_lock);
65028 + read_unlock(&tasklist_lock);
65029 +
65030 + if (retmode & GR_NOPTRACE)
65031 + return 1;
65032 +
65033 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65034 + && (current->acl != task->acl || (current->acl != current->role->root_label
65035 + && task_pid_nr(current) != task_pid_nr(task))))
65036 + return 1;
65037 +
65038 + return 0;
65039 +}
65040 +
65041 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65042 +{
65043 + if (unlikely(!(gr_status & GR_READY)))
65044 + return;
65045 +
65046 + if (!(current->role->roletype & GR_ROLE_GOD))
65047 + return;
65048 +
65049 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65050 + p->role->rolename, gr_task_roletype_to_char(p),
65051 + p->acl->filename);
65052 +}
65053 +
65054 +int
65055 +gr_handle_ptrace(struct task_struct *task, const long request)
65056 +{
65057 + struct task_struct *tmp = task;
65058 + struct task_struct *curtemp = current;
65059 + __u32 retmode;
65060 +
65061 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65062 + if (unlikely(!(gr_status & GR_READY)))
65063 + return 0;
65064 +#endif
65065 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65066 + read_lock(&tasklist_lock);
65067 + while (task_pid_nr(tmp) > 0) {
65068 + if (tmp == curtemp)
65069 + break;
65070 + tmp = tmp->real_parent;
65071 + }
65072 +
65073 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65074 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65075 + read_unlock(&tasklist_lock);
65076 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65077 + return 1;
65078 + }
65079 + read_unlock(&tasklist_lock);
65080 + }
65081 +
65082 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65083 + if (!(gr_status & GR_READY))
65084 + return 0;
65085 +#endif
65086 +
65087 + read_lock(&grsec_exec_file_lock);
65088 + if (unlikely(!task->exec_file)) {
65089 + read_unlock(&grsec_exec_file_lock);
65090 + return 0;
65091 + }
65092 +
65093 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65094 + read_unlock(&grsec_exec_file_lock);
65095 +
65096 + if (retmode & GR_NOPTRACE) {
65097 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65098 + return 1;
65099 + }
65100 +
65101 + if (retmode & GR_PTRACERD) {
65102 + switch (request) {
65103 + case PTRACE_SEIZE:
65104 + case PTRACE_POKETEXT:
65105 + case PTRACE_POKEDATA:
65106 + case PTRACE_POKEUSR:
65107 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65108 + case PTRACE_SETREGS:
65109 + case PTRACE_SETFPREGS:
65110 +#endif
65111 +#ifdef CONFIG_X86
65112 + case PTRACE_SETFPXREGS:
65113 +#endif
65114 +#ifdef CONFIG_ALTIVEC
65115 + case PTRACE_SETVRREGS:
65116 +#endif
65117 + return 1;
65118 + default:
65119 + return 0;
65120 + }
65121 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65122 + !(current->role->roletype & GR_ROLE_GOD) &&
65123 + (current->acl != task->acl)) {
65124 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65125 + return 1;
65126 + }
65127 +
65128 + return 0;
65129 +}
65130 +
65131 +static int is_writable_mmap(const struct file *filp)
65132 +{
65133 + struct task_struct *task = current;
65134 + struct acl_object_label *obj, *obj2;
65135 +
65136 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65137 + !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))) {
65138 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65139 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65140 + task->role->root_label);
65141 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65142 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65143 + return 1;
65144 + }
65145 + }
65146 + return 0;
65147 +}
65148 +
65149 +int
65150 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65151 +{
65152 + __u32 mode;
65153 +
65154 + if (unlikely(!file || !(prot & PROT_EXEC)))
65155 + return 1;
65156 +
65157 + if (is_writable_mmap(file))
65158 + return 0;
65159 +
65160 + mode =
65161 + gr_search_file(file->f_path.dentry,
65162 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65163 + file->f_path.mnt);
65164 +
65165 + if (!gr_tpe_allow(file))
65166 + return 0;
65167 +
65168 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65169 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65170 + return 0;
65171 + } else if (unlikely(!(mode & GR_EXEC))) {
65172 + return 0;
65173 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65174 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65175 + return 1;
65176 + }
65177 +
65178 + return 1;
65179 +}
65180 +
65181 +int
65182 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65183 +{
65184 + __u32 mode;
65185 +
65186 + if (unlikely(!file || !(prot & PROT_EXEC)))
65187 + return 1;
65188 +
65189 + if (is_writable_mmap(file))
65190 + return 0;
65191 +
65192 + mode =
65193 + gr_search_file(file->f_path.dentry,
65194 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65195 + file->f_path.mnt);
65196 +
65197 + if (!gr_tpe_allow(file))
65198 + return 0;
65199 +
65200 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65201 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65202 + return 0;
65203 + } else if (unlikely(!(mode & GR_EXEC))) {
65204 + return 0;
65205 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65206 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65207 + return 1;
65208 + }
65209 +
65210 + return 1;
65211 +}
65212 +
65213 +void
65214 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65215 +{
65216 + unsigned long runtime;
65217 + unsigned long cputime;
65218 + unsigned int wday, cday;
65219 + __u8 whr, chr;
65220 + __u8 wmin, cmin;
65221 + __u8 wsec, csec;
65222 + struct timespec timeval;
65223 +
65224 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
65225 + !(task->acl->mode & GR_PROCACCT)))
65226 + return;
65227 +
65228 + do_posix_clock_monotonic_gettime(&timeval);
65229 + runtime = timeval.tv_sec - task->start_time.tv_sec;
65230 + wday = runtime / (3600 * 24);
65231 + runtime -= wday * (3600 * 24);
65232 + whr = runtime / 3600;
65233 + runtime -= whr * 3600;
65234 + wmin = runtime / 60;
65235 + runtime -= wmin * 60;
65236 + wsec = runtime;
65237 +
65238 + cputime = (task->utime + task->stime) / HZ;
65239 + cday = cputime / (3600 * 24);
65240 + cputime -= cday * (3600 * 24);
65241 + chr = cputime / 3600;
65242 + cputime -= chr * 3600;
65243 + cmin = cputime / 60;
65244 + cputime -= cmin * 60;
65245 + csec = cputime;
65246 +
65247 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
65248 +
65249 + return;
65250 +}
65251 +
65252 +#ifdef CONFIG_TASKSTATS
65253 +int gr_is_taskstats_denied(int pid)
65254 +{
65255 + struct task_struct *task;
65256 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65257 + const struct cred *cred;
65258 +#endif
65259 + int ret = 0;
65260 +
65261 + /* restrict taskstats viewing to un-chrooted root users
65262 + who have the 'view' subject flag if the RBAC system is enabled
65263 + */
65264 +
65265 + rcu_read_lock();
65266 + read_lock(&tasklist_lock);
65267 + task = find_task_by_vpid(pid);
65268 + if (task) {
65269 +#ifdef CONFIG_GRKERNSEC_CHROOT
65270 + if (proc_is_chrooted(task))
65271 + ret = -EACCES;
65272 +#endif
65273 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65274 + cred = __task_cred(task);
65275 +#ifdef CONFIG_GRKERNSEC_PROC_USER
65276 + if (gr_is_global_nonroot(cred->uid))
65277 + ret = -EACCES;
65278 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65279 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
65280 + ret = -EACCES;
65281 +#endif
65282 +#endif
65283 + if (gr_status & GR_READY) {
65284 + if (!(task->acl->mode & GR_VIEW))
65285 + ret = -EACCES;
65286 + }
65287 + } else
65288 + ret = -ENOENT;
65289 +
65290 + read_unlock(&tasklist_lock);
65291 + rcu_read_unlock();
65292 +
65293 + return ret;
65294 +}
65295 +#endif
65296 +
65297 +/* AUXV entries are filled via a descendant of search_binary_handler
65298 + after we've already applied the subject for the target
65299 +*/
65300 +int gr_acl_enable_at_secure(void)
65301 +{
65302 + if (unlikely(!(gr_status & GR_READY)))
65303 + return 0;
65304 +
65305 + if (current->acl->mode & GR_ATSECURE)
65306 + return 1;
65307 +
65308 + return 0;
65309 +}
65310 +
65311 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
65312 +{
65313 + struct task_struct *task = current;
65314 + struct dentry *dentry = file->f_path.dentry;
65315 + struct vfsmount *mnt = file->f_path.mnt;
65316 + struct acl_object_label *obj, *tmp;
65317 + struct acl_subject_label *subj;
65318 + unsigned int bufsize;
65319 + int is_not_root;
65320 + char *path;
65321 + dev_t dev = __get_dev(dentry);
65322 +
65323 + if (unlikely(!(gr_status & GR_READY)))
65324 + return 1;
65325 +
65326 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65327 + return 1;
65328 +
65329 + /* ignore Eric Biederman */
65330 + if (IS_PRIVATE(dentry->d_inode))
65331 + return 1;
65332 +
65333 + subj = task->acl;
65334 + read_lock(&gr_inode_lock);
65335 + do {
65336 + obj = lookup_acl_obj_label(ino, dev, subj);
65337 + if (obj != NULL) {
65338 + read_unlock(&gr_inode_lock);
65339 + return (obj->mode & GR_FIND) ? 1 : 0;
65340 + }
65341 + } while ((subj = subj->parent_subject));
65342 + read_unlock(&gr_inode_lock);
65343 +
65344 + /* this is purely an optimization since we're looking for an object
65345 + for the directory we're doing a readdir on
65346 + if it's possible for any globbed object to match the entry we're
65347 + filling into the directory, then the object we find here will be
65348 + an anchor point with attached globbed objects
65349 + */
65350 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
65351 + if (obj->globbed == NULL)
65352 + return (obj->mode & GR_FIND) ? 1 : 0;
65353 +
65354 + is_not_root = ((obj->filename[0] == '/') &&
65355 + (obj->filename[1] == '\0')) ? 0 : 1;
65356 + bufsize = PAGE_SIZE - namelen - is_not_root;
65357 +
65358 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
65359 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
65360 + return 1;
65361 +
65362 + preempt_disable();
65363 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
65364 + bufsize);
65365 +
65366 + bufsize = strlen(path);
65367 +
65368 + /* if base is "/", don't append an additional slash */
65369 + if (is_not_root)
65370 + *(path + bufsize) = '/';
65371 + memcpy(path + bufsize + is_not_root, name, namelen);
65372 + *(path + bufsize + namelen + is_not_root) = '\0';
65373 +
65374 + tmp = obj->globbed;
65375 + while (tmp) {
65376 + if (!glob_match(tmp->filename, path)) {
65377 + preempt_enable();
65378 + return (tmp->mode & GR_FIND) ? 1 : 0;
65379 + }
65380 + tmp = tmp->next;
65381 + }
65382 + preempt_enable();
65383 + return (obj->mode & GR_FIND) ? 1 : 0;
65384 +}
65385 +
65386 +void gr_put_exec_file(struct task_struct *task)
65387 +{
65388 + struct file *filp;
65389 +
65390 + write_lock(&grsec_exec_file_lock);
65391 + filp = task->exec_file;
65392 + task->exec_file = NULL;
65393 + write_unlock(&grsec_exec_file_lock);
65394 +
65395 + if (filp)
65396 + fput(filp);
65397 +
65398 + return;
65399 +}
65400 +
65401 +
65402 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
65403 +EXPORT_SYMBOL(gr_acl_is_enabled);
65404 +#endif
65405 +#ifdef CONFIG_SECURITY
65406 +EXPORT_SYMBOL(gr_check_user_change);
65407 +EXPORT_SYMBOL(gr_check_group_change);
65408 +#endif
65409 +
65410 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
65411 new file mode 100644
65412 index 0000000..18ffbbd
65413 --- /dev/null
65414 +++ b/grsecurity/gracl_alloc.c
65415 @@ -0,0 +1,105 @@
65416 +#include <linux/kernel.h>
65417 +#include <linux/mm.h>
65418 +#include <linux/slab.h>
65419 +#include <linux/vmalloc.h>
65420 +#include <linux/gracl.h>
65421 +#include <linux/grsecurity.h>
65422 +
65423 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
65424 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
65425 +
65426 +static __inline__ int
65427 +alloc_pop(void)
65428 +{
65429 + if (current_alloc_state->alloc_stack_next == 1)
65430 + return 0;
65431 +
65432 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
65433 +
65434 + current_alloc_state->alloc_stack_next--;
65435 +
65436 + return 1;
65437 +}
65438 +
65439 +static __inline__ int
65440 +alloc_push(void *buf)
65441 +{
65442 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
65443 + return 1;
65444 +
65445 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
65446 +
65447 + current_alloc_state->alloc_stack_next++;
65448 +
65449 + return 0;
65450 +}
65451 +
65452 +void *
65453 +acl_alloc(unsigned long len)
65454 +{
65455 + void *ret = NULL;
65456 +
65457 + if (!len || len > PAGE_SIZE)
65458 + goto out;
65459 +
65460 + ret = kmalloc(len, GFP_KERNEL);
65461 +
65462 + if (ret) {
65463 + if (alloc_push(ret)) {
65464 + kfree(ret);
65465 + ret = NULL;
65466 + }
65467 + }
65468 +
65469 +out:
65470 + return ret;
65471 +}
65472 +
65473 +void *
65474 +acl_alloc_num(unsigned long num, unsigned long len)
65475 +{
65476 + if (!len || (num > (PAGE_SIZE / len)))
65477 + return NULL;
65478 +
65479 + return acl_alloc(num * len);
65480 +}
65481 +
65482 +void
65483 +acl_free_all(void)
65484 +{
65485 + if (!current_alloc_state->alloc_stack)
65486 + return;
65487 +
65488 + while (alloc_pop()) ;
65489 +
65490 + if (current_alloc_state->alloc_stack) {
65491 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
65492 + kfree(current_alloc_state->alloc_stack);
65493 + else
65494 + vfree(current_alloc_state->alloc_stack);
65495 + }
65496 +
65497 + current_alloc_state->alloc_stack = NULL;
65498 + current_alloc_state->alloc_stack_size = 1;
65499 + current_alloc_state->alloc_stack_next = 1;
65500 +
65501 + return;
65502 +}
65503 +
65504 +int
65505 +acl_alloc_stack_init(unsigned long size)
65506 +{
65507 + if ((size * sizeof (void *)) <= PAGE_SIZE)
65508 + current_alloc_state->alloc_stack =
65509 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
65510 + else
65511 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
65512 +
65513 + current_alloc_state->alloc_stack_size = size;
65514 + current_alloc_state->alloc_stack_next = 1;
65515 +
65516 + if (!current_alloc_state->alloc_stack)
65517 + return 0;
65518 + else
65519 + return 1;
65520 +}
65521 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
65522 new file mode 100644
65523 index 0000000..bdd51ea
65524 --- /dev/null
65525 +++ b/grsecurity/gracl_cap.c
65526 @@ -0,0 +1,110 @@
65527 +#include <linux/kernel.h>
65528 +#include <linux/module.h>
65529 +#include <linux/sched.h>
65530 +#include <linux/gracl.h>
65531 +#include <linux/grsecurity.h>
65532 +#include <linux/grinternal.h>
65533 +
65534 +extern const char *captab_log[];
65535 +extern int captab_log_entries;
65536 +
65537 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65538 +{
65539 + struct acl_subject_label *curracl;
65540 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65541 + kernel_cap_t cap_audit = __cap_empty_set;
65542 +
65543 + if (!gr_acl_is_enabled())
65544 + return 1;
65545 +
65546 + curracl = task->acl;
65547 +
65548 + cap_drop = curracl->cap_lower;
65549 + cap_mask = curracl->cap_mask;
65550 + cap_audit = curracl->cap_invert_audit;
65551 +
65552 + while ((curracl = curracl->parent_subject)) {
65553 + /* if the cap isn't specified in the current computed mask but is specified in the
65554 + current level subject, and is lowered in the current level subject, then add
65555 + it to the set of dropped capabilities
65556 + otherwise, add the current level subject's mask to the current computed mask
65557 + */
65558 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65559 + cap_raise(cap_mask, cap);
65560 + if (cap_raised(curracl->cap_lower, cap))
65561 + cap_raise(cap_drop, cap);
65562 + if (cap_raised(curracl->cap_invert_audit, cap))
65563 + cap_raise(cap_audit, cap);
65564 + }
65565 + }
65566 +
65567 + if (!cap_raised(cap_drop, cap)) {
65568 + if (cap_raised(cap_audit, cap))
65569 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
65570 + return 1;
65571 + }
65572 +
65573 + curracl = task->acl;
65574 +
65575 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
65576 + && cap_raised(cred->cap_effective, cap)) {
65577 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65578 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
65579 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
65580 + gr_to_filename(task->exec_file->f_path.dentry,
65581 + task->exec_file->f_path.mnt) : curracl->filename,
65582 + curracl->filename, 0UL,
65583 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
65584 + return 1;
65585 + }
65586 +
65587 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
65588 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
65589 +
65590 + return 0;
65591 +}
65592 +
65593 +int
65594 +gr_acl_is_capable(const int cap)
65595 +{
65596 + return gr_task_acl_is_capable(current, current_cred(), cap);
65597 +}
65598 +
65599 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
65600 +{
65601 + struct acl_subject_label *curracl;
65602 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65603 +
65604 + if (!gr_acl_is_enabled())
65605 + return 1;
65606 +
65607 + curracl = task->acl;
65608 +
65609 + cap_drop = curracl->cap_lower;
65610 + cap_mask = curracl->cap_mask;
65611 +
65612 + while ((curracl = curracl->parent_subject)) {
65613 + /* if the cap isn't specified in the current computed mask but is specified in the
65614 + current level subject, and is lowered in the current level subject, then add
65615 + it to the set of dropped capabilities
65616 + otherwise, add the current level subject's mask to the current computed mask
65617 + */
65618 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65619 + cap_raise(cap_mask, cap);
65620 + if (cap_raised(curracl->cap_lower, cap))
65621 + cap_raise(cap_drop, cap);
65622 + }
65623 + }
65624 +
65625 + if (!cap_raised(cap_drop, cap))
65626 + return 1;
65627 +
65628 + return 0;
65629 +}
65630 +
65631 +int
65632 +gr_acl_is_capable_nolog(const int cap)
65633 +{
65634 + return gr_task_acl_is_capable_nolog(current, cap);
65635 +}
65636 +
65637 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
65638 new file mode 100644
65639 index 0000000..ca25605
65640 --- /dev/null
65641 +++ b/grsecurity/gracl_compat.c
65642 @@ -0,0 +1,270 @@
65643 +#include <linux/kernel.h>
65644 +#include <linux/gracl.h>
65645 +#include <linux/compat.h>
65646 +#include <linux/gracl_compat.h>
65647 +
65648 +#include <asm/uaccess.h>
65649 +
65650 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
65651 +{
65652 + struct gr_arg_wrapper_compat uwrapcompat;
65653 +
65654 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
65655 + return -EFAULT;
65656 +
65657 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
65658 + (uwrapcompat.version != 0x2901)) ||
65659 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
65660 + return -EINVAL;
65661 +
65662 + uwrap->arg = compat_ptr(uwrapcompat.arg);
65663 + uwrap->version = uwrapcompat.version;
65664 + uwrap->size = sizeof(struct gr_arg);
65665 +
65666 + return 0;
65667 +}
65668 +
65669 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
65670 +{
65671 + struct gr_arg_compat argcompat;
65672 +
65673 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
65674 + return -EFAULT;
65675 +
65676 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
65677 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
65678 + arg->role_db.num_roles = argcompat.role_db.num_roles;
65679 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
65680 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
65681 + arg->role_db.num_objects = argcompat.role_db.num_objects;
65682 +
65683 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
65684 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65685 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65686 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65687 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65688 + arg->segv_device = argcompat.segv_device;
65689 + arg->segv_inode = argcompat.segv_inode;
65690 + arg->segv_uid = argcompat.segv_uid;
65691 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65692 + arg->mode = argcompat.mode;
65693 +
65694 + return 0;
65695 +}
65696 +
65697 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65698 +{
65699 + struct acl_object_label_compat objcompat;
65700 +
65701 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65702 + return -EFAULT;
65703 +
65704 + obj->filename = compat_ptr(objcompat.filename);
65705 + obj->inode = objcompat.inode;
65706 + obj->device = objcompat.device;
65707 + obj->mode = objcompat.mode;
65708 +
65709 + obj->nested = compat_ptr(objcompat.nested);
65710 + obj->globbed = compat_ptr(objcompat.globbed);
65711 +
65712 + obj->prev = compat_ptr(objcompat.prev);
65713 + obj->next = compat_ptr(objcompat.next);
65714 +
65715 + return 0;
65716 +}
65717 +
65718 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65719 +{
65720 + unsigned int i;
65721 + struct acl_subject_label_compat subjcompat;
65722 +
65723 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65724 + return -EFAULT;
65725 +
65726 + subj->filename = compat_ptr(subjcompat.filename);
65727 + subj->inode = subjcompat.inode;
65728 + subj->device = subjcompat.device;
65729 + subj->mode = subjcompat.mode;
65730 + subj->cap_mask = subjcompat.cap_mask;
65731 + subj->cap_lower = subjcompat.cap_lower;
65732 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65733 +
65734 + for (i = 0; i < GR_NLIMITS; i++) {
65735 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65736 + subj->res[i].rlim_cur = RLIM_INFINITY;
65737 + else
65738 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65739 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65740 + subj->res[i].rlim_max = RLIM_INFINITY;
65741 + else
65742 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65743 + }
65744 + subj->resmask = subjcompat.resmask;
65745 +
65746 + subj->user_trans_type = subjcompat.user_trans_type;
65747 + subj->group_trans_type = subjcompat.group_trans_type;
65748 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65749 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65750 + subj->user_trans_num = subjcompat.user_trans_num;
65751 + subj->group_trans_num = subjcompat.group_trans_num;
65752 +
65753 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65754 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65755 + subj->ip_type = subjcompat.ip_type;
65756 + subj->ips = compat_ptr(subjcompat.ips);
65757 + subj->ip_num = subjcompat.ip_num;
65758 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65759 +
65760 + subj->crashes = subjcompat.crashes;
65761 + subj->expires = subjcompat.expires;
65762 +
65763 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65764 + subj->hash = compat_ptr(subjcompat.hash);
65765 + subj->prev = compat_ptr(subjcompat.prev);
65766 + subj->next = compat_ptr(subjcompat.next);
65767 +
65768 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65769 + subj->obj_hash_size = subjcompat.obj_hash_size;
65770 + subj->pax_flags = subjcompat.pax_flags;
65771 +
65772 + return 0;
65773 +}
65774 +
65775 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65776 +{
65777 + struct acl_role_label_compat rolecompat;
65778 +
65779 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65780 + return -EFAULT;
65781 +
65782 + role->rolename = compat_ptr(rolecompat.rolename);
65783 + role->uidgid = rolecompat.uidgid;
65784 + role->roletype = rolecompat.roletype;
65785 +
65786 + role->auth_attempts = rolecompat.auth_attempts;
65787 + role->expires = rolecompat.expires;
65788 +
65789 + role->root_label = compat_ptr(rolecompat.root_label);
65790 + role->hash = compat_ptr(rolecompat.hash);
65791 +
65792 + role->prev = compat_ptr(rolecompat.prev);
65793 + role->next = compat_ptr(rolecompat.next);
65794 +
65795 + role->transitions = compat_ptr(rolecompat.transitions);
65796 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65797 + role->domain_children = compat_ptr(rolecompat.domain_children);
65798 + role->domain_child_num = rolecompat.domain_child_num;
65799 +
65800 + role->umask = rolecompat.umask;
65801 +
65802 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65803 + role->subj_hash_size = rolecompat.subj_hash_size;
65804 +
65805 + return 0;
65806 +}
65807 +
65808 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65809 +{
65810 + struct role_allowed_ip_compat roleip_compat;
65811 +
65812 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65813 + return -EFAULT;
65814 +
65815 + roleip->addr = roleip_compat.addr;
65816 + roleip->netmask = roleip_compat.netmask;
65817 +
65818 + roleip->prev = compat_ptr(roleip_compat.prev);
65819 + roleip->next = compat_ptr(roleip_compat.next);
65820 +
65821 + return 0;
65822 +}
65823 +
65824 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65825 +{
65826 + struct role_transition_compat trans_compat;
65827 +
65828 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65829 + return -EFAULT;
65830 +
65831 + trans->rolename = compat_ptr(trans_compat.rolename);
65832 +
65833 + trans->prev = compat_ptr(trans_compat.prev);
65834 + trans->next = compat_ptr(trans_compat.next);
65835 +
65836 + return 0;
65837 +
65838 +}
65839 +
65840 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
65841 +{
65842 + struct gr_hash_struct_compat hash_compat;
65843 +
65844 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
65845 + return -EFAULT;
65846 +
65847 + hash->table = compat_ptr(hash_compat.table);
65848 + hash->nametable = compat_ptr(hash_compat.nametable);
65849 + hash->first = compat_ptr(hash_compat.first);
65850 +
65851 + hash->table_size = hash_compat.table_size;
65852 + hash->used_size = hash_compat.used_size;
65853 +
65854 + hash->type = hash_compat.type;
65855 +
65856 + return 0;
65857 +}
65858 +
65859 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
65860 +{
65861 + compat_uptr_t ptrcompat;
65862 +
65863 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
65864 + return -EFAULT;
65865 +
65866 + *(void **)ptr = compat_ptr(ptrcompat);
65867 +
65868 + return 0;
65869 +}
65870 +
65871 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
65872 +{
65873 + struct acl_ip_label_compat ip_compat;
65874 +
65875 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
65876 + return -EFAULT;
65877 +
65878 + ip->iface = compat_ptr(ip_compat.iface);
65879 + ip->addr = ip_compat.addr;
65880 + ip->netmask = ip_compat.netmask;
65881 + ip->low = ip_compat.low;
65882 + ip->high = ip_compat.high;
65883 + ip->mode = ip_compat.mode;
65884 + ip->type = ip_compat.type;
65885 +
65886 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
65887 +
65888 + ip->prev = compat_ptr(ip_compat.prev);
65889 + ip->next = compat_ptr(ip_compat.next);
65890 +
65891 + return 0;
65892 +}
65893 +
65894 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
65895 +{
65896 + struct sprole_pw_compat pw_compat;
65897 +
65898 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
65899 + return -EFAULT;
65900 +
65901 + pw->rolename = compat_ptr(pw_compat.rolename);
65902 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
65903 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
65904 +
65905 + return 0;
65906 +}
65907 +
65908 +size_t get_gr_arg_wrapper_size_compat(void)
65909 +{
65910 + return sizeof(struct gr_arg_wrapper_compat);
65911 +}
65912 +
65913 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
65914 new file mode 100644
65915 index 0000000..a340c17
65916 --- /dev/null
65917 +++ b/grsecurity/gracl_fs.c
65918 @@ -0,0 +1,431 @@
65919 +#include <linux/kernel.h>
65920 +#include <linux/sched.h>
65921 +#include <linux/types.h>
65922 +#include <linux/fs.h>
65923 +#include <linux/file.h>
65924 +#include <linux/stat.h>
65925 +#include <linux/grsecurity.h>
65926 +#include <linux/grinternal.h>
65927 +#include <linux/gracl.h>
65928 +
65929 +umode_t
65930 +gr_acl_umask(void)
65931 +{
65932 + if (unlikely(!gr_acl_is_enabled()))
65933 + return 0;
65934 +
65935 + return current->role->umask;
65936 +}
65937 +
65938 +__u32
65939 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65940 + const struct vfsmount * mnt)
65941 +{
65942 + __u32 mode;
65943 +
65944 + if (unlikely(!dentry->d_inode))
65945 + return GR_FIND;
65946 +
65947 + mode =
65948 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
65949 +
65950 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
65951 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65952 + return mode;
65953 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
65954 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65955 + return 0;
65956 + } else if (unlikely(!(mode & GR_FIND)))
65957 + return 0;
65958 +
65959 + return GR_FIND;
65960 +}
65961 +
65962 +__u32
65963 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65964 + int acc_mode)
65965 +{
65966 + __u32 reqmode = GR_FIND;
65967 + __u32 mode;
65968 +
65969 + if (unlikely(!dentry->d_inode))
65970 + return reqmode;
65971 +
65972 + if (acc_mode & MAY_APPEND)
65973 + reqmode |= GR_APPEND;
65974 + else if (acc_mode & MAY_WRITE)
65975 + reqmode |= GR_WRITE;
65976 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
65977 + reqmode |= GR_READ;
65978 +
65979 + mode =
65980 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65981 + mnt);
65982 +
65983 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65984 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65985 + reqmode & GR_READ ? " reading" : "",
65986 + reqmode & GR_WRITE ? " writing" : reqmode &
65987 + GR_APPEND ? " appending" : "");
65988 + return reqmode;
65989 + } else
65990 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65991 + {
65992 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65993 + reqmode & GR_READ ? " reading" : "",
65994 + reqmode & GR_WRITE ? " writing" : reqmode &
65995 + GR_APPEND ? " appending" : "");
65996 + return 0;
65997 + } else if (unlikely((mode & reqmode) != reqmode))
65998 + return 0;
65999 +
66000 + return reqmode;
66001 +}
66002 +
66003 +__u32
66004 +gr_acl_handle_creat(const struct dentry * dentry,
66005 + const struct dentry * p_dentry,
66006 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66007 + const int imode)
66008 +{
66009 + __u32 reqmode = GR_WRITE | GR_CREATE;
66010 + __u32 mode;
66011 +
66012 + if (acc_mode & MAY_APPEND)
66013 + reqmode |= GR_APPEND;
66014 + // if a directory was required or the directory already exists, then
66015 + // don't count this open as a read
66016 + if ((acc_mode & MAY_READ) &&
66017 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66018 + reqmode |= GR_READ;
66019 + if ((open_flags & O_CREAT) &&
66020 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66021 + reqmode |= GR_SETID;
66022 +
66023 + mode =
66024 + gr_check_create(dentry, p_dentry, p_mnt,
66025 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66026 +
66027 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66028 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66029 + reqmode & GR_READ ? " reading" : "",
66030 + reqmode & GR_WRITE ? " writing" : reqmode &
66031 + GR_APPEND ? " appending" : "");
66032 + return reqmode;
66033 + } else
66034 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66035 + {
66036 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66037 + reqmode & GR_READ ? " reading" : "",
66038 + reqmode & GR_WRITE ? " writing" : reqmode &
66039 + GR_APPEND ? " appending" : "");
66040 + return 0;
66041 + } else if (unlikely((mode & reqmode) != reqmode))
66042 + return 0;
66043 +
66044 + return reqmode;
66045 +}
66046 +
66047 +__u32
66048 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66049 + const int fmode)
66050 +{
66051 + __u32 mode, reqmode = GR_FIND;
66052 +
66053 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66054 + reqmode |= GR_EXEC;
66055 + if (fmode & S_IWOTH)
66056 + reqmode |= GR_WRITE;
66057 + if (fmode & S_IROTH)
66058 + reqmode |= GR_READ;
66059 +
66060 + mode =
66061 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66062 + mnt);
66063 +
66064 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66065 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66066 + reqmode & GR_READ ? " reading" : "",
66067 + reqmode & GR_WRITE ? " writing" : "",
66068 + reqmode & GR_EXEC ? " executing" : "");
66069 + return reqmode;
66070 + } else
66071 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66072 + {
66073 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66074 + reqmode & GR_READ ? " reading" : "",
66075 + reqmode & GR_WRITE ? " writing" : "",
66076 + reqmode & GR_EXEC ? " executing" : "");
66077 + return 0;
66078 + } else if (unlikely((mode & reqmode) != reqmode))
66079 + return 0;
66080 +
66081 + return reqmode;
66082 +}
66083 +
66084 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66085 +{
66086 + __u32 mode;
66087 +
66088 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66089 +
66090 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66091 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66092 + return mode;
66093 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66094 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66095 + return 0;
66096 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66097 + return 0;
66098 +
66099 + return (reqmode);
66100 +}
66101 +
66102 +__u32
66103 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66104 +{
66105 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66106 +}
66107 +
66108 +__u32
66109 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66110 +{
66111 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66112 +}
66113 +
66114 +__u32
66115 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66116 +{
66117 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66118 +}
66119 +
66120 +__u32
66121 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66122 +{
66123 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66124 +}
66125 +
66126 +__u32
66127 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66128 + umode_t *modeptr)
66129 +{
66130 + umode_t mode;
66131 +
66132 + *modeptr &= ~gr_acl_umask();
66133 + mode = *modeptr;
66134 +
66135 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66136 + return 1;
66137 +
66138 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66139 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66140 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66141 + GR_CHMOD_ACL_MSG);
66142 + } else {
66143 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66144 + }
66145 +}
66146 +
66147 +__u32
66148 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66149 +{
66150 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66151 +}
66152 +
66153 +__u32
66154 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66155 +{
66156 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66157 +}
66158 +
66159 +__u32
66160 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66161 +{
66162 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66163 +}
66164 +
66165 +__u32
66166 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66167 +{
66168 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66169 + GR_UNIXCONNECT_ACL_MSG);
66170 +}
66171 +
66172 +/* hardlinks require at minimum create and link permission,
66173 + any additional privilege required is based on the
66174 + privilege of the file being linked to
66175 +*/
66176 +__u32
66177 +gr_acl_handle_link(const struct dentry * new_dentry,
66178 + const struct dentry * parent_dentry,
66179 + const struct vfsmount * parent_mnt,
66180 + const struct dentry * old_dentry,
66181 + const struct vfsmount * old_mnt, const struct filename *to)
66182 +{
66183 + __u32 mode;
66184 + __u32 needmode = GR_CREATE | GR_LINK;
66185 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66186 +
66187 + mode =
66188 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66189 + old_mnt);
66190 +
66191 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66192 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66193 + return mode;
66194 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66195 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66196 + return 0;
66197 + } else if (unlikely((mode & needmode) != needmode))
66198 + return 0;
66199 +
66200 + return 1;
66201 +}
66202 +
66203 +__u32
66204 +gr_acl_handle_symlink(const struct dentry * new_dentry,
66205 + const struct dentry * parent_dentry,
66206 + const struct vfsmount * parent_mnt, const struct filename *from)
66207 +{
66208 + __u32 needmode = GR_WRITE | GR_CREATE;
66209 + __u32 mode;
66210 +
66211 + mode =
66212 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
66213 + GR_CREATE | GR_AUDIT_CREATE |
66214 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
66215 +
66216 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
66217 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66218 + return mode;
66219 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66220 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66221 + return 0;
66222 + } else if (unlikely((mode & needmode) != needmode))
66223 + return 0;
66224 +
66225 + return (GR_WRITE | GR_CREATE);
66226 +}
66227 +
66228 +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)
66229 +{
66230 + __u32 mode;
66231 +
66232 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66233 +
66234 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66235 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
66236 + return mode;
66237 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66238 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
66239 + return 0;
66240 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66241 + return 0;
66242 +
66243 + return (reqmode);
66244 +}
66245 +
66246 +__u32
66247 +gr_acl_handle_mknod(const struct dentry * new_dentry,
66248 + const struct dentry * parent_dentry,
66249 + const struct vfsmount * parent_mnt,
66250 + const int mode)
66251 +{
66252 + __u32 reqmode = GR_WRITE | GR_CREATE;
66253 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66254 + reqmode |= GR_SETID;
66255 +
66256 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66257 + reqmode, GR_MKNOD_ACL_MSG);
66258 +}
66259 +
66260 +__u32
66261 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
66262 + const struct dentry *parent_dentry,
66263 + const struct vfsmount *parent_mnt)
66264 +{
66265 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66266 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
66267 +}
66268 +
66269 +#define RENAME_CHECK_SUCCESS(old, new) \
66270 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
66271 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
66272 +
66273 +int
66274 +gr_acl_handle_rename(struct dentry *new_dentry,
66275 + struct dentry *parent_dentry,
66276 + const struct vfsmount *parent_mnt,
66277 + struct dentry *old_dentry,
66278 + struct inode *old_parent_inode,
66279 + struct vfsmount *old_mnt, const struct filename *newname)
66280 +{
66281 + __u32 comp1, comp2;
66282 + int error = 0;
66283 +
66284 + if (unlikely(!gr_acl_is_enabled()))
66285 + return 0;
66286 +
66287 + if (!new_dentry->d_inode) {
66288 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
66289 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
66290 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
66291 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
66292 + GR_DELETE | GR_AUDIT_DELETE |
66293 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66294 + GR_SUPPRESS, old_mnt);
66295 + } else {
66296 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
66297 + GR_CREATE | GR_DELETE |
66298 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
66299 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66300 + GR_SUPPRESS, parent_mnt);
66301 + comp2 =
66302 + gr_search_file(old_dentry,
66303 + GR_READ | GR_WRITE | GR_AUDIT_READ |
66304 + GR_DELETE | GR_AUDIT_DELETE |
66305 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
66306 + }
66307 +
66308 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
66309 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
66310 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66311 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
66312 + && !(comp2 & GR_SUPPRESS)) {
66313 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66314 + error = -EACCES;
66315 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
66316 + error = -EACCES;
66317 +
66318 + return error;
66319 +}
66320 +
66321 +void
66322 +gr_acl_handle_exit(void)
66323 +{
66324 + u16 id;
66325 + char *rolename;
66326 +
66327 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
66328 + !(current->role->roletype & GR_ROLE_PERSIST))) {
66329 + id = current->acl_role_id;
66330 + rolename = current->role->rolename;
66331 + gr_set_acls(1);
66332 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
66333 + }
66334 +
66335 + gr_put_exec_file(current);
66336 + return;
66337 +}
66338 +
66339 +int
66340 +gr_acl_handle_procpidmem(const struct task_struct *task)
66341 +{
66342 + if (unlikely(!gr_acl_is_enabled()))
66343 + return 0;
66344 +
66345 + if (task != current && task->acl->mode & GR_PROTPROCFD)
66346 + return -EACCES;
66347 +
66348 + return 0;
66349 +}
66350 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
66351 new file mode 100644
66352 index 0000000..f056b81
66353 --- /dev/null
66354 +++ b/grsecurity/gracl_ip.c
66355 @@ -0,0 +1,386 @@
66356 +#include <linux/kernel.h>
66357 +#include <asm/uaccess.h>
66358 +#include <asm/errno.h>
66359 +#include <net/sock.h>
66360 +#include <linux/file.h>
66361 +#include <linux/fs.h>
66362 +#include <linux/net.h>
66363 +#include <linux/in.h>
66364 +#include <linux/skbuff.h>
66365 +#include <linux/ip.h>
66366 +#include <linux/udp.h>
66367 +#include <linux/types.h>
66368 +#include <linux/sched.h>
66369 +#include <linux/netdevice.h>
66370 +#include <linux/inetdevice.h>
66371 +#include <linux/gracl.h>
66372 +#include <linux/grsecurity.h>
66373 +#include <linux/grinternal.h>
66374 +
66375 +#define GR_BIND 0x01
66376 +#define GR_CONNECT 0x02
66377 +#define GR_INVERT 0x04
66378 +#define GR_BINDOVERRIDE 0x08
66379 +#define GR_CONNECTOVERRIDE 0x10
66380 +#define GR_SOCK_FAMILY 0x20
66381 +
66382 +static const char * gr_protocols[IPPROTO_MAX] = {
66383 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
66384 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
66385 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
66386 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
66387 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
66388 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
66389 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
66390 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
66391 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
66392 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
66393 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
66394 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
66395 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
66396 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
66397 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
66398 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
66399 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
66400 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
66401 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
66402 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
66403 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
66404 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
66405 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
66406 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
66407 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
66408 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
66409 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
66410 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
66411 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
66412 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
66413 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
66414 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
66415 + };
66416 +
66417 +static const char * gr_socktypes[SOCK_MAX] = {
66418 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
66419 + "unknown:7", "unknown:8", "unknown:9", "packet"
66420 + };
66421 +
66422 +static const char * gr_sockfamilies[AF_MAX+1] = {
66423 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
66424 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
66425 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
66426 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
66427 + };
66428 +
66429 +const char *
66430 +gr_proto_to_name(unsigned char proto)
66431 +{
66432 + return gr_protocols[proto];
66433 +}
66434 +
66435 +const char *
66436 +gr_socktype_to_name(unsigned char type)
66437 +{
66438 + return gr_socktypes[type];
66439 +}
66440 +
66441 +const char *
66442 +gr_sockfamily_to_name(unsigned char family)
66443 +{
66444 + return gr_sockfamilies[family];
66445 +}
66446 +
66447 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
66448 +
66449 +int
66450 +gr_search_socket(const int domain, const int type, const int protocol)
66451 +{
66452 + struct acl_subject_label *curr;
66453 + const struct cred *cred = current_cred();
66454 +
66455 + if (unlikely(!gr_acl_is_enabled()))
66456 + goto exit;
66457 +
66458 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
66459 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
66460 + goto exit; // let the kernel handle it
66461 +
66462 + curr = current->acl;
66463 +
66464 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
66465 + /* the family is allowed, if this is PF_INET allow it only if
66466 + the extra sock type/protocol checks pass */
66467 + if (domain == PF_INET)
66468 + goto inet_check;
66469 + goto exit;
66470 + } else {
66471 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66472 + __u32 fakeip = 0;
66473 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66474 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66475 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66476 + gr_to_filename(current->exec_file->f_path.dentry,
66477 + current->exec_file->f_path.mnt) :
66478 + curr->filename, curr->filename,
66479 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
66480 + &current->signal->saved_ip);
66481 + goto exit;
66482 + }
66483 + goto exit_fail;
66484 + }
66485 +
66486 +inet_check:
66487 + /* the rest of this checking is for IPv4 only */
66488 + if (!curr->ips)
66489 + goto exit;
66490 +
66491 + if ((curr->ip_type & (1U << type)) &&
66492 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
66493 + goto exit;
66494 +
66495 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66496 + /* we don't place acls on raw sockets , and sometimes
66497 + dgram/ip sockets are opened for ioctl and not
66498 + bind/connect, so we'll fake a bind learn log */
66499 + if (type == SOCK_RAW || type == SOCK_PACKET) {
66500 + __u32 fakeip = 0;
66501 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66502 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66503 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66504 + gr_to_filename(current->exec_file->f_path.dentry,
66505 + current->exec_file->f_path.mnt) :
66506 + curr->filename, curr->filename,
66507 + &fakeip, 0, type,
66508 + protocol, GR_CONNECT, &current->signal->saved_ip);
66509 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
66510 + __u32 fakeip = 0;
66511 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66512 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66513 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66514 + gr_to_filename(current->exec_file->f_path.dentry,
66515 + current->exec_file->f_path.mnt) :
66516 + curr->filename, curr->filename,
66517 + &fakeip, 0, type,
66518 + protocol, GR_BIND, &current->signal->saved_ip);
66519 + }
66520 + /* we'll log when they use connect or bind */
66521 + goto exit;
66522 + }
66523 +
66524 +exit_fail:
66525 + if (domain == PF_INET)
66526 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
66527 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
66528 + else if (rcu_access_pointer(net_families[domain]) != NULL)
66529 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
66530 + gr_socktype_to_name(type), protocol);
66531 +
66532 + return 0;
66533 +exit:
66534 + return 1;
66535 +}
66536 +
66537 +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)
66538 +{
66539 + if ((ip->mode & mode) &&
66540 + (ip_port >= ip->low) &&
66541 + (ip_port <= ip->high) &&
66542 + ((ntohl(ip_addr) & our_netmask) ==
66543 + (ntohl(our_addr) & our_netmask))
66544 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
66545 + && (ip->type & (1U << type))) {
66546 + if (ip->mode & GR_INVERT)
66547 + return 2; // specifically denied
66548 + else
66549 + return 1; // allowed
66550 + }
66551 +
66552 + return 0; // not specifically allowed, may continue parsing
66553 +}
66554 +
66555 +static int
66556 +gr_search_connectbind(const int full_mode, struct sock *sk,
66557 + struct sockaddr_in *addr, const int type)
66558 +{
66559 + char iface[IFNAMSIZ] = {0};
66560 + struct acl_subject_label *curr;
66561 + struct acl_ip_label *ip;
66562 + struct inet_sock *isk;
66563 + struct net_device *dev;
66564 + struct in_device *idev;
66565 + unsigned long i;
66566 + int ret;
66567 + int mode = full_mode & (GR_BIND | GR_CONNECT);
66568 + __u32 ip_addr = 0;
66569 + __u32 our_addr;
66570 + __u32 our_netmask;
66571 + char *p;
66572 + __u16 ip_port = 0;
66573 + const struct cred *cred = current_cred();
66574 +
66575 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
66576 + return 0;
66577 +
66578 + curr = current->acl;
66579 + isk = inet_sk(sk);
66580 +
66581 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
66582 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
66583 + addr->sin_addr.s_addr = curr->inaddr_any_override;
66584 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
66585 + struct sockaddr_in saddr;
66586 + int err;
66587 +
66588 + saddr.sin_family = AF_INET;
66589 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
66590 + saddr.sin_port = isk->inet_sport;
66591 +
66592 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66593 + if (err)
66594 + return err;
66595 +
66596 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66597 + if (err)
66598 + return err;
66599 + }
66600 +
66601 + if (!curr->ips)
66602 + return 0;
66603 +
66604 + ip_addr = addr->sin_addr.s_addr;
66605 + ip_port = ntohs(addr->sin_port);
66606 +
66607 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66608 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66609 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66610 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66611 + gr_to_filename(current->exec_file->f_path.dentry,
66612 + current->exec_file->f_path.mnt) :
66613 + curr->filename, curr->filename,
66614 + &ip_addr, ip_port, type,
66615 + sk->sk_protocol, mode, &current->signal->saved_ip);
66616 + return 0;
66617 + }
66618 +
66619 + for (i = 0; i < curr->ip_num; i++) {
66620 + ip = *(curr->ips + i);
66621 + if (ip->iface != NULL) {
66622 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
66623 + p = strchr(iface, ':');
66624 + if (p != NULL)
66625 + *p = '\0';
66626 + dev = dev_get_by_name(sock_net(sk), iface);
66627 + if (dev == NULL)
66628 + continue;
66629 + idev = in_dev_get(dev);
66630 + if (idev == NULL) {
66631 + dev_put(dev);
66632 + continue;
66633 + }
66634 + rcu_read_lock();
66635 + for_ifa(idev) {
66636 + if (!strcmp(ip->iface, ifa->ifa_label)) {
66637 + our_addr = ifa->ifa_address;
66638 + our_netmask = 0xffffffff;
66639 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66640 + if (ret == 1) {
66641 + rcu_read_unlock();
66642 + in_dev_put(idev);
66643 + dev_put(dev);
66644 + return 0;
66645 + } else if (ret == 2) {
66646 + rcu_read_unlock();
66647 + in_dev_put(idev);
66648 + dev_put(dev);
66649 + goto denied;
66650 + }
66651 + }
66652 + } endfor_ifa(idev);
66653 + rcu_read_unlock();
66654 + in_dev_put(idev);
66655 + dev_put(dev);
66656 + } else {
66657 + our_addr = ip->addr;
66658 + our_netmask = ip->netmask;
66659 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66660 + if (ret == 1)
66661 + return 0;
66662 + else if (ret == 2)
66663 + goto denied;
66664 + }
66665 + }
66666 +
66667 +denied:
66668 + if (mode == GR_BIND)
66669 + 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));
66670 + else if (mode == GR_CONNECT)
66671 + 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));
66672 +
66673 + return -EACCES;
66674 +}
66675 +
66676 +int
66677 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
66678 +{
66679 + /* always allow disconnection of dgram sockets with connect */
66680 + if (addr->sin_family == AF_UNSPEC)
66681 + return 0;
66682 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
66683 +}
66684 +
66685 +int
66686 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66687 +{
66688 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66689 +}
66690 +
66691 +int gr_search_listen(struct socket *sock)
66692 +{
66693 + struct sock *sk = sock->sk;
66694 + struct sockaddr_in addr;
66695 +
66696 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66697 + addr.sin_port = inet_sk(sk)->inet_sport;
66698 +
66699 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66700 +}
66701 +
66702 +int gr_search_accept(struct socket *sock)
66703 +{
66704 + struct sock *sk = sock->sk;
66705 + struct sockaddr_in addr;
66706 +
66707 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66708 + addr.sin_port = inet_sk(sk)->inet_sport;
66709 +
66710 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66711 +}
66712 +
66713 +int
66714 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66715 +{
66716 + if (addr)
66717 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66718 + else {
66719 + struct sockaddr_in sin;
66720 + const struct inet_sock *inet = inet_sk(sk);
66721 +
66722 + sin.sin_addr.s_addr = inet->inet_daddr;
66723 + sin.sin_port = inet->inet_dport;
66724 +
66725 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66726 + }
66727 +}
66728 +
66729 +int
66730 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66731 +{
66732 + struct sockaddr_in sin;
66733 +
66734 + if (unlikely(skb->len < sizeof (struct udphdr)))
66735 + return 0; // skip this packet
66736 +
66737 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66738 + sin.sin_port = udp_hdr(skb)->source;
66739 +
66740 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66741 +}
66742 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66743 new file mode 100644
66744 index 0000000..25f54ef
66745 --- /dev/null
66746 +++ b/grsecurity/gracl_learn.c
66747 @@ -0,0 +1,207 @@
66748 +#include <linux/kernel.h>
66749 +#include <linux/mm.h>
66750 +#include <linux/sched.h>
66751 +#include <linux/poll.h>
66752 +#include <linux/string.h>
66753 +#include <linux/file.h>
66754 +#include <linux/types.h>
66755 +#include <linux/vmalloc.h>
66756 +#include <linux/grinternal.h>
66757 +
66758 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66759 + size_t count, loff_t *ppos);
66760 +extern int gr_acl_is_enabled(void);
66761 +
66762 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66763 +static int gr_learn_attached;
66764 +
66765 +/* use a 512k buffer */
66766 +#define LEARN_BUFFER_SIZE (512 * 1024)
66767 +
66768 +static DEFINE_SPINLOCK(gr_learn_lock);
66769 +static DEFINE_MUTEX(gr_learn_user_mutex);
66770 +
66771 +/* we need to maintain two buffers, so that the kernel context of grlearn
66772 + uses a semaphore around the userspace copying, and the other kernel contexts
66773 + use a spinlock when copying into the buffer, since they cannot sleep
66774 +*/
66775 +static char *learn_buffer;
66776 +static char *learn_buffer_user;
66777 +static int learn_buffer_len;
66778 +static int learn_buffer_user_len;
66779 +
66780 +static ssize_t
66781 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66782 +{
66783 + DECLARE_WAITQUEUE(wait, current);
66784 + ssize_t retval = 0;
66785 +
66786 + add_wait_queue(&learn_wait, &wait);
66787 + set_current_state(TASK_INTERRUPTIBLE);
66788 + do {
66789 + mutex_lock(&gr_learn_user_mutex);
66790 + spin_lock(&gr_learn_lock);
66791 + if (learn_buffer_len)
66792 + break;
66793 + spin_unlock(&gr_learn_lock);
66794 + mutex_unlock(&gr_learn_user_mutex);
66795 + if (file->f_flags & O_NONBLOCK) {
66796 + retval = -EAGAIN;
66797 + goto out;
66798 + }
66799 + if (signal_pending(current)) {
66800 + retval = -ERESTARTSYS;
66801 + goto out;
66802 + }
66803 +
66804 + schedule();
66805 + } while (1);
66806 +
66807 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66808 + learn_buffer_user_len = learn_buffer_len;
66809 + retval = learn_buffer_len;
66810 + learn_buffer_len = 0;
66811 +
66812 + spin_unlock(&gr_learn_lock);
66813 +
66814 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66815 + retval = -EFAULT;
66816 +
66817 + mutex_unlock(&gr_learn_user_mutex);
66818 +out:
66819 + set_current_state(TASK_RUNNING);
66820 + remove_wait_queue(&learn_wait, &wait);
66821 + return retval;
66822 +}
66823 +
66824 +static unsigned int
66825 +poll_learn(struct file * file, poll_table * wait)
66826 +{
66827 + poll_wait(file, &learn_wait, wait);
66828 +
66829 + if (learn_buffer_len)
66830 + return (POLLIN | POLLRDNORM);
66831 +
66832 + return 0;
66833 +}
66834 +
66835 +void
66836 +gr_clear_learn_entries(void)
66837 +{
66838 + char *tmp;
66839 +
66840 + mutex_lock(&gr_learn_user_mutex);
66841 + spin_lock(&gr_learn_lock);
66842 + tmp = learn_buffer;
66843 + learn_buffer = NULL;
66844 + spin_unlock(&gr_learn_lock);
66845 + if (tmp)
66846 + vfree(tmp);
66847 + if (learn_buffer_user != NULL) {
66848 + vfree(learn_buffer_user);
66849 + learn_buffer_user = NULL;
66850 + }
66851 + learn_buffer_len = 0;
66852 + mutex_unlock(&gr_learn_user_mutex);
66853 +
66854 + return;
66855 +}
66856 +
66857 +void
66858 +gr_add_learn_entry(const char *fmt, ...)
66859 +{
66860 + va_list args;
66861 + unsigned int len;
66862 +
66863 + if (!gr_learn_attached)
66864 + return;
66865 +
66866 + spin_lock(&gr_learn_lock);
66867 +
66868 + /* leave a gap at the end so we know when it's "full" but don't have to
66869 + compute the exact length of the string we're trying to append
66870 + */
66871 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
66872 + spin_unlock(&gr_learn_lock);
66873 + wake_up_interruptible(&learn_wait);
66874 + return;
66875 + }
66876 + if (learn_buffer == NULL) {
66877 + spin_unlock(&gr_learn_lock);
66878 + return;
66879 + }
66880 +
66881 + va_start(args, fmt);
66882 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
66883 + va_end(args);
66884 +
66885 + learn_buffer_len += len + 1;
66886 +
66887 + spin_unlock(&gr_learn_lock);
66888 + wake_up_interruptible(&learn_wait);
66889 +
66890 + return;
66891 +}
66892 +
66893 +static int
66894 +open_learn(struct inode *inode, struct file *file)
66895 +{
66896 + if (file->f_mode & FMODE_READ && gr_learn_attached)
66897 + return -EBUSY;
66898 + if (file->f_mode & FMODE_READ) {
66899 + int retval = 0;
66900 + mutex_lock(&gr_learn_user_mutex);
66901 + if (learn_buffer == NULL)
66902 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
66903 + if (learn_buffer_user == NULL)
66904 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
66905 + if (learn_buffer == NULL) {
66906 + retval = -ENOMEM;
66907 + goto out_error;
66908 + }
66909 + if (learn_buffer_user == NULL) {
66910 + retval = -ENOMEM;
66911 + goto out_error;
66912 + }
66913 + learn_buffer_len = 0;
66914 + learn_buffer_user_len = 0;
66915 + gr_learn_attached = 1;
66916 +out_error:
66917 + mutex_unlock(&gr_learn_user_mutex);
66918 + return retval;
66919 + }
66920 + return 0;
66921 +}
66922 +
66923 +static int
66924 +close_learn(struct inode *inode, struct file *file)
66925 +{
66926 + if (file->f_mode & FMODE_READ) {
66927 + char *tmp = NULL;
66928 + mutex_lock(&gr_learn_user_mutex);
66929 + spin_lock(&gr_learn_lock);
66930 + tmp = learn_buffer;
66931 + learn_buffer = NULL;
66932 + spin_unlock(&gr_learn_lock);
66933 + if (tmp)
66934 + vfree(tmp);
66935 + if (learn_buffer_user != NULL) {
66936 + vfree(learn_buffer_user);
66937 + learn_buffer_user = NULL;
66938 + }
66939 + learn_buffer_len = 0;
66940 + learn_buffer_user_len = 0;
66941 + gr_learn_attached = 0;
66942 + mutex_unlock(&gr_learn_user_mutex);
66943 + }
66944 +
66945 + return 0;
66946 +}
66947 +
66948 +const struct file_operations grsec_fops = {
66949 + .read = read_learn,
66950 + .write = write_grsec_handler,
66951 + .open = open_learn,
66952 + .release = close_learn,
66953 + .poll = poll_learn,
66954 +};
66955 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
66956 new file mode 100644
66957 index 0000000..36e293f
66958 --- /dev/null
66959 +++ b/grsecurity/gracl_policy.c
66960 @@ -0,0 +1,1777 @@
66961 +#include <linux/kernel.h>
66962 +#include <linux/module.h>
66963 +#include <linux/sched.h>
66964 +#include <linux/mm.h>
66965 +#include <linux/file.h>
66966 +#include <linux/fs.h>
66967 +#include <linux/namei.h>
66968 +#include <linux/mount.h>
66969 +#include <linux/tty.h>
66970 +#include <linux/proc_fs.h>
66971 +#include <linux/lglock.h>
66972 +#include <linux/slab.h>
66973 +#include <linux/vmalloc.h>
66974 +#include <linux/types.h>
66975 +#include <linux/sysctl.h>
66976 +#include <linux/netdevice.h>
66977 +#include <linux/ptrace.h>
66978 +#include <linux/gracl.h>
66979 +#include <linux/gralloc.h>
66980 +#include <linux/security.h>
66981 +#include <linux/grinternal.h>
66982 +#include <linux/pid_namespace.h>
66983 +#include <linux/stop_machine.h>
66984 +#include <linux/fdtable.h>
66985 +#include <linux/percpu.h>
66986 +#include <linux/lglock.h>
66987 +#include <linux/hugetlb.h>
66988 +#include <linux/posix-timers.h>
66989 +#include "../fs/mount.h"
66990 +
66991 +#include <asm/uaccess.h>
66992 +#include <asm/errno.h>
66993 +#include <asm/mman.h>
66994 +
66995 +extern struct gr_policy_state *polstate;
66996 +
66997 +#define FOR_EACH_ROLE_START(role) \
66998 + role = polstate->role_list; \
66999 + while (role) {
67000 +
67001 +#define FOR_EACH_ROLE_END(role) \
67002 + role = role->prev; \
67003 + }
67004 +
67005 +struct path gr_real_root;
67006 +
67007 +extern struct gr_alloc_state *current_alloc_state;
67008 +
67009 +u16 acl_sp_role_value;
67010 +
67011 +static DEFINE_MUTEX(gr_dev_mutex);
67012 +
67013 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
67014 +extern void gr_clear_learn_entries(void);
67015 +
67016 +static struct gr_arg gr_usermode;
67017 +static unsigned char gr_system_salt[GR_SALT_LEN];
67018 +static unsigned char gr_system_sum[GR_SHA_LEN];
67019 +
67020 +static unsigned int gr_auth_attempts = 0;
67021 +static unsigned long gr_auth_expires = 0UL;
67022 +
67023 +struct acl_object_label *fakefs_obj_rw;
67024 +struct acl_object_label *fakefs_obj_rwx;
67025 +
67026 +extern int gr_init_uidset(void);
67027 +extern void gr_free_uidset(void);
67028 +extern void gr_remove_uid(uid_t uid);
67029 +extern int gr_find_uid(uid_t uid);
67030 +
67031 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
67032 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
67033 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
67034 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
67035 +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);
67036 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
67037 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
67038 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
67039 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
67040 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67041 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67042 +extern void assign_special_role(const char *rolename);
67043 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
67044 +extern int gr_rbac_disable(void *unused);
67045 +extern void gr_enable_rbac_system(void);
67046 +
67047 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
67048 +{
67049 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
67050 + return -EFAULT;
67051 +
67052 + return 0;
67053 +}
67054 +
67055 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
67056 +{
67057 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
67058 + return -EFAULT;
67059 +
67060 + return 0;
67061 +}
67062 +
67063 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
67064 +{
67065 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
67066 + return -EFAULT;
67067 +
67068 + return 0;
67069 +}
67070 +
67071 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
67072 +{
67073 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
67074 + return -EFAULT;
67075 +
67076 + return 0;
67077 +}
67078 +
67079 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67080 +{
67081 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
67082 + return -EFAULT;
67083 +
67084 + return 0;
67085 +}
67086 +
67087 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67088 +{
67089 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
67090 + return -EFAULT;
67091 +
67092 + return 0;
67093 +}
67094 +
67095 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
67096 +{
67097 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
67098 + return -EFAULT;
67099 +
67100 + return 0;
67101 +}
67102 +
67103 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
67104 +{
67105 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
67106 + return -EFAULT;
67107 +
67108 + return 0;
67109 +}
67110 +
67111 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
67112 +{
67113 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
67114 + return -EFAULT;
67115 +
67116 + return 0;
67117 +}
67118 +
67119 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
67120 +{
67121 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
67122 + return -EFAULT;
67123 +
67124 + if (((uwrap->version != GRSECURITY_VERSION) &&
67125 + (uwrap->version != 0x2901)) ||
67126 + (uwrap->size != sizeof(struct gr_arg)))
67127 + return -EINVAL;
67128 +
67129 + return 0;
67130 +}
67131 +
67132 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
67133 +{
67134 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
67135 + return -EFAULT;
67136 +
67137 + return 0;
67138 +}
67139 +
67140 +static size_t get_gr_arg_wrapper_size_normal(void)
67141 +{
67142 + return sizeof(struct gr_arg_wrapper);
67143 +}
67144 +
67145 +#ifdef CONFIG_COMPAT
67146 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
67147 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
67148 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
67149 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
67150 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
67151 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
67152 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
67153 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
67154 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
67155 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
67156 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
67157 +extern size_t get_gr_arg_wrapper_size_compat(void);
67158 +
67159 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
67160 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
67161 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
67162 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
67163 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
67164 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
67165 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
67166 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
67167 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
67168 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
67169 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
67170 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
67171 +
67172 +#else
67173 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
67174 +#define copy_gr_arg copy_gr_arg_normal
67175 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
67176 +#define copy_acl_object_label copy_acl_object_label_normal
67177 +#define copy_acl_subject_label copy_acl_subject_label_normal
67178 +#define copy_acl_role_label copy_acl_role_label_normal
67179 +#define copy_acl_ip_label copy_acl_ip_label_normal
67180 +#define copy_pointer_from_array copy_pointer_from_array_normal
67181 +#define copy_sprole_pw copy_sprole_pw_normal
67182 +#define copy_role_transition copy_role_transition_normal
67183 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
67184 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
67185 +#endif
67186 +
67187 +static struct acl_subject_label *
67188 +lookup_subject_map(const struct acl_subject_label *userp)
67189 +{
67190 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
67191 + struct subject_map *match;
67192 +
67193 + match = polstate->subj_map_set.s_hash[index];
67194 +
67195 + while (match && match->user != userp)
67196 + match = match->next;
67197 +
67198 + if (match != NULL)
67199 + return match->kernel;
67200 + else
67201 + return NULL;
67202 +}
67203 +
67204 +static void
67205 +insert_subj_map_entry(struct subject_map *subjmap)
67206 +{
67207 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
67208 + struct subject_map **curr;
67209 +
67210 + subjmap->prev = NULL;
67211 +
67212 + curr = &polstate->subj_map_set.s_hash[index];
67213 + if (*curr != NULL)
67214 + (*curr)->prev = subjmap;
67215 +
67216 + subjmap->next = *curr;
67217 + *curr = subjmap;
67218 +
67219 + return;
67220 +}
67221 +
67222 +static void
67223 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
67224 +{
67225 + unsigned int index =
67226 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
67227 + struct acl_role_label **curr;
67228 + struct acl_role_label *tmp, *tmp2;
67229 +
67230 + curr = &polstate->acl_role_set.r_hash[index];
67231 +
67232 + /* simple case, slot is empty, just set it to our role */
67233 + if (*curr == NULL) {
67234 + *curr = role;
67235 + } else {
67236 + /* example:
67237 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
67238 + 2 -> 3
67239 + */
67240 + /* first check to see if we can already be reached via this slot */
67241 + tmp = *curr;
67242 + while (tmp && tmp != role)
67243 + tmp = tmp->next;
67244 + if (tmp == role) {
67245 + /* we don't need to add ourselves to this slot's chain */
67246 + return;
67247 + }
67248 + /* we need to add ourselves to this chain, two cases */
67249 + if (role->next == NULL) {
67250 + /* simple case, append the current chain to our role */
67251 + role->next = *curr;
67252 + *curr = role;
67253 + } else {
67254 + /* 1 -> 2 -> 3 -> 4
67255 + 2 -> 3 -> 4
67256 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
67257 + */
67258 + /* trickier case: walk our role's chain until we find
67259 + the role for the start of the current slot's chain */
67260 + tmp = role;
67261 + tmp2 = *curr;
67262 + while (tmp->next && tmp->next != tmp2)
67263 + tmp = tmp->next;
67264 + if (tmp->next == tmp2) {
67265 + /* from example above, we found 3, so just
67266 + replace this slot's chain with ours */
67267 + *curr = role;
67268 + } else {
67269 + /* we didn't find a subset of our role's chain
67270 + in the current slot's chain, so append their
67271 + chain to ours, and set us as the first role in
67272 + the slot's chain
67273 +
67274 + we could fold this case with the case above,
67275 + but making it explicit for clarity
67276 + */
67277 + tmp->next = tmp2;
67278 + *curr = role;
67279 + }
67280 + }
67281 + }
67282 +
67283 + return;
67284 +}
67285 +
67286 +static void
67287 +insert_acl_role_label(struct acl_role_label *role)
67288 +{
67289 + int i;
67290 +
67291 + if (polstate->role_list == NULL) {
67292 + polstate->role_list = role;
67293 + role->prev = NULL;
67294 + } else {
67295 + role->prev = polstate->role_list;
67296 + polstate->role_list = role;
67297 + }
67298 +
67299 + /* used for hash chains */
67300 + role->next = NULL;
67301 +
67302 + if (role->roletype & GR_ROLE_DOMAIN) {
67303 + for (i = 0; i < role->domain_child_num; i++)
67304 + __insert_acl_role_label(role, role->domain_children[i]);
67305 + } else
67306 + __insert_acl_role_label(role, role->uidgid);
67307 +}
67308 +
67309 +static int
67310 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
67311 +{
67312 + struct name_entry **curr, *nentry;
67313 + struct inodev_entry *ientry;
67314 + unsigned int len = strlen(name);
67315 + unsigned int key = full_name_hash(name, len);
67316 + unsigned int index = key % polstate->name_set.n_size;
67317 +
67318 + curr = &polstate->name_set.n_hash[index];
67319 +
67320 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
67321 + curr = &((*curr)->next);
67322 +
67323 + if (*curr != NULL)
67324 + return 1;
67325 +
67326 + nentry = acl_alloc(sizeof (struct name_entry));
67327 + if (nentry == NULL)
67328 + return 0;
67329 + ientry = acl_alloc(sizeof (struct inodev_entry));
67330 + if (ientry == NULL)
67331 + return 0;
67332 + ientry->nentry = nentry;
67333 +
67334 + nentry->key = key;
67335 + nentry->name = name;
67336 + nentry->inode = inode;
67337 + nentry->device = device;
67338 + nentry->len = len;
67339 + nentry->deleted = deleted;
67340 +
67341 + nentry->prev = NULL;
67342 + curr = &polstate->name_set.n_hash[index];
67343 + if (*curr != NULL)
67344 + (*curr)->prev = nentry;
67345 + nentry->next = *curr;
67346 + *curr = nentry;
67347 +
67348 + /* insert us into the table searchable by inode/dev */
67349 + __insert_inodev_entry(polstate, ientry);
67350 +
67351 + return 1;
67352 +}
67353 +
67354 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
67355 +
67356 +static void *
67357 +create_table(__u32 * len, int elementsize)
67358 +{
67359 + unsigned int table_sizes[] = {
67360 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
67361 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
67362 + 4194301, 8388593, 16777213, 33554393, 67108859
67363 + };
67364 + void *newtable = NULL;
67365 + unsigned int pwr = 0;
67366 +
67367 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
67368 + table_sizes[pwr] <= *len)
67369 + pwr++;
67370 +
67371 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
67372 + return newtable;
67373 +
67374 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
67375 + newtable =
67376 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
67377 + else
67378 + newtable = vmalloc(table_sizes[pwr] * elementsize);
67379 +
67380 + *len = table_sizes[pwr];
67381 +
67382 + return newtable;
67383 +}
67384 +
67385 +static int
67386 +init_variables(const struct gr_arg *arg, bool reload)
67387 +{
67388 + struct task_struct *reaper = init_pid_ns.child_reaper;
67389 + unsigned int stacksize;
67390 +
67391 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
67392 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
67393 + polstate->name_set.n_size = arg->role_db.num_objects;
67394 + polstate->inodev_set.i_size = arg->role_db.num_objects;
67395 +
67396 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
67397 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
67398 + return 1;
67399 +
67400 + if (!reload) {
67401 + if (!gr_init_uidset())
67402 + return 1;
67403 + }
67404 +
67405 + /* set up the stack that holds allocation info */
67406 +
67407 + stacksize = arg->role_db.num_pointers + 5;
67408 +
67409 + if (!acl_alloc_stack_init(stacksize))
67410 + return 1;
67411 +
67412 + if (!reload) {
67413 + /* grab reference for the real root dentry and vfsmount */
67414 + get_fs_root(reaper->fs, &gr_real_root);
67415 +
67416 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67417 + 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);
67418 +#endif
67419 +
67420 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
67421 + if (fakefs_obj_rw == NULL)
67422 + return 1;
67423 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
67424 +
67425 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
67426 + if (fakefs_obj_rwx == NULL)
67427 + return 1;
67428 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
67429 + }
67430 +
67431 + polstate->subj_map_set.s_hash =
67432 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
67433 + polstate->acl_role_set.r_hash =
67434 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
67435 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
67436 + polstate->inodev_set.i_hash =
67437 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
67438 +
67439 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
67440 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
67441 + return 1;
67442 +
67443 + memset(polstate->subj_map_set.s_hash, 0,
67444 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
67445 + memset(polstate->acl_role_set.r_hash, 0,
67446 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
67447 + memset(polstate->name_set.n_hash, 0,
67448 + sizeof (struct name_entry *) * polstate->name_set.n_size);
67449 + memset(polstate->inodev_set.i_hash, 0,
67450 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
67451 +
67452 + return 0;
67453 +}
67454 +
67455 +/* free information not needed after startup
67456 + currently contains user->kernel pointer mappings for subjects
67457 +*/
67458 +
67459 +static void
67460 +free_init_variables(void)
67461 +{
67462 + __u32 i;
67463 +
67464 + if (polstate->subj_map_set.s_hash) {
67465 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
67466 + if (polstate->subj_map_set.s_hash[i]) {
67467 + kfree(polstate->subj_map_set.s_hash[i]);
67468 + polstate->subj_map_set.s_hash[i] = NULL;
67469 + }
67470 + }
67471 +
67472 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
67473 + PAGE_SIZE)
67474 + kfree(polstate->subj_map_set.s_hash);
67475 + else
67476 + vfree(polstate->subj_map_set.s_hash);
67477 + }
67478 +
67479 + return;
67480 +}
67481 +
67482 +static void
67483 +free_variables(bool reload)
67484 +{
67485 + struct acl_subject_label *s;
67486 + struct acl_role_label *r;
67487 + struct task_struct *task, *task2;
67488 + unsigned int x;
67489 +
67490 + if (!reload) {
67491 + gr_clear_learn_entries();
67492 +
67493 + read_lock(&tasklist_lock);
67494 + do_each_thread(task2, task) {
67495 + task->acl_sp_role = 0;
67496 + task->acl_role_id = 0;
67497 + task->inherited = 0;
67498 + task->acl = NULL;
67499 + task->role = NULL;
67500 + } while_each_thread(task2, task);
67501 + read_unlock(&tasklist_lock);
67502 +
67503 + /* release the reference to the real root dentry and vfsmount */
67504 + path_put(&gr_real_root);
67505 + memset(&gr_real_root, 0, sizeof(gr_real_root));
67506 + }
67507 +
67508 + /* free all object hash tables */
67509 +
67510 + FOR_EACH_ROLE_START(r)
67511 + if (r->subj_hash == NULL)
67512 + goto next_role;
67513 + FOR_EACH_SUBJECT_START(r, s, x)
67514 + if (s->obj_hash == NULL)
67515 + break;
67516 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67517 + kfree(s->obj_hash);
67518 + else
67519 + vfree(s->obj_hash);
67520 + FOR_EACH_SUBJECT_END(s, x)
67521 + FOR_EACH_NESTED_SUBJECT_START(r, s)
67522 + if (s->obj_hash == NULL)
67523 + break;
67524 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67525 + kfree(s->obj_hash);
67526 + else
67527 + vfree(s->obj_hash);
67528 + FOR_EACH_NESTED_SUBJECT_END(s)
67529 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
67530 + kfree(r->subj_hash);
67531 + else
67532 + vfree(r->subj_hash);
67533 + r->subj_hash = NULL;
67534 +next_role:
67535 + FOR_EACH_ROLE_END(r)
67536 +
67537 + acl_free_all();
67538 +
67539 + if (polstate->acl_role_set.r_hash) {
67540 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
67541 + PAGE_SIZE)
67542 + kfree(polstate->acl_role_set.r_hash);
67543 + else
67544 + vfree(polstate->acl_role_set.r_hash);
67545 + }
67546 + if (polstate->name_set.n_hash) {
67547 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
67548 + PAGE_SIZE)
67549 + kfree(polstate->name_set.n_hash);
67550 + else
67551 + vfree(polstate->name_set.n_hash);
67552 + }
67553 +
67554 + if (polstate->inodev_set.i_hash) {
67555 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
67556 + PAGE_SIZE)
67557 + kfree(polstate->inodev_set.i_hash);
67558 + else
67559 + vfree(polstate->inodev_set.i_hash);
67560 + }
67561 +
67562 + if (!reload)
67563 + gr_free_uidset();
67564 +
67565 + memset(&polstate->name_set, 0, sizeof (struct name_db));
67566 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
67567 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
67568 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
67569 +
67570 + polstate->default_role = NULL;
67571 + polstate->kernel_role = NULL;
67572 + polstate->role_list = NULL;
67573 +
67574 + return;
67575 +}
67576 +
67577 +static struct acl_subject_label *
67578 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
67579 +
67580 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
67581 +{
67582 + unsigned int len = strnlen_user(*name, maxlen);
67583 + char *tmp;
67584 +
67585 + if (!len || len >= maxlen)
67586 + return -EINVAL;
67587 +
67588 + if ((tmp = (char *) acl_alloc(len)) == NULL)
67589 + return -ENOMEM;
67590 +
67591 + if (copy_from_user(tmp, *name, len))
67592 + return -EFAULT;
67593 +
67594 + tmp[len-1] = '\0';
67595 + *name = tmp;
67596 +
67597 + return 0;
67598 +}
67599 +
67600 +static int
67601 +copy_user_glob(struct acl_object_label *obj)
67602 +{
67603 + struct acl_object_label *g_tmp, **guser;
67604 + int error;
67605 +
67606 + if (obj->globbed == NULL)
67607 + return 0;
67608 +
67609 + guser = &obj->globbed;
67610 + while (*guser) {
67611 + g_tmp = (struct acl_object_label *)
67612 + acl_alloc(sizeof (struct acl_object_label));
67613 + if (g_tmp == NULL)
67614 + return -ENOMEM;
67615 +
67616 + if (copy_acl_object_label(g_tmp, *guser))
67617 + return -EFAULT;
67618 +
67619 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
67620 + if (error)
67621 + return error;
67622 +
67623 + *guser = g_tmp;
67624 + guser = &(g_tmp->next);
67625 + }
67626 +
67627 + return 0;
67628 +}
67629 +
67630 +static int
67631 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
67632 + struct acl_role_label *role)
67633 +{
67634 + struct acl_object_label *o_tmp;
67635 + int ret;
67636 +
67637 + while (userp) {
67638 + if ((o_tmp = (struct acl_object_label *)
67639 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
67640 + return -ENOMEM;
67641 +
67642 + if (copy_acl_object_label(o_tmp, userp))
67643 + return -EFAULT;
67644 +
67645 + userp = o_tmp->prev;
67646 +
67647 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
67648 + if (ret)
67649 + return ret;
67650 +
67651 + insert_acl_obj_label(o_tmp, subj);
67652 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
67653 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
67654 + return -ENOMEM;
67655 +
67656 + ret = copy_user_glob(o_tmp);
67657 + if (ret)
67658 + return ret;
67659 +
67660 + if (o_tmp->nested) {
67661 + int already_copied;
67662 +
67663 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
67664 + if (IS_ERR(o_tmp->nested))
67665 + return PTR_ERR(o_tmp->nested);
67666 +
67667 + /* insert into nested subject list if we haven't copied this one yet
67668 + to prevent duplicate entries */
67669 + if (!already_copied) {
67670 + o_tmp->nested->next = role->hash->first;
67671 + role->hash->first = o_tmp->nested;
67672 + }
67673 + }
67674 + }
67675 +
67676 + return 0;
67677 +}
67678 +
67679 +static __u32
67680 +count_user_subjs(struct acl_subject_label *userp)
67681 +{
67682 + struct acl_subject_label s_tmp;
67683 + __u32 num = 0;
67684 +
67685 + while (userp) {
67686 + if (copy_acl_subject_label(&s_tmp, userp))
67687 + break;
67688 +
67689 + userp = s_tmp.prev;
67690 + }
67691 +
67692 + return num;
67693 +}
67694 +
67695 +static int
67696 +copy_user_allowedips(struct acl_role_label *rolep)
67697 +{
67698 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
67699 +
67700 + ruserip = rolep->allowed_ips;
67701 +
67702 + while (ruserip) {
67703 + rlast = rtmp;
67704 +
67705 + if ((rtmp = (struct role_allowed_ip *)
67706 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
67707 + return -ENOMEM;
67708 +
67709 + if (copy_role_allowed_ip(rtmp, ruserip))
67710 + return -EFAULT;
67711 +
67712 + ruserip = rtmp->prev;
67713 +
67714 + if (!rlast) {
67715 + rtmp->prev = NULL;
67716 + rolep->allowed_ips = rtmp;
67717 + } else {
67718 + rlast->next = rtmp;
67719 + rtmp->prev = rlast;
67720 + }
67721 +
67722 + if (!ruserip)
67723 + rtmp->next = NULL;
67724 + }
67725 +
67726 + return 0;
67727 +}
67728 +
67729 +static int
67730 +copy_user_transitions(struct acl_role_label *rolep)
67731 +{
67732 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
67733 + int error;
67734 +
67735 + rusertp = rolep->transitions;
67736 +
67737 + while (rusertp) {
67738 + rlast = rtmp;
67739 +
67740 + if ((rtmp = (struct role_transition *)
67741 + acl_alloc(sizeof (struct role_transition))) == NULL)
67742 + return -ENOMEM;
67743 +
67744 + if (copy_role_transition(rtmp, rusertp))
67745 + return -EFAULT;
67746 +
67747 + rusertp = rtmp->prev;
67748 +
67749 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
67750 + if (error)
67751 + return error;
67752 +
67753 + if (!rlast) {
67754 + rtmp->prev = NULL;
67755 + rolep->transitions = rtmp;
67756 + } else {
67757 + rlast->next = rtmp;
67758 + rtmp->prev = rlast;
67759 + }
67760 +
67761 + if (!rusertp)
67762 + rtmp->next = NULL;
67763 + }
67764 +
67765 + return 0;
67766 +}
67767 +
67768 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
67769 +{
67770 + struct acl_object_label o_tmp;
67771 + __u32 num = 0;
67772 +
67773 + while (userp) {
67774 + if (copy_acl_object_label(&o_tmp, userp))
67775 + break;
67776 +
67777 + userp = o_tmp.prev;
67778 + num++;
67779 + }
67780 +
67781 + return num;
67782 +}
67783 +
67784 +static struct acl_subject_label *
67785 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
67786 +{
67787 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
67788 + __u32 num_objs;
67789 + struct acl_ip_label **i_tmp, *i_utmp2;
67790 + struct gr_hash_struct ghash;
67791 + struct subject_map *subjmap;
67792 + unsigned int i_num;
67793 + int err;
67794 +
67795 + if (already_copied != NULL)
67796 + *already_copied = 0;
67797 +
67798 + s_tmp = lookup_subject_map(userp);
67799 +
67800 + /* we've already copied this subject into the kernel, just return
67801 + the reference to it, and don't copy it over again
67802 + */
67803 + if (s_tmp) {
67804 + if (already_copied != NULL)
67805 + *already_copied = 1;
67806 + return(s_tmp);
67807 + }
67808 +
67809 + if ((s_tmp = (struct acl_subject_label *)
67810 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
67811 + return ERR_PTR(-ENOMEM);
67812 +
67813 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
67814 + if (subjmap == NULL)
67815 + return ERR_PTR(-ENOMEM);
67816 +
67817 + subjmap->user = userp;
67818 + subjmap->kernel = s_tmp;
67819 + insert_subj_map_entry(subjmap);
67820 +
67821 + if (copy_acl_subject_label(s_tmp, userp))
67822 + return ERR_PTR(-EFAULT);
67823 +
67824 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
67825 + if (err)
67826 + return ERR_PTR(err);
67827 +
67828 + if (!strcmp(s_tmp->filename, "/"))
67829 + role->root_label = s_tmp;
67830 +
67831 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
67832 + return ERR_PTR(-EFAULT);
67833 +
67834 + /* copy user and group transition tables */
67835 +
67836 + if (s_tmp->user_trans_num) {
67837 + uid_t *uidlist;
67838 +
67839 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
67840 + if (uidlist == NULL)
67841 + return ERR_PTR(-ENOMEM);
67842 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
67843 + return ERR_PTR(-EFAULT);
67844 +
67845 + s_tmp->user_transitions = uidlist;
67846 + }
67847 +
67848 + if (s_tmp->group_trans_num) {
67849 + gid_t *gidlist;
67850 +
67851 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
67852 + if (gidlist == NULL)
67853 + return ERR_PTR(-ENOMEM);
67854 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
67855 + return ERR_PTR(-EFAULT);
67856 +
67857 + s_tmp->group_transitions = gidlist;
67858 + }
67859 +
67860 + /* set up object hash table */
67861 + num_objs = count_user_objs(ghash.first);
67862 +
67863 + s_tmp->obj_hash_size = num_objs;
67864 + s_tmp->obj_hash =
67865 + (struct acl_object_label **)
67866 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
67867 +
67868 + if (!s_tmp->obj_hash)
67869 + return ERR_PTR(-ENOMEM);
67870 +
67871 + memset(s_tmp->obj_hash, 0,
67872 + s_tmp->obj_hash_size *
67873 + sizeof (struct acl_object_label *));
67874 +
67875 + /* add in objects */
67876 + err = copy_user_objs(ghash.first, s_tmp, role);
67877 +
67878 + if (err)
67879 + return ERR_PTR(err);
67880 +
67881 + /* set pointer for parent subject */
67882 + if (s_tmp->parent_subject) {
67883 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
67884 +
67885 + if (IS_ERR(s_tmp2))
67886 + return s_tmp2;
67887 +
67888 + s_tmp->parent_subject = s_tmp2;
67889 + }
67890 +
67891 + /* add in ip acls */
67892 +
67893 + if (!s_tmp->ip_num) {
67894 + s_tmp->ips = NULL;
67895 + goto insert;
67896 + }
67897 +
67898 + i_tmp =
67899 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
67900 + sizeof (struct acl_ip_label *));
67901 +
67902 + if (!i_tmp)
67903 + return ERR_PTR(-ENOMEM);
67904 +
67905 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
67906 + *(i_tmp + i_num) =
67907 + (struct acl_ip_label *)
67908 + acl_alloc(sizeof (struct acl_ip_label));
67909 + if (!*(i_tmp + i_num))
67910 + return ERR_PTR(-ENOMEM);
67911 +
67912 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
67913 + return ERR_PTR(-EFAULT);
67914 +
67915 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
67916 + return ERR_PTR(-EFAULT);
67917 +
67918 + if ((*(i_tmp + i_num))->iface == NULL)
67919 + continue;
67920 +
67921 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
67922 + if (err)
67923 + return ERR_PTR(err);
67924 + }
67925 +
67926 + s_tmp->ips = i_tmp;
67927 +
67928 +insert:
67929 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
67930 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
67931 + return ERR_PTR(-ENOMEM);
67932 +
67933 + return s_tmp;
67934 +}
67935 +
67936 +static int
67937 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
67938 +{
67939 + struct acl_subject_label s_pre;
67940 + struct acl_subject_label * ret;
67941 + int err;
67942 +
67943 + while (userp) {
67944 + if (copy_acl_subject_label(&s_pre, userp))
67945 + return -EFAULT;
67946 +
67947 + ret = do_copy_user_subj(userp, role, NULL);
67948 +
67949 + err = PTR_ERR(ret);
67950 + if (IS_ERR(ret))
67951 + return err;
67952 +
67953 + insert_acl_subj_label(ret, role);
67954 +
67955 + userp = s_pre.prev;
67956 + }
67957 +
67958 + return 0;
67959 +}
67960 +
67961 +static int
67962 +copy_user_acl(struct gr_arg *arg)
67963 +{
67964 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
67965 + struct acl_subject_label *subj_list;
67966 + struct sprole_pw *sptmp;
67967 + struct gr_hash_struct *ghash;
67968 + uid_t *domainlist;
67969 + unsigned int r_num;
67970 + int err = 0;
67971 + __u16 i;
67972 + __u32 num_subjs;
67973 +
67974 + /* we need a default and kernel role */
67975 + if (arg->role_db.num_roles < 2)
67976 + return -EINVAL;
67977 +
67978 + /* copy special role authentication info from userspace */
67979 +
67980 + polstate->num_sprole_pws = arg->num_sprole_pws;
67981 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
67982 +
67983 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
67984 + return -ENOMEM;
67985 +
67986 + for (i = 0; i < polstate->num_sprole_pws; i++) {
67987 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
67988 + if (!sptmp)
67989 + return -ENOMEM;
67990 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
67991 + return -EFAULT;
67992 +
67993 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
67994 + if (err)
67995 + return err;
67996 +
67997 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67998 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
67999 +#endif
68000 +
68001 + polstate->acl_special_roles[i] = sptmp;
68002 + }
68003 +
68004 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
68005 +
68006 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
68007 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
68008 +
68009 + if (!r_tmp)
68010 + return -ENOMEM;
68011 +
68012 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
68013 + return -EFAULT;
68014 +
68015 + if (copy_acl_role_label(r_tmp, r_utmp2))
68016 + return -EFAULT;
68017 +
68018 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
68019 + if (err)
68020 + return err;
68021 +
68022 + if (!strcmp(r_tmp->rolename, "default")
68023 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
68024 + polstate->default_role = r_tmp;
68025 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
68026 + polstate->kernel_role = r_tmp;
68027 + }
68028 +
68029 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
68030 + return -ENOMEM;
68031 +
68032 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
68033 + return -EFAULT;
68034 +
68035 + r_tmp->hash = ghash;
68036 +
68037 + num_subjs = count_user_subjs(r_tmp->hash->first);
68038 +
68039 + r_tmp->subj_hash_size = num_subjs;
68040 + r_tmp->subj_hash =
68041 + (struct acl_subject_label **)
68042 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
68043 +
68044 + if (!r_tmp->subj_hash)
68045 + return -ENOMEM;
68046 +
68047 + err = copy_user_allowedips(r_tmp);
68048 + if (err)
68049 + return err;
68050 +
68051 + /* copy domain info */
68052 + if (r_tmp->domain_children != NULL) {
68053 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
68054 + if (domainlist == NULL)
68055 + return -ENOMEM;
68056 +
68057 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
68058 + return -EFAULT;
68059 +
68060 + r_tmp->domain_children = domainlist;
68061 + }
68062 +
68063 + err = copy_user_transitions(r_tmp);
68064 + if (err)
68065 + return err;
68066 +
68067 + memset(r_tmp->subj_hash, 0,
68068 + r_tmp->subj_hash_size *
68069 + sizeof (struct acl_subject_label *));
68070 +
68071 + /* acquire the list of subjects, then NULL out
68072 + the list prior to parsing the subjects for this role,
68073 + as during this parsing the list is replaced with a list
68074 + of *nested* subjects for the role
68075 + */
68076 + subj_list = r_tmp->hash->first;
68077 +
68078 + /* set nested subject list to null */
68079 + r_tmp->hash->first = NULL;
68080 +
68081 + err = copy_user_subjs(subj_list, r_tmp);
68082 +
68083 + if (err)
68084 + return err;
68085 +
68086 + insert_acl_role_label(r_tmp);
68087 + }
68088 +
68089 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
68090 + return -EINVAL;
68091 +
68092 + return err;
68093 +}
68094 +
68095 +static int gracl_reload_apply_policies(void *reload)
68096 +{
68097 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
68098 + struct task_struct *task, *task2;
68099 + struct acl_role_label *role, *rtmp;
68100 + struct acl_subject_label *subj;
68101 + const struct cred *cred;
68102 + int role_applied;
68103 + int ret = 0;
68104 +
68105 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
68106 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
68107 +
68108 + /* first make sure we'll be able to apply the new policy cleanly */
68109 + do_each_thread(task2, task) {
68110 + if (task->exec_file == NULL)
68111 + continue;
68112 + role_applied = 0;
68113 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68114 + /* preserve special roles */
68115 + FOR_EACH_ROLE_START(role)
68116 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68117 + rtmp = task->role;
68118 + task->role = role;
68119 + role_applied = 1;
68120 + break;
68121 + }
68122 + FOR_EACH_ROLE_END(role)
68123 + }
68124 + if (!role_applied) {
68125 + cred = __task_cred(task);
68126 + rtmp = task->role;
68127 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68128 + }
68129 + /* this handles non-nested inherited subjects, nested subjects will still
68130 + be dropped currently */
68131 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
68132 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
68133 + /* change the role back so that we've made no modifications to the policy */
68134 + task->role = rtmp;
68135 +
68136 + if (subj == NULL || task->tmpacl == NULL) {
68137 + ret = -EINVAL;
68138 + goto out;
68139 + }
68140 + } while_each_thread(task2, task);
68141 +
68142 + /* now actually apply the policy */
68143 +
68144 + do_each_thread(task2, task) {
68145 + if (task->exec_file) {
68146 + role_applied = 0;
68147 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68148 + /* preserve special roles */
68149 + FOR_EACH_ROLE_START(role)
68150 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68151 + task->role = role;
68152 + role_applied = 1;
68153 + break;
68154 + }
68155 + FOR_EACH_ROLE_END(role)
68156 + }
68157 + if (!role_applied) {
68158 + cred = __task_cred(task);
68159 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68160 + }
68161 + /* this handles non-nested inherited subjects, nested subjects will still
68162 + be dropped currently */
68163 + if (!reload_state->oldmode && task->inherited)
68164 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
68165 + else {
68166 + /* looked up and tagged to the task previously */
68167 + subj = task->tmpacl;
68168 + }
68169 + /* subj will be non-null */
68170 + __gr_apply_subject_to_task(polstate, task, subj);
68171 + if (reload_state->oldmode) {
68172 + task->acl_role_id = 0;
68173 + task->acl_sp_role = 0;
68174 + task->inherited = 0;
68175 + }
68176 + } else {
68177 + // it's a kernel process
68178 + task->role = polstate->kernel_role;
68179 + task->acl = polstate->kernel_role->root_label;
68180 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68181 + task->acl->mode &= ~GR_PROCFIND;
68182 +#endif
68183 + }
68184 + } while_each_thread(task2, task);
68185 +
68186 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
68187 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
68188 +
68189 +out:
68190 +
68191 + return ret;
68192 +}
68193 +
68194 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
68195 +{
68196 + struct gr_reload_state new_reload_state = { };
68197 + int err;
68198 +
68199 + new_reload_state.oldpolicy_ptr = polstate;
68200 + new_reload_state.oldalloc_ptr = current_alloc_state;
68201 + new_reload_state.oldmode = oldmode;
68202 +
68203 + current_alloc_state = &new_reload_state.newalloc;
68204 + polstate = &new_reload_state.newpolicy;
68205 +
68206 + /* everything relevant is now saved off, copy in the new policy */
68207 + if (init_variables(args, true)) {
68208 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68209 + err = -ENOMEM;
68210 + goto error;
68211 + }
68212 +
68213 + err = copy_user_acl(args);
68214 + free_init_variables();
68215 + if (err)
68216 + goto error;
68217 + /* the new policy is copied in, with the old policy available via saved_state
68218 + first go through applying roles, making sure to preserve special roles
68219 + then apply new subjects, making sure to preserve inherited and nested subjects,
68220 + though currently only inherited subjects will be preserved
68221 + */
68222 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
68223 + if (err)
68224 + goto error;
68225 +
68226 + /* we've now applied the new policy, so restore the old policy state to free it */
68227 + polstate = &new_reload_state.oldpolicy;
68228 + current_alloc_state = &new_reload_state.oldalloc;
68229 + free_variables(true);
68230 +
68231 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
68232 + to running_polstate/current_alloc_state inside stop_machine
68233 + */
68234 + err = 0;
68235 + goto out;
68236 +error:
68237 + /* on error of loading the new policy, we'll just keep the previous
68238 + policy set around
68239 + */
68240 + free_variables(true);
68241 +
68242 + /* doesn't affect runtime, but maintains consistent state */
68243 +out:
68244 + polstate = new_reload_state.oldpolicy_ptr;
68245 + current_alloc_state = new_reload_state.oldalloc_ptr;
68246 +
68247 + return err;
68248 +}
68249 +
68250 +static int
68251 +gracl_init(struct gr_arg *args)
68252 +{
68253 + int error = 0;
68254 +
68255 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
68256 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
68257 +
68258 + if (init_variables(args, false)) {
68259 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68260 + error = -ENOMEM;
68261 + goto out;
68262 + }
68263 +
68264 + error = copy_user_acl(args);
68265 + free_init_variables();
68266 + if (error)
68267 + goto out;
68268 +
68269 + error = gr_set_acls(0);
68270 + if (error)
68271 + goto out;
68272 +
68273 + gr_enable_rbac_system();
68274 +
68275 + return 0;
68276 +
68277 +out:
68278 + free_variables(false);
68279 + return error;
68280 +}
68281 +
68282 +static int
68283 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
68284 + unsigned char **sum)
68285 +{
68286 + struct acl_role_label *r;
68287 + struct role_allowed_ip *ipp;
68288 + struct role_transition *trans;
68289 + unsigned int i;
68290 + int found = 0;
68291 + u32 curr_ip = current->signal->curr_ip;
68292 +
68293 + current->signal->saved_ip = curr_ip;
68294 +
68295 + /* check transition table */
68296 +
68297 + for (trans = current->role->transitions; trans; trans = trans->next) {
68298 + if (!strcmp(rolename, trans->rolename)) {
68299 + found = 1;
68300 + break;
68301 + }
68302 + }
68303 +
68304 + if (!found)
68305 + return 0;
68306 +
68307 + /* handle special roles that do not require authentication
68308 + and check ip */
68309 +
68310 + FOR_EACH_ROLE_START(r)
68311 + if (!strcmp(rolename, r->rolename) &&
68312 + (r->roletype & GR_ROLE_SPECIAL)) {
68313 + found = 0;
68314 + if (r->allowed_ips != NULL) {
68315 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
68316 + if ((ntohl(curr_ip) & ipp->netmask) ==
68317 + (ntohl(ipp->addr) & ipp->netmask))
68318 + found = 1;
68319 + }
68320 + } else
68321 + found = 2;
68322 + if (!found)
68323 + return 0;
68324 +
68325 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
68326 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
68327 + *salt = NULL;
68328 + *sum = NULL;
68329 + return 1;
68330 + }
68331 + }
68332 + FOR_EACH_ROLE_END(r)
68333 +
68334 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68335 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
68336 + *salt = polstate->acl_special_roles[i]->salt;
68337 + *sum = polstate->acl_special_roles[i]->sum;
68338 + return 1;
68339 + }
68340 + }
68341 +
68342 + return 0;
68343 +}
68344 +
68345 +int gr_check_secure_terminal(struct task_struct *task)
68346 +{
68347 + struct task_struct *p, *p2, *p3;
68348 + struct files_struct *files;
68349 + struct fdtable *fdt;
68350 + struct file *our_file = NULL, *file;
68351 + int i;
68352 +
68353 + if (task->signal->tty == NULL)
68354 + return 1;
68355 +
68356 + files = get_files_struct(task);
68357 + if (files != NULL) {
68358 + rcu_read_lock();
68359 + fdt = files_fdtable(files);
68360 + for (i=0; i < fdt->max_fds; i++) {
68361 + file = fcheck_files(files, i);
68362 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
68363 + get_file(file);
68364 + our_file = file;
68365 + }
68366 + }
68367 + rcu_read_unlock();
68368 + put_files_struct(files);
68369 + }
68370 +
68371 + if (our_file == NULL)
68372 + return 1;
68373 +
68374 + read_lock(&tasklist_lock);
68375 + do_each_thread(p2, p) {
68376 + files = get_files_struct(p);
68377 + if (files == NULL ||
68378 + (p->signal && p->signal->tty == task->signal->tty)) {
68379 + if (files != NULL)
68380 + put_files_struct(files);
68381 + continue;
68382 + }
68383 + rcu_read_lock();
68384 + fdt = files_fdtable(files);
68385 + for (i=0; i < fdt->max_fds; i++) {
68386 + file = fcheck_files(files, i);
68387 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
68388 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
68389 + p3 = task;
68390 + while (task_pid_nr(p3) > 0) {
68391 + if (p3 == p)
68392 + break;
68393 + p3 = p3->real_parent;
68394 + }
68395 + if (p3 == p)
68396 + break;
68397 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
68398 + gr_handle_alertkill(p);
68399 + rcu_read_unlock();
68400 + put_files_struct(files);
68401 + read_unlock(&tasklist_lock);
68402 + fput(our_file);
68403 + return 0;
68404 + }
68405 + }
68406 + rcu_read_unlock();
68407 + put_files_struct(files);
68408 + } while_each_thread(p2, p);
68409 + read_unlock(&tasklist_lock);
68410 +
68411 + fput(our_file);
68412 + return 1;
68413 +}
68414 +
68415 +ssize_t
68416 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
68417 +{
68418 + struct gr_arg_wrapper uwrap;
68419 + unsigned char *sprole_salt = NULL;
68420 + unsigned char *sprole_sum = NULL;
68421 + int error = 0;
68422 + int error2 = 0;
68423 + size_t req_count = 0;
68424 + unsigned char oldmode = 0;
68425 +
68426 + mutex_lock(&gr_dev_mutex);
68427 +
68428 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
68429 + error = -EPERM;
68430 + goto out;
68431 + }
68432 +
68433 +#ifdef CONFIG_COMPAT
68434 + pax_open_kernel();
68435 + if (is_compat_task()) {
68436 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
68437 + copy_gr_arg = &copy_gr_arg_compat;
68438 + copy_acl_object_label = &copy_acl_object_label_compat;
68439 + copy_acl_subject_label = &copy_acl_subject_label_compat;
68440 + copy_acl_role_label = &copy_acl_role_label_compat;
68441 + copy_acl_ip_label = &copy_acl_ip_label_compat;
68442 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
68443 + copy_role_transition = &copy_role_transition_compat;
68444 + copy_sprole_pw = &copy_sprole_pw_compat;
68445 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
68446 + copy_pointer_from_array = &copy_pointer_from_array_compat;
68447 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
68448 + } else {
68449 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
68450 + copy_gr_arg = &copy_gr_arg_normal;
68451 + copy_acl_object_label = &copy_acl_object_label_normal;
68452 + copy_acl_subject_label = &copy_acl_subject_label_normal;
68453 + copy_acl_role_label = &copy_acl_role_label_normal;
68454 + copy_acl_ip_label = &copy_acl_ip_label_normal;
68455 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
68456 + copy_role_transition = &copy_role_transition_normal;
68457 + copy_sprole_pw = &copy_sprole_pw_normal;
68458 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
68459 + copy_pointer_from_array = &copy_pointer_from_array_normal;
68460 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
68461 + }
68462 + pax_close_kernel();
68463 +#endif
68464 +
68465 + req_count = get_gr_arg_wrapper_size();
68466 +
68467 + if (count != req_count) {
68468 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
68469 + error = -EINVAL;
68470 + goto out;
68471 + }
68472 +
68473 +
68474 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
68475 + gr_auth_expires = 0;
68476 + gr_auth_attempts = 0;
68477 + }
68478 +
68479 + error = copy_gr_arg_wrapper(buf, &uwrap);
68480 + if (error)
68481 + goto out;
68482 +
68483 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
68484 + if (error)
68485 + goto out;
68486 +
68487 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68488 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68489 + time_after(gr_auth_expires, get_seconds())) {
68490 + error = -EBUSY;
68491 + goto out;
68492 + }
68493 +
68494 + /* if non-root trying to do anything other than use a special role,
68495 + do not attempt authentication, do not count towards authentication
68496 + locking
68497 + */
68498 +
68499 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
68500 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68501 + gr_is_global_nonroot(current_uid())) {
68502 + error = -EPERM;
68503 + goto out;
68504 + }
68505 +
68506 + /* ensure pw and special role name are null terminated */
68507 +
68508 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
68509 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
68510 +
68511 + /* Okay.
68512 + * We have our enough of the argument structure..(we have yet
68513 + * to copy_from_user the tables themselves) . Copy the tables
68514 + * only if we need them, i.e. for loading operations. */
68515 +
68516 + switch (gr_usermode.mode) {
68517 + case GR_STATUS:
68518 + if (gr_acl_is_enabled()) {
68519 + error = 1;
68520 + if (!gr_check_secure_terminal(current))
68521 + error = 3;
68522 + } else
68523 + error = 2;
68524 + goto out;
68525 + case GR_SHUTDOWN:
68526 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68527 + stop_machine(gr_rbac_disable, NULL, NULL);
68528 + free_variables(false);
68529 + memset(&gr_usermode, 0, sizeof(gr_usermode));
68530 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
68531 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
68532 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
68533 + } else if (gr_acl_is_enabled()) {
68534 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
68535 + error = -EPERM;
68536 + } else {
68537 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
68538 + error = -EAGAIN;
68539 + }
68540 + break;
68541 + case GR_ENABLE:
68542 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
68543 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
68544 + else {
68545 + if (gr_acl_is_enabled())
68546 + error = -EAGAIN;
68547 + else
68548 + error = error2;
68549 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
68550 + }
68551 + break;
68552 + case GR_OLDRELOAD:
68553 + oldmode = 1;
68554 + case GR_RELOAD:
68555 + if (!gr_acl_is_enabled()) {
68556 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
68557 + error = -EAGAIN;
68558 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68559 + error2 = gracl_reload(&gr_usermode, oldmode);
68560 + if (!error2)
68561 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
68562 + else {
68563 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68564 + error = error2;
68565 + }
68566 + } else {
68567 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68568 + error = -EPERM;
68569 + }
68570 + break;
68571 + case GR_SEGVMOD:
68572 + if (unlikely(!gr_acl_is_enabled())) {
68573 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
68574 + error = -EAGAIN;
68575 + break;
68576 + }
68577 +
68578 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68579 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
68580 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
68581 + struct acl_subject_label *segvacl;
68582 + segvacl =
68583 + lookup_acl_subj_label(gr_usermode.segv_inode,
68584 + gr_usermode.segv_device,
68585 + current->role);
68586 + if (segvacl) {
68587 + segvacl->crashes = 0;
68588 + segvacl->expires = 0;
68589 + }
68590 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
68591 + gr_remove_uid(gr_usermode.segv_uid);
68592 + }
68593 + } else {
68594 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
68595 + error = -EPERM;
68596 + }
68597 + break;
68598 + case GR_SPROLE:
68599 + case GR_SPROLEPAM:
68600 + if (unlikely(!gr_acl_is_enabled())) {
68601 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
68602 + error = -EAGAIN;
68603 + break;
68604 + }
68605 +
68606 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
68607 + current->role->expires = 0;
68608 + current->role->auth_attempts = 0;
68609 + }
68610 +
68611 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68612 + time_after(current->role->expires, get_seconds())) {
68613 + error = -EBUSY;
68614 + goto out;
68615 + }
68616 +
68617 + if (lookup_special_role_auth
68618 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
68619 + && ((!sprole_salt && !sprole_sum)
68620 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
68621 + char *p = "";
68622 + assign_special_role(gr_usermode.sp_role);
68623 + read_lock(&tasklist_lock);
68624 + if (current->real_parent)
68625 + p = current->real_parent->role->rolename;
68626 + read_unlock(&tasklist_lock);
68627 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
68628 + p, acl_sp_role_value);
68629 + } else {
68630 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
68631 + error = -EPERM;
68632 + if(!(current->role->auth_attempts++))
68633 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68634 +
68635 + goto out;
68636 + }
68637 + break;
68638 + case GR_UNSPROLE:
68639 + if (unlikely(!gr_acl_is_enabled())) {
68640 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
68641 + error = -EAGAIN;
68642 + break;
68643 + }
68644 +
68645 + if (current->role->roletype & GR_ROLE_SPECIAL) {
68646 + char *p = "";
68647 + int i = 0;
68648 +
68649 + read_lock(&tasklist_lock);
68650 + if (current->real_parent) {
68651 + p = current->real_parent->role->rolename;
68652 + i = current->real_parent->acl_role_id;
68653 + }
68654 + read_unlock(&tasklist_lock);
68655 +
68656 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
68657 + gr_set_acls(1);
68658 + } else {
68659 + error = -EPERM;
68660 + goto out;
68661 + }
68662 + break;
68663 + default:
68664 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
68665 + error = -EINVAL;
68666 + break;
68667 + }
68668 +
68669 + if (error != -EPERM)
68670 + goto out;
68671 +
68672 + if(!(gr_auth_attempts++))
68673 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68674 +
68675 + out:
68676 + mutex_unlock(&gr_dev_mutex);
68677 +
68678 + if (!error)
68679 + error = req_count;
68680 +
68681 + return error;
68682 +}
68683 +
68684 +int
68685 +gr_set_acls(const int type)
68686 +{
68687 + struct task_struct *task, *task2;
68688 + struct acl_role_label *role = current->role;
68689 + struct acl_subject_label *subj;
68690 + __u16 acl_role_id = current->acl_role_id;
68691 + const struct cred *cred;
68692 + int ret;
68693 +
68694 + rcu_read_lock();
68695 + read_lock(&tasklist_lock);
68696 + read_lock(&grsec_exec_file_lock);
68697 + do_each_thread(task2, task) {
68698 + /* check to see if we're called from the exit handler,
68699 + if so, only replace ACLs that have inherited the admin
68700 + ACL */
68701 +
68702 + if (type && (task->role != role ||
68703 + task->acl_role_id != acl_role_id))
68704 + continue;
68705 +
68706 + task->acl_role_id = 0;
68707 + task->acl_sp_role = 0;
68708 + task->inherited = 0;
68709 +
68710 + if (task->exec_file) {
68711 + cred = __task_cred(task);
68712 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68713 + subj = __gr_get_subject_for_task(polstate, task, NULL);
68714 + if (subj == NULL) {
68715 + ret = -EINVAL;
68716 + read_unlock(&grsec_exec_file_lock);
68717 + read_unlock(&tasklist_lock);
68718 + rcu_read_unlock();
68719 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
68720 + return ret;
68721 + }
68722 + __gr_apply_subject_to_task(polstate, task, subj);
68723 + } else {
68724 + // it's a kernel process
68725 + task->role = polstate->kernel_role;
68726 + task->acl = polstate->kernel_role->root_label;
68727 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68728 + task->acl->mode &= ~GR_PROCFIND;
68729 +#endif
68730 + }
68731 + } while_each_thread(task2, task);
68732 + read_unlock(&grsec_exec_file_lock);
68733 + read_unlock(&tasklist_lock);
68734 + rcu_read_unlock();
68735 +
68736 + return 0;
68737 +}
68738 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68739 new file mode 100644
68740 index 0000000..39645c9
68741 --- /dev/null
68742 +++ b/grsecurity/gracl_res.c
68743 @@ -0,0 +1,68 @@
68744 +#include <linux/kernel.h>
68745 +#include <linux/sched.h>
68746 +#include <linux/gracl.h>
68747 +#include <linux/grinternal.h>
68748 +
68749 +static const char *restab_log[] = {
68750 + [RLIMIT_CPU] = "RLIMIT_CPU",
68751 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68752 + [RLIMIT_DATA] = "RLIMIT_DATA",
68753 + [RLIMIT_STACK] = "RLIMIT_STACK",
68754 + [RLIMIT_CORE] = "RLIMIT_CORE",
68755 + [RLIMIT_RSS] = "RLIMIT_RSS",
68756 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68757 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68758 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68759 + [RLIMIT_AS] = "RLIMIT_AS",
68760 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68761 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68762 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68763 + [RLIMIT_NICE] = "RLIMIT_NICE",
68764 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68765 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68766 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68767 +};
68768 +
68769 +void
68770 +gr_log_resource(const struct task_struct *task,
68771 + const int res, const unsigned long wanted, const int gt)
68772 +{
68773 + const struct cred *cred;
68774 + unsigned long rlim;
68775 +
68776 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68777 + return;
68778 +
68779 + // not yet supported resource
68780 + if (unlikely(!restab_log[res]))
68781 + return;
68782 +
68783 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68784 + rlim = task_rlimit_max(task, res);
68785 + else
68786 + rlim = task_rlimit(task, res);
68787 +
68788 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68789 + return;
68790 +
68791 + rcu_read_lock();
68792 + cred = __task_cred(task);
68793 +
68794 + if (res == RLIMIT_NPROC &&
68795 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68796 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68797 + goto out_rcu_unlock;
68798 + else if (res == RLIMIT_MEMLOCK &&
68799 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68800 + goto out_rcu_unlock;
68801 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68802 + goto out_rcu_unlock;
68803 + rcu_read_unlock();
68804 +
68805 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68806 +
68807 + return;
68808 +out_rcu_unlock:
68809 + rcu_read_unlock();
68810 + return;
68811 +}
68812 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68813 new file mode 100644
68814 index 0000000..2040e61
68815 --- /dev/null
68816 +++ b/grsecurity/gracl_segv.c
68817 @@ -0,0 +1,313 @@
68818 +#include <linux/kernel.h>
68819 +#include <linux/mm.h>
68820 +#include <asm/uaccess.h>
68821 +#include <asm/errno.h>
68822 +#include <asm/mman.h>
68823 +#include <net/sock.h>
68824 +#include <linux/file.h>
68825 +#include <linux/fs.h>
68826 +#include <linux/net.h>
68827 +#include <linux/in.h>
68828 +#include <linux/slab.h>
68829 +#include <linux/types.h>
68830 +#include <linux/sched.h>
68831 +#include <linux/timer.h>
68832 +#include <linux/gracl.h>
68833 +#include <linux/grsecurity.h>
68834 +#include <linux/grinternal.h>
68835 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68836 +#include <linux/magic.h>
68837 +#include <linux/pagemap.h>
68838 +#include "../fs/btrfs/async-thread.h"
68839 +#include "../fs/btrfs/ctree.h"
68840 +#include "../fs/btrfs/btrfs_inode.h"
68841 +#endif
68842 +
68843 +static struct crash_uid *uid_set;
68844 +static unsigned short uid_used;
68845 +static DEFINE_SPINLOCK(gr_uid_lock);
68846 +extern rwlock_t gr_inode_lock;
68847 +extern struct acl_subject_label *
68848 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68849 + struct acl_role_label *role);
68850 +
68851 +static inline dev_t __get_dev(const struct dentry *dentry)
68852 +{
68853 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68854 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68855 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68856 + else
68857 +#endif
68858 + return dentry->d_sb->s_dev;
68859 +}
68860 +
68861 +int
68862 +gr_init_uidset(void)
68863 +{
68864 + uid_set =
68865 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68866 + uid_used = 0;
68867 +
68868 + return uid_set ? 1 : 0;
68869 +}
68870 +
68871 +void
68872 +gr_free_uidset(void)
68873 +{
68874 + if (uid_set) {
68875 + struct crash_uid *tmpset;
68876 + spin_lock(&gr_uid_lock);
68877 + tmpset = uid_set;
68878 + uid_set = NULL;
68879 + uid_used = 0;
68880 + spin_unlock(&gr_uid_lock);
68881 + if (tmpset)
68882 + kfree(tmpset);
68883 + }
68884 +
68885 + return;
68886 +}
68887 +
68888 +int
68889 +gr_find_uid(const uid_t uid)
68890 +{
68891 + struct crash_uid *tmp = uid_set;
68892 + uid_t buid;
68893 + int low = 0, high = uid_used - 1, mid;
68894 +
68895 + while (high >= low) {
68896 + mid = (low + high) >> 1;
68897 + buid = tmp[mid].uid;
68898 + if (buid == uid)
68899 + return mid;
68900 + if (buid > uid)
68901 + high = mid - 1;
68902 + if (buid < uid)
68903 + low = mid + 1;
68904 + }
68905 +
68906 + return -1;
68907 +}
68908 +
68909 +static __inline__ void
68910 +gr_insertsort(void)
68911 +{
68912 + unsigned short i, j;
68913 + struct crash_uid index;
68914 +
68915 + for (i = 1; i < uid_used; i++) {
68916 + index = uid_set[i];
68917 + j = i;
68918 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68919 + uid_set[j] = uid_set[j - 1];
68920 + j--;
68921 + }
68922 + uid_set[j] = index;
68923 + }
68924 +
68925 + return;
68926 +}
68927 +
68928 +static __inline__ void
68929 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68930 +{
68931 + int loc;
68932 + uid_t uid = GR_GLOBAL_UID(kuid);
68933 +
68934 + if (uid_used == GR_UIDTABLE_MAX)
68935 + return;
68936 +
68937 + loc = gr_find_uid(uid);
68938 +
68939 + if (loc >= 0) {
68940 + uid_set[loc].expires = expires;
68941 + return;
68942 + }
68943 +
68944 + uid_set[uid_used].uid = uid;
68945 + uid_set[uid_used].expires = expires;
68946 + uid_used++;
68947 +
68948 + gr_insertsort();
68949 +
68950 + return;
68951 +}
68952 +
68953 +void
68954 +gr_remove_uid(const unsigned short loc)
68955 +{
68956 + unsigned short i;
68957 +
68958 + for (i = loc + 1; i < uid_used; i++)
68959 + uid_set[i - 1] = uid_set[i];
68960 +
68961 + uid_used--;
68962 +
68963 + return;
68964 +}
68965 +
68966 +int
68967 +gr_check_crash_uid(const kuid_t kuid)
68968 +{
68969 + int loc;
68970 + int ret = 0;
68971 + uid_t uid;
68972 +
68973 + if (unlikely(!gr_acl_is_enabled()))
68974 + return 0;
68975 +
68976 + uid = GR_GLOBAL_UID(kuid);
68977 +
68978 + spin_lock(&gr_uid_lock);
68979 + loc = gr_find_uid(uid);
68980 +
68981 + if (loc < 0)
68982 + goto out_unlock;
68983 +
68984 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68985 + gr_remove_uid(loc);
68986 + else
68987 + ret = 1;
68988 +
68989 +out_unlock:
68990 + spin_unlock(&gr_uid_lock);
68991 + return ret;
68992 +}
68993 +
68994 +static __inline__ int
68995 +proc_is_setxid(const struct cred *cred)
68996 +{
68997 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68998 + !uid_eq(cred->uid, cred->fsuid))
68999 + return 1;
69000 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69001 + !gid_eq(cred->gid, cred->fsgid))
69002 + return 1;
69003 +
69004 + return 0;
69005 +}
69006 +
69007 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69008 +
69009 +void
69010 +gr_handle_crash(struct task_struct *task, const int sig)
69011 +{
69012 + struct acl_subject_label *curr;
69013 + struct task_struct *tsk, *tsk2;
69014 + const struct cred *cred;
69015 + const struct cred *cred2;
69016 +
69017 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69018 + return;
69019 +
69020 + if (unlikely(!gr_acl_is_enabled()))
69021 + return;
69022 +
69023 + curr = task->acl;
69024 +
69025 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69026 + return;
69027 +
69028 + if (time_before_eq(curr->expires, get_seconds())) {
69029 + curr->expires = 0;
69030 + curr->crashes = 0;
69031 + }
69032 +
69033 + curr->crashes++;
69034 +
69035 + if (!curr->expires)
69036 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69037 +
69038 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69039 + time_after(curr->expires, get_seconds())) {
69040 + rcu_read_lock();
69041 + cred = __task_cred(task);
69042 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69043 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69044 + spin_lock(&gr_uid_lock);
69045 + gr_insert_uid(cred->uid, curr->expires);
69046 + spin_unlock(&gr_uid_lock);
69047 + curr->expires = 0;
69048 + curr->crashes = 0;
69049 + read_lock(&tasklist_lock);
69050 + do_each_thread(tsk2, tsk) {
69051 + cred2 = __task_cred(tsk);
69052 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69053 + gr_fake_force_sig(SIGKILL, tsk);
69054 + } while_each_thread(tsk2, tsk);
69055 + read_unlock(&tasklist_lock);
69056 + } else {
69057 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69058 + read_lock(&tasklist_lock);
69059 + read_lock(&grsec_exec_file_lock);
69060 + do_each_thread(tsk2, tsk) {
69061 + if (likely(tsk != task)) {
69062 + // if this thread has the same subject as the one that triggered
69063 + // RES_CRASH and it's the same binary, kill it
69064 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69065 + gr_fake_force_sig(SIGKILL, tsk);
69066 + }
69067 + } while_each_thread(tsk2, tsk);
69068 + read_unlock(&grsec_exec_file_lock);
69069 + read_unlock(&tasklist_lock);
69070 + }
69071 + rcu_read_unlock();
69072 + }
69073 +
69074 + return;
69075 +}
69076 +
69077 +int
69078 +gr_check_crash_exec(const struct file *filp)
69079 +{
69080 + struct acl_subject_label *curr;
69081 +
69082 + if (unlikely(!gr_acl_is_enabled()))
69083 + return 0;
69084 +
69085 + read_lock(&gr_inode_lock);
69086 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69087 + __get_dev(filp->f_path.dentry),
69088 + current->role);
69089 + read_unlock(&gr_inode_lock);
69090 +
69091 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69092 + (!curr->crashes && !curr->expires))
69093 + return 0;
69094 +
69095 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69096 + time_after(curr->expires, get_seconds()))
69097 + return 1;
69098 + else if (time_before_eq(curr->expires, get_seconds())) {
69099 + curr->crashes = 0;
69100 + curr->expires = 0;
69101 + }
69102 +
69103 + return 0;
69104 +}
69105 +
69106 +void
69107 +gr_handle_alertkill(struct task_struct *task)
69108 +{
69109 + struct acl_subject_label *curracl;
69110 + __u32 curr_ip;
69111 + struct task_struct *p, *p2;
69112 +
69113 + if (unlikely(!gr_acl_is_enabled()))
69114 + return;
69115 +
69116 + curracl = task->acl;
69117 + curr_ip = task->signal->curr_ip;
69118 +
69119 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69120 + read_lock(&tasklist_lock);
69121 + do_each_thread(p2, p) {
69122 + if (p->signal->curr_ip == curr_ip)
69123 + gr_fake_force_sig(SIGKILL, p);
69124 + } while_each_thread(p2, p);
69125 + read_unlock(&tasklist_lock);
69126 + } else if (curracl->mode & GR_KILLPROC)
69127 + gr_fake_force_sig(SIGKILL, task);
69128 +
69129 + return;
69130 +}
69131 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69132 new file mode 100644
69133 index 0000000..98011b0
69134 --- /dev/null
69135 +++ b/grsecurity/gracl_shm.c
69136 @@ -0,0 +1,40 @@
69137 +#include <linux/kernel.h>
69138 +#include <linux/mm.h>
69139 +#include <linux/sched.h>
69140 +#include <linux/file.h>
69141 +#include <linux/ipc.h>
69142 +#include <linux/gracl.h>
69143 +#include <linux/grsecurity.h>
69144 +#include <linux/grinternal.h>
69145 +
69146 +int
69147 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69148 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69149 +{
69150 + struct task_struct *task;
69151 +
69152 + if (!gr_acl_is_enabled())
69153 + return 1;
69154 +
69155 + rcu_read_lock();
69156 + read_lock(&tasklist_lock);
69157 +
69158 + task = find_task_by_vpid(shm_cprid);
69159 +
69160 + if (unlikely(!task))
69161 + task = find_task_by_vpid(shm_lapid);
69162 +
69163 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69164 + (task_pid_nr(task) == shm_lapid)) &&
69165 + (task->acl->mode & GR_PROTSHM) &&
69166 + (task->acl != current->acl))) {
69167 + read_unlock(&tasklist_lock);
69168 + rcu_read_unlock();
69169 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69170 + return 0;
69171 + }
69172 + read_unlock(&tasklist_lock);
69173 + rcu_read_unlock();
69174 +
69175 + return 1;
69176 +}
69177 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69178 new file mode 100644
69179 index 0000000..bc0be01
69180 --- /dev/null
69181 +++ b/grsecurity/grsec_chdir.c
69182 @@ -0,0 +1,19 @@
69183 +#include <linux/kernel.h>
69184 +#include <linux/sched.h>
69185 +#include <linux/fs.h>
69186 +#include <linux/file.h>
69187 +#include <linux/grsecurity.h>
69188 +#include <linux/grinternal.h>
69189 +
69190 +void
69191 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69192 +{
69193 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69194 + if ((grsec_enable_chdir && grsec_enable_group &&
69195 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69196 + !grsec_enable_group)) {
69197 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69198 + }
69199 +#endif
69200 + return;
69201 +}
69202 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69203 new file mode 100644
69204 index 0000000..e10b319
69205 --- /dev/null
69206 +++ b/grsecurity/grsec_chroot.c
69207 @@ -0,0 +1,370 @@
69208 +#include <linux/kernel.h>
69209 +#include <linux/module.h>
69210 +#include <linux/sched.h>
69211 +#include <linux/file.h>
69212 +#include <linux/fs.h>
69213 +#include <linux/mount.h>
69214 +#include <linux/types.h>
69215 +#include "../fs/mount.h"
69216 +#include <linux/grsecurity.h>
69217 +#include <linux/grinternal.h>
69218 +
69219 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69220 +int gr_init_ran;
69221 +#endif
69222 +
69223 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69224 +{
69225 +#ifdef CONFIG_GRKERNSEC
69226 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69227 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69228 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69229 + && gr_init_ran
69230 +#endif
69231 + )
69232 + task->gr_is_chrooted = 1;
69233 + else {
69234 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69235 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69236 + gr_init_ran = 1;
69237 +#endif
69238 + task->gr_is_chrooted = 0;
69239 + }
69240 +
69241 + task->gr_chroot_dentry = path->dentry;
69242 +#endif
69243 + return;
69244 +}
69245 +
69246 +void gr_clear_chroot_entries(struct task_struct *task)
69247 +{
69248 +#ifdef CONFIG_GRKERNSEC
69249 + task->gr_is_chrooted = 0;
69250 + task->gr_chroot_dentry = NULL;
69251 +#endif
69252 + return;
69253 +}
69254 +
69255 +int
69256 +gr_handle_chroot_unix(const pid_t pid)
69257 +{
69258 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69259 + struct task_struct *p;
69260 +
69261 + if (unlikely(!grsec_enable_chroot_unix))
69262 + return 1;
69263 +
69264 + if (likely(!proc_is_chrooted(current)))
69265 + return 1;
69266 +
69267 + rcu_read_lock();
69268 + read_lock(&tasklist_lock);
69269 + p = find_task_by_vpid_unrestricted(pid);
69270 + if (unlikely(p && !have_same_root(current, p))) {
69271 + read_unlock(&tasklist_lock);
69272 + rcu_read_unlock();
69273 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69274 + return 0;
69275 + }
69276 + read_unlock(&tasklist_lock);
69277 + rcu_read_unlock();
69278 +#endif
69279 + return 1;
69280 +}
69281 +
69282 +int
69283 +gr_handle_chroot_nice(void)
69284 +{
69285 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69286 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69287 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69288 + return -EPERM;
69289 + }
69290 +#endif
69291 + return 0;
69292 +}
69293 +
69294 +int
69295 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
69296 +{
69297 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69298 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
69299 + && proc_is_chrooted(current)) {
69300 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
69301 + return -EACCES;
69302 + }
69303 +#endif
69304 + return 0;
69305 +}
69306 +
69307 +int
69308 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
69309 +{
69310 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69311 + struct task_struct *p;
69312 + int ret = 0;
69313 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
69314 + return ret;
69315 +
69316 + read_lock(&tasklist_lock);
69317 + do_each_pid_task(pid, type, p) {
69318 + if (!have_same_root(current, p)) {
69319 + ret = 1;
69320 + goto out;
69321 + }
69322 + } while_each_pid_task(pid, type, p);
69323 +out:
69324 + read_unlock(&tasklist_lock);
69325 + return ret;
69326 +#endif
69327 + return 0;
69328 +}
69329 +
69330 +int
69331 +gr_pid_is_chrooted(struct task_struct *p)
69332 +{
69333 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69334 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
69335 + return 0;
69336 +
69337 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
69338 + !have_same_root(current, p)) {
69339 + return 1;
69340 + }
69341 +#endif
69342 + return 0;
69343 +}
69344 +
69345 +EXPORT_SYMBOL(gr_pid_is_chrooted);
69346 +
69347 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
69348 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
69349 +{
69350 + struct path path, currentroot;
69351 + int ret = 0;
69352 +
69353 + path.dentry = (struct dentry *)u_dentry;
69354 + path.mnt = (struct vfsmount *)u_mnt;
69355 + get_fs_root(current->fs, &currentroot);
69356 + if (path_is_under(&path, &currentroot))
69357 + ret = 1;
69358 + path_put(&currentroot);
69359 +
69360 + return ret;
69361 +}
69362 +#endif
69363 +
69364 +int
69365 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
69366 +{
69367 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69368 + if (!grsec_enable_chroot_fchdir)
69369 + return 1;
69370 +
69371 + if (!proc_is_chrooted(current))
69372 + return 1;
69373 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
69374 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
69375 + return 0;
69376 + }
69377 +#endif
69378 + return 1;
69379 +}
69380 +
69381 +int
69382 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69383 + const time_t shm_createtime)
69384 +{
69385 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69386 + struct task_struct *p;
69387 + time_t starttime;
69388 +
69389 + if (unlikely(!grsec_enable_chroot_shmat))
69390 + return 1;
69391 +
69392 + if (likely(!proc_is_chrooted(current)))
69393 + return 1;
69394 +
69395 + rcu_read_lock();
69396 + read_lock(&tasklist_lock);
69397 +
69398 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
69399 + starttime = p->start_time.tv_sec;
69400 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
69401 + if (have_same_root(current, p)) {
69402 + goto allow;
69403 + } else {
69404 + read_unlock(&tasklist_lock);
69405 + rcu_read_unlock();
69406 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69407 + return 0;
69408 + }
69409 + }
69410 + /* creator exited, pid reuse, fall through to next check */
69411 + }
69412 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
69413 + if (unlikely(!have_same_root(current, p))) {
69414 + read_unlock(&tasklist_lock);
69415 + rcu_read_unlock();
69416 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69417 + return 0;
69418 + }
69419 + }
69420 +
69421 +allow:
69422 + read_unlock(&tasklist_lock);
69423 + rcu_read_unlock();
69424 +#endif
69425 + return 1;
69426 +}
69427 +
69428 +void
69429 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
69430 +{
69431 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69432 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
69433 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
69434 +#endif
69435 + return;
69436 +}
69437 +
69438 +int
69439 +gr_handle_chroot_mknod(const struct dentry *dentry,
69440 + const struct vfsmount *mnt, const int mode)
69441 +{
69442 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69443 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
69444 + proc_is_chrooted(current)) {
69445 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
69446 + return -EPERM;
69447 + }
69448 +#endif
69449 + return 0;
69450 +}
69451 +
69452 +int
69453 +gr_handle_chroot_mount(const struct dentry *dentry,
69454 + const struct vfsmount *mnt, const char *dev_name)
69455 +{
69456 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69457 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
69458 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
69459 + return -EPERM;
69460 + }
69461 +#endif
69462 + return 0;
69463 +}
69464 +
69465 +int
69466 +gr_handle_chroot_pivot(void)
69467 +{
69468 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69469 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
69470 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
69471 + return -EPERM;
69472 + }
69473 +#endif
69474 + return 0;
69475 +}
69476 +
69477 +int
69478 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
69479 +{
69480 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69481 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
69482 + !gr_is_outside_chroot(dentry, mnt)) {
69483 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
69484 + return -EPERM;
69485 + }
69486 +#endif
69487 + return 0;
69488 +}
69489 +
69490 +extern const char *captab_log[];
69491 +extern int captab_log_entries;
69492 +
69493 +int
69494 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69495 +{
69496 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69497 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69498 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69499 + if (cap_raised(chroot_caps, cap)) {
69500 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
69501 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
69502 + }
69503 + return 0;
69504 + }
69505 + }
69506 +#endif
69507 + return 1;
69508 +}
69509 +
69510 +int
69511 +gr_chroot_is_capable(const int cap)
69512 +{
69513 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69514 + return gr_task_chroot_is_capable(current, current_cred(), cap);
69515 +#endif
69516 + return 1;
69517 +}
69518 +
69519 +int
69520 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
69521 +{
69522 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69523 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69524 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69525 + if (cap_raised(chroot_caps, cap)) {
69526 + return 0;
69527 + }
69528 + }
69529 +#endif
69530 + return 1;
69531 +}
69532 +
69533 +int
69534 +gr_chroot_is_capable_nolog(const int cap)
69535 +{
69536 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69537 + return gr_task_chroot_is_capable_nolog(current, cap);
69538 +#endif
69539 + return 1;
69540 +}
69541 +
69542 +int
69543 +gr_handle_chroot_sysctl(const int op)
69544 +{
69545 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69546 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
69547 + proc_is_chrooted(current))
69548 + return -EACCES;
69549 +#endif
69550 + return 0;
69551 +}
69552 +
69553 +void
69554 +gr_handle_chroot_chdir(const struct path *path)
69555 +{
69556 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69557 + if (grsec_enable_chroot_chdir)
69558 + set_fs_pwd(current->fs, path);
69559 +#endif
69560 + return;
69561 +}
69562 +
69563 +int
69564 +gr_handle_chroot_chmod(const struct dentry *dentry,
69565 + const struct vfsmount *mnt, const int mode)
69566 +{
69567 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69568 + /* allow chmod +s on directories, but not files */
69569 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
69570 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
69571 + proc_is_chrooted(current)) {
69572 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
69573 + return -EPERM;
69574 + }
69575 +#endif
69576 + return 0;
69577 +}
69578 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
69579 new file mode 100644
69580 index 0000000..0866ab2
69581 --- /dev/null
69582 +++ b/grsecurity/grsec_disabled.c
69583 @@ -0,0 +1,427 @@
69584 +#include <linux/kernel.h>
69585 +#include <linux/module.h>
69586 +#include <linux/sched.h>
69587 +#include <linux/file.h>
69588 +#include <linux/fs.h>
69589 +#include <linux/kdev_t.h>
69590 +#include <linux/net.h>
69591 +#include <linux/in.h>
69592 +#include <linux/ip.h>
69593 +#include <linux/skbuff.h>
69594 +#include <linux/sysctl.h>
69595 +
69596 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
69597 +void
69598 +pax_set_initial_flags(struct linux_binprm *bprm)
69599 +{
69600 + return;
69601 +}
69602 +#endif
69603 +
69604 +#ifdef CONFIG_SYSCTL
69605 +__u32
69606 +gr_handle_sysctl(const struct ctl_table * table, const int op)
69607 +{
69608 + return 0;
69609 +}
69610 +#endif
69611 +
69612 +#ifdef CONFIG_TASKSTATS
69613 +int gr_is_taskstats_denied(int pid)
69614 +{
69615 + return 0;
69616 +}
69617 +#endif
69618 +
69619 +int
69620 +gr_acl_is_enabled(void)
69621 +{
69622 + return 0;
69623 +}
69624 +
69625 +void
69626 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
69627 +{
69628 + return;
69629 +}
69630 +
69631 +int
69632 +gr_handle_rawio(const struct inode *inode)
69633 +{
69634 + return 0;
69635 +}
69636 +
69637 +void
69638 +gr_acl_handle_psacct(struct task_struct *task, const long code)
69639 +{
69640 + return;
69641 +}
69642 +
69643 +int
69644 +gr_handle_ptrace(struct task_struct *task, const long request)
69645 +{
69646 + return 0;
69647 +}
69648 +
69649 +int
69650 +gr_handle_proc_ptrace(struct task_struct *task)
69651 +{
69652 + return 0;
69653 +}
69654 +
69655 +int
69656 +gr_set_acls(const int type)
69657 +{
69658 + return 0;
69659 +}
69660 +
69661 +int
69662 +gr_check_hidden_task(const struct task_struct *tsk)
69663 +{
69664 + return 0;
69665 +}
69666 +
69667 +int
69668 +gr_check_protected_task(const struct task_struct *task)
69669 +{
69670 + return 0;
69671 +}
69672 +
69673 +int
69674 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
69675 +{
69676 + return 0;
69677 +}
69678 +
69679 +void
69680 +gr_copy_label(struct task_struct *tsk)
69681 +{
69682 + return;
69683 +}
69684 +
69685 +void
69686 +gr_set_pax_flags(struct task_struct *task)
69687 +{
69688 + return;
69689 +}
69690 +
69691 +int
69692 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
69693 + const int unsafe_share)
69694 +{
69695 + return 0;
69696 +}
69697 +
69698 +void
69699 +gr_handle_delete(const ino_t ino, const dev_t dev)
69700 +{
69701 + return;
69702 +}
69703 +
69704 +void
69705 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
69706 +{
69707 + return;
69708 +}
69709 +
69710 +void
69711 +gr_handle_crash(struct task_struct *task, const int sig)
69712 +{
69713 + return;
69714 +}
69715 +
69716 +int
69717 +gr_check_crash_exec(const struct file *filp)
69718 +{
69719 + return 0;
69720 +}
69721 +
69722 +int
69723 +gr_check_crash_uid(const kuid_t uid)
69724 +{
69725 + return 0;
69726 +}
69727 +
69728 +void
69729 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69730 + struct dentry *old_dentry,
69731 + struct dentry *new_dentry,
69732 + struct vfsmount *mnt, const __u8 replace)
69733 +{
69734 + return;
69735 +}
69736 +
69737 +int
69738 +gr_search_socket(const int family, const int type, const int protocol)
69739 +{
69740 + return 1;
69741 +}
69742 +
69743 +int
69744 +gr_search_connectbind(const int mode, const struct socket *sock,
69745 + const struct sockaddr_in *addr)
69746 +{
69747 + return 0;
69748 +}
69749 +
69750 +void
69751 +gr_handle_alertkill(struct task_struct *task)
69752 +{
69753 + return;
69754 +}
69755 +
69756 +__u32
69757 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69758 +{
69759 + return 1;
69760 +}
69761 +
69762 +__u32
69763 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69764 + const struct vfsmount * mnt)
69765 +{
69766 + return 1;
69767 +}
69768 +
69769 +__u32
69770 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69771 + int acc_mode)
69772 +{
69773 + return 1;
69774 +}
69775 +
69776 +__u32
69777 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69778 +{
69779 + return 1;
69780 +}
69781 +
69782 +__u32
69783 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69784 +{
69785 + return 1;
69786 +}
69787 +
69788 +int
69789 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69790 + unsigned int *vm_flags)
69791 +{
69792 + return 1;
69793 +}
69794 +
69795 +__u32
69796 +gr_acl_handle_truncate(const struct dentry * dentry,
69797 + const struct vfsmount * mnt)
69798 +{
69799 + return 1;
69800 +}
69801 +
69802 +__u32
69803 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69804 +{
69805 + return 1;
69806 +}
69807 +
69808 +__u32
69809 +gr_acl_handle_access(const struct dentry * dentry,
69810 + const struct vfsmount * mnt, const int fmode)
69811 +{
69812 + return 1;
69813 +}
69814 +
69815 +__u32
69816 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69817 + umode_t *mode)
69818 +{
69819 + return 1;
69820 +}
69821 +
69822 +__u32
69823 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69824 +{
69825 + return 1;
69826 +}
69827 +
69828 +__u32
69829 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69830 +{
69831 + return 1;
69832 +}
69833 +
69834 +void
69835 +grsecurity_init(void)
69836 +{
69837 + return;
69838 +}
69839 +
69840 +umode_t gr_acl_umask(void)
69841 +{
69842 + return 0;
69843 +}
69844 +
69845 +__u32
69846 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69847 + const struct dentry * parent_dentry,
69848 + const struct vfsmount * parent_mnt,
69849 + const int mode)
69850 +{
69851 + return 1;
69852 +}
69853 +
69854 +__u32
69855 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69856 + const struct dentry * parent_dentry,
69857 + const struct vfsmount * parent_mnt)
69858 +{
69859 + return 1;
69860 +}
69861 +
69862 +__u32
69863 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69864 + const struct dentry * parent_dentry,
69865 + const struct vfsmount * parent_mnt, const struct filename *from)
69866 +{
69867 + return 1;
69868 +}
69869 +
69870 +__u32
69871 +gr_acl_handle_link(const struct dentry * new_dentry,
69872 + const struct dentry * parent_dentry,
69873 + const struct vfsmount * parent_mnt,
69874 + const struct dentry * old_dentry,
69875 + const struct vfsmount * old_mnt, const struct filename *to)
69876 +{
69877 + return 1;
69878 +}
69879 +
69880 +int
69881 +gr_acl_handle_rename(const struct dentry *new_dentry,
69882 + const struct dentry *parent_dentry,
69883 + const struct vfsmount *parent_mnt,
69884 + const struct dentry *old_dentry,
69885 + const struct inode *old_parent_inode,
69886 + const struct vfsmount *old_mnt, const struct filename *newname)
69887 +{
69888 + return 0;
69889 +}
69890 +
69891 +int
69892 +gr_acl_handle_filldir(const struct file *file, const char *name,
69893 + const int namelen, const ino_t ino)
69894 +{
69895 + return 1;
69896 +}
69897 +
69898 +int
69899 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69900 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69901 +{
69902 + return 1;
69903 +}
69904 +
69905 +int
69906 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69907 +{
69908 + return 0;
69909 +}
69910 +
69911 +int
69912 +gr_search_accept(const struct socket *sock)
69913 +{
69914 + return 0;
69915 +}
69916 +
69917 +int
69918 +gr_search_listen(const struct socket *sock)
69919 +{
69920 + return 0;
69921 +}
69922 +
69923 +int
69924 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69925 +{
69926 + return 0;
69927 +}
69928 +
69929 +__u32
69930 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69931 +{
69932 + return 1;
69933 +}
69934 +
69935 +__u32
69936 +gr_acl_handle_creat(const struct dentry * dentry,
69937 + const struct dentry * p_dentry,
69938 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69939 + const int imode)
69940 +{
69941 + return 1;
69942 +}
69943 +
69944 +void
69945 +gr_acl_handle_exit(void)
69946 +{
69947 + return;
69948 +}
69949 +
69950 +int
69951 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69952 +{
69953 + return 1;
69954 +}
69955 +
69956 +void
69957 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69958 +{
69959 + return;
69960 +}
69961 +
69962 +int
69963 +gr_acl_handle_procpidmem(const struct task_struct *task)
69964 +{
69965 + return 0;
69966 +}
69967 +
69968 +int
69969 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69970 +{
69971 + return 0;
69972 +}
69973 +
69974 +int
69975 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69976 +{
69977 + return 0;
69978 +}
69979 +
69980 +int
69981 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69982 +{
69983 + return 0;
69984 +}
69985 +
69986 +int
69987 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69988 +{
69989 + return 0;
69990 +}
69991 +
69992 +int gr_acl_enable_at_secure(void)
69993 +{
69994 + return 0;
69995 +}
69996 +
69997 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69998 +{
69999 + return dentry->d_sb->s_dev;
70000 +}
70001 +
70002 +void gr_put_exec_file(struct task_struct *task)
70003 +{
70004 + return;
70005 +}
70006 +
70007 +#ifdef CONFIG_SECURITY
70008 +EXPORT_SYMBOL(gr_check_user_change);
70009 +EXPORT_SYMBOL(gr_check_group_change);
70010 +#endif
70011 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70012 new file mode 100644
70013 index 0000000..387032b
70014 --- /dev/null
70015 +++ b/grsecurity/grsec_exec.c
70016 @@ -0,0 +1,187 @@
70017 +#include <linux/kernel.h>
70018 +#include <linux/sched.h>
70019 +#include <linux/file.h>
70020 +#include <linux/binfmts.h>
70021 +#include <linux/fs.h>
70022 +#include <linux/types.h>
70023 +#include <linux/grdefs.h>
70024 +#include <linux/grsecurity.h>
70025 +#include <linux/grinternal.h>
70026 +#include <linux/capability.h>
70027 +#include <linux/module.h>
70028 +#include <linux/compat.h>
70029 +
70030 +#include <asm/uaccess.h>
70031 +
70032 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70033 +static char gr_exec_arg_buf[132];
70034 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70035 +#endif
70036 +
70037 +struct user_arg_ptr {
70038 +#ifdef CONFIG_COMPAT
70039 + bool is_compat;
70040 +#endif
70041 + union {
70042 + const char __user *const __user *native;
70043 +#ifdef CONFIG_COMPAT
70044 + const compat_uptr_t __user *compat;
70045 +#endif
70046 + } ptr;
70047 +};
70048 +
70049 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70050 +
70051 +void
70052 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70053 +{
70054 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70055 + char *grarg = gr_exec_arg_buf;
70056 + unsigned int i, x, execlen = 0;
70057 + char c;
70058 +
70059 + if (!((grsec_enable_execlog && grsec_enable_group &&
70060 + in_group_p(grsec_audit_gid))
70061 + || (grsec_enable_execlog && !grsec_enable_group)))
70062 + return;
70063 +
70064 + mutex_lock(&gr_exec_arg_mutex);
70065 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70066 +
70067 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70068 + const char __user *p;
70069 + unsigned int len;
70070 +
70071 + p = get_user_arg_ptr(argv, i);
70072 + if (IS_ERR(p))
70073 + goto log;
70074 +
70075 + len = strnlen_user(p, 128 - execlen);
70076 + if (len > 128 - execlen)
70077 + len = 128 - execlen;
70078 + else if (len > 0)
70079 + len--;
70080 + if (copy_from_user(grarg + execlen, p, len))
70081 + goto log;
70082 +
70083 + /* rewrite unprintable characters */
70084 + for (x = 0; x < len; x++) {
70085 + c = *(grarg + execlen + x);
70086 + if (c < 32 || c > 126)
70087 + *(grarg + execlen + x) = ' ';
70088 + }
70089 +
70090 + execlen += len;
70091 + *(grarg + execlen) = ' ';
70092 + *(grarg + execlen + 1) = '\0';
70093 + execlen++;
70094 + }
70095 +
70096 + log:
70097 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70098 + bprm->file->f_path.mnt, grarg);
70099 + mutex_unlock(&gr_exec_arg_mutex);
70100 +#endif
70101 + return;
70102 +}
70103 +
70104 +#ifdef CONFIG_GRKERNSEC
70105 +extern int gr_acl_is_capable(const int cap);
70106 +extern int gr_acl_is_capable_nolog(const int cap);
70107 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70108 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70109 +extern int gr_chroot_is_capable(const int cap);
70110 +extern int gr_chroot_is_capable_nolog(const int cap);
70111 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70112 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70113 +#endif
70114 +
70115 +const char *captab_log[] = {
70116 + "CAP_CHOWN",
70117 + "CAP_DAC_OVERRIDE",
70118 + "CAP_DAC_READ_SEARCH",
70119 + "CAP_FOWNER",
70120 + "CAP_FSETID",
70121 + "CAP_KILL",
70122 + "CAP_SETGID",
70123 + "CAP_SETUID",
70124 + "CAP_SETPCAP",
70125 + "CAP_LINUX_IMMUTABLE",
70126 + "CAP_NET_BIND_SERVICE",
70127 + "CAP_NET_BROADCAST",
70128 + "CAP_NET_ADMIN",
70129 + "CAP_NET_RAW",
70130 + "CAP_IPC_LOCK",
70131 + "CAP_IPC_OWNER",
70132 + "CAP_SYS_MODULE",
70133 + "CAP_SYS_RAWIO",
70134 + "CAP_SYS_CHROOT",
70135 + "CAP_SYS_PTRACE",
70136 + "CAP_SYS_PACCT",
70137 + "CAP_SYS_ADMIN",
70138 + "CAP_SYS_BOOT",
70139 + "CAP_SYS_NICE",
70140 + "CAP_SYS_RESOURCE",
70141 + "CAP_SYS_TIME",
70142 + "CAP_SYS_TTY_CONFIG",
70143 + "CAP_MKNOD",
70144 + "CAP_LEASE",
70145 + "CAP_AUDIT_WRITE",
70146 + "CAP_AUDIT_CONTROL",
70147 + "CAP_SETFCAP",
70148 + "CAP_MAC_OVERRIDE",
70149 + "CAP_MAC_ADMIN",
70150 + "CAP_SYSLOG",
70151 + "CAP_WAKE_ALARM"
70152 +};
70153 +
70154 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70155 +
70156 +int gr_is_capable(const int cap)
70157 +{
70158 +#ifdef CONFIG_GRKERNSEC
70159 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70160 + return 1;
70161 + return 0;
70162 +#else
70163 + return 1;
70164 +#endif
70165 +}
70166 +
70167 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70168 +{
70169 +#ifdef CONFIG_GRKERNSEC
70170 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70171 + return 1;
70172 + return 0;
70173 +#else
70174 + return 1;
70175 +#endif
70176 +}
70177 +
70178 +int gr_is_capable_nolog(const int cap)
70179 +{
70180 +#ifdef CONFIG_GRKERNSEC
70181 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70182 + return 1;
70183 + return 0;
70184 +#else
70185 + return 1;
70186 +#endif
70187 +}
70188 +
70189 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70190 +{
70191 +#ifdef CONFIG_GRKERNSEC
70192 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70193 + return 1;
70194 + return 0;
70195 +#else
70196 + return 1;
70197 +#endif
70198 +}
70199 +
70200 +EXPORT_SYMBOL(gr_is_capable);
70201 +EXPORT_SYMBOL(gr_is_capable_nolog);
70202 +EXPORT_SYMBOL(gr_task_is_capable);
70203 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70204 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70205 new file mode 100644
70206 index 0000000..06cc6ea
70207 --- /dev/null
70208 +++ b/grsecurity/grsec_fifo.c
70209 @@ -0,0 +1,24 @@
70210 +#include <linux/kernel.h>
70211 +#include <linux/sched.h>
70212 +#include <linux/fs.h>
70213 +#include <linux/file.h>
70214 +#include <linux/grinternal.h>
70215 +
70216 +int
70217 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70218 + const struct dentry *dir, const int flag, const int acc_mode)
70219 +{
70220 +#ifdef CONFIG_GRKERNSEC_FIFO
70221 + const struct cred *cred = current_cred();
70222 +
70223 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70224 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70225 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70226 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70227 + if (!inode_permission(dentry->d_inode, acc_mode))
70228 + 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));
70229 + return -EACCES;
70230 + }
70231 +#endif
70232 + return 0;
70233 +}
70234 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70235 new file mode 100644
70236 index 0000000..8ca18bf
70237 --- /dev/null
70238 +++ b/grsecurity/grsec_fork.c
70239 @@ -0,0 +1,23 @@
70240 +#include <linux/kernel.h>
70241 +#include <linux/sched.h>
70242 +#include <linux/grsecurity.h>
70243 +#include <linux/grinternal.h>
70244 +#include <linux/errno.h>
70245 +
70246 +void
70247 +gr_log_forkfail(const int retval)
70248 +{
70249 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70250 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70251 + switch (retval) {
70252 + case -EAGAIN:
70253 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70254 + break;
70255 + case -ENOMEM:
70256 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70257 + break;
70258 + }
70259 + }
70260 +#endif
70261 + return;
70262 +}
70263 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70264 new file mode 100644
70265 index 0000000..a88e901
70266 --- /dev/null
70267 +++ b/grsecurity/grsec_init.c
70268 @@ -0,0 +1,272 @@
70269 +#include <linux/kernel.h>
70270 +#include <linux/sched.h>
70271 +#include <linux/mm.h>
70272 +#include <linux/gracl.h>
70273 +#include <linux/slab.h>
70274 +#include <linux/vmalloc.h>
70275 +#include <linux/percpu.h>
70276 +#include <linux/module.h>
70277 +
70278 +int grsec_enable_ptrace_readexec;
70279 +int grsec_enable_setxid;
70280 +int grsec_enable_symlinkown;
70281 +kgid_t grsec_symlinkown_gid;
70282 +int grsec_enable_brute;
70283 +int grsec_enable_link;
70284 +int grsec_enable_dmesg;
70285 +int grsec_enable_harden_ptrace;
70286 +int grsec_enable_harden_ipc;
70287 +int grsec_enable_fifo;
70288 +int grsec_enable_execlog;
70289 +int grsec_enable_signal;
70290 +int grsec_enable_forkfail;
70291 +int grsec_enable_audit_ptrace;
70292 +int grsec_enable_time;
70293 +int grsec_enable_group;
70294 +kgid_t grsec_audit_gid;
70295 +int grsec_enable_chdir;
70296 +int grsec_enable_mount;
70297 +int grsec_enable_rofs;
70298 +int grsec_deny_new_usb;
70299 +int grsec_enable_chroot_findtask;
70300 +int grsec_enable_chroot_mount;
70301 +int grsec_enable_chroot_shmat;
70302 +int grsec_enable_chroot_fchdir;
70303 +int grsec_enable_chroot_double;
70304 +int grsec_enable_chroot_pivot;
70305 +int grsec_enable_chroot_chdir;
70306 +int grsec_enable_chroot_chmod;
70307 +int grsec_enable_chroot_mknod;
70308 +int grsec_enable_chroot_nice;
70309 +int grsec_enable_chroot_execlog;
70310 +int grsec_enable_chroot_caps;
70311 +int grsec_enable_chroot_sysctl;
70312 +int grsec_enable_chroot_unix;
70313 +int grsec_enable_tpe;
70314 +kgid_t grsec_tpe_gid;
70315 +int grsec_enable_blackhole;
70316 +#ifdef CONFIG_IPV6_MODULE
70317 +EXPORT_SYMBOL(grsec_enable_blackhole);
70318 +#endif
70319 +int grsec_lastack_retries;
70320 +int grsec_enable_tpe_all;
70321 +int grsec_enable_tpe_invert;
70322 +int grsec_enable_socket_all;
70323 +kgid_t grsec_socket_all_gid;
70324 +int grsec_enable_socket_client;
70325 +kgid_t grsec_socket_client_gid;
70326 +int grsec_enable_socket_server;
70327 +kgid_t grsec_socket_server_gid;
70328 +int grsec_resource_logging;
70329 +int grsec_disable_privio;
70330 +int grsec_enable_log_rwxmaps;
70331 +int grsec_lock;
70332 +
70333 +DEFINE_SPINLOCK(grsec_alert_lock);
70334 +unsigned long grsec_alert_wtime = 0;
70335 +unsigned long grsec_alert_fyet = 0;
70336 +
70337 +DEFINE_SPINLOCK(grsec_audit_lock);
70338 +
70339 +DEFINE_RWLOCK(grsec_exec_file_lock);
70340 +
70341 +char *gr_shared_page[4];
70342 +
70343 +char *gr_alert_log_fmt;
70344 +char *gr_audit_log_fmt;
70345 +char *gr_alert_log_buf;
70346 +char *gr_audit_log_buf;
70347 +
70348 +void __init
70349 +grsecurity_init(void)
70350 +{
70351 + int j;
70352 + /* create the per-cpu shared pages */
70353 +
70354 +#ifdef CONFIG_X86
70355 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
70356 +#endif
70357 +
70358 + for (j = 0; j < 4; j++) {
70359 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
70360 + if (gr_shared_page[j] == NULL) {
70361 + panic("Unable to allocate grsecurity shared page");
70362 + return;
70363 + }
70364 + }
70365 +
70366 + /* allocate log buffers */
70367 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
70368 + if (!gr_alert_log_fmt) {
70369 + panic("Unable to allocate grsecurity alert log format buffer");
70370 + return;
70371 + }
70372 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
70373 + if (!gr_audit_log_fmt) {
70374 + panic("Unable to allocate grsecurity audit log format buffer");
70375 + return;
70376 + }
70377 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70378 + if (!gr_alert_log_buf) {
70379 + panic("Unable to allocate grsecurity alert log buffer");
70380 + return;
70381 + }
70382 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70383 + if (!gr_audit_log_buf) {
70384 + panic("Unable to allocate grsecurity audit log buffer");
70385 + return;
70386 + }
70387 +
70388 +#ifdef CONFIG_GRKERNSEC_IO
70389 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
70390 + grsec_disable_privio = 1;
70391 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70392 + grsec_disable_privio = 1;
70393 +#else
70394 + grsec_disable_privio = 0;
70395 +#endif
70396 +#endif
70397 +
70398 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70399 + /* for backward compatibility, tpe_invert always defaults to on if
70400 + enabled in the kernel
70401 + */
70402 + grsec_enable_tpe_invert = 1;
70403 +#endif
70404 +
70405 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70406 +#ifndef CONFIG_GRKERNSEC_SYSCTL
70407 + grsec_lock = 1;
70408 +#endif
70409 +
70410 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70411 + grsec_enable_log_rwxmaps = 1;
70412 +#endif
70413 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70414 + grsec_enable_group = 1;
70415 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
70416 +#endif
70417 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70418 + grsec_enable_ptrace_readexec = 1;
70419 +#endif
70420 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70421 + grsec_enable_chdir = 1;
70422 +#endif
70423 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70424 + grsec_enable_harden_ptrace = 1;
70425 +#endif
70426 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70427 + grsec_enable_harden_ipc = 1;
70428 +#endif
70429 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70430 + grsec_enable_mount = 1;
70431 +#endif
70432 +#ifdef CONFIG_GRKERNSEC_LINK
70433 + grsec_enable_link = 1;
70434 +#endif
70435 +#ifdef CONFIG_GRKERNSEC_BRUTE
70436 + grsec_enable_brute = 1;
70437 +#endif
70438 +#ifdef CONFIG_GRKERNSEC_DMESG
70439 + grsec_enable_dmesg = 1;
70440 +#endif
70441 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70442 + grsec_enable_blackhole = 1;
70443 + grsec_lastack_retries = 4;
70444 +#endif
70445 +#ifdef CONFIG_GRKERNSEC_FIFO
70446 + grsec_enable_fifo = 1;
70447 +#endif
70448 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70449 + grsec_enable_execlog = 1;
70450 +#endif
70451 +#ifdef CONFIG_GRKERNSEC_SETXID
70452 + grsec_enable_setxid = 1;
70453 +#endif
70454 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70455 + grsec_enable_signal = 1;
70456 +#endif
70457 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70458 + grsec_enable_forkfail = 1;
70459 +#endif
70460 +#ifdef CONFIG_GRKERNSEC_TIME
70461 + grsec_enable_time = 1;
70462 +#endif
70463 +#ifdef CONFIG_GRKERNSEC_RESLOG
70464 + grsec_resource_logging = 1;
70465 +#endif
70466 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70467 + grsec_enable_chroot_findtask = 1;
70468 +#endif
70469 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70470 + grsec_enable_chroot_unix = 1;
70471 +#endif
70472 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70473 + grsec_enable_chroot_mount = 1;
70474 +#endif
70475 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70476 + grsec_enable_chroot_fchdir = 1;
70477 +#endif
70478 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70479 + grsec_enable_chroot_shmat = 1;
70480 +#endif
70481 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70482 + grsec_enable_audit_ptrace = 1;
70483 +#endif
70484 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70485 + grsec_enable_chroot_double = 1;
70486 +#endif
70487 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70488 + grsec_enable_chroot_pivot = 1;
70489 +#endif
70490 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70491 + grsec_enable_chroot_chdir = 1;
70492 +#endif
70493 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70494 + grsec_enable_chroot_chmod = 1;
70495 +#endif
70496 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70497 + grsec_enable_chroot_mknod = 1;
70498 +#endif
70499 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70500 + grsec_enable_chroot_nice = 1;
70501 +#endif
70502 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70503 + grsec_enable_chroot_execlog = 1;
70504 +#endif
70505 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70506 + grsec_enable_chroot_caps = 1;
70507 +#endif
70508 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70509 + grsec_enable_chroot_sysctl = 1;
70510 +#endif
70511 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70512 + grsec_enable_symlinkown = 1;
70513 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
70514 +#endif
70515 +#ifdef CONFIG_GRKERNSEC_TPE
70516 + grsec_enable_tpe = 1;
70517 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
70518 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70519 + grsec_enable_tpe_all = 1;
70520 +#endif
70521 +#endif
70522 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70523 + grsec_enable_socket_all = 1;
70524 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
70525 +#endif
70526 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70527 + grsec_enable_socket_client = 1;
70528 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
70529 +#endif
70530 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70531 + grsec_enable_socket_server = 1;
70532 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
70533 +#endif
70534 +#endif
70535 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
70536 + grsec_deny_new_usb = 1;
70537 +#endif
70538 +
70539 + return;
70540 +}
70541 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
70542 new file mode 100644
70543 index 0000000..f365de0
70544 --- /dev/null
70545 +++ b/grsecurity/grsec_ipc.c
70546 @@ -0,0 +1,22 @@
70547 +#include <linux/kernel.h>
70548 +#include <linux/mm.h>
70549 +#include <linux/sched.h>
70550 +#include <linux/file.h>
70551 +#include <linux/ipc.h>
70552 +#include <linux/ipc_namespace.h>
70553 +#include <linux/grsecurity.h>
70554 +#include <linux/grinternal.h>
70555 +
70556 +int
70557 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
70558 +{
70559 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70560 + int write = (requested_mode & 00002);
70561 +
70562 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
70563 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
70564 + return 0;
70565 + }
70566 +#endif
70567 + return 1;
70568 +}
70569 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
70570 new file mode 100644
70571 index 0000000..5e05e20
70572 --- /dev/null
70573 +++ b/grsecurity/grsec_link.c
70574 @@ -0,0 +1,58 @@
70575 +#include <linux/kernel.h>
70576 +#include <linux/sched.h>
70577 +#include <linux/fs.h>
70578 +#include <linux/file.h>
70579 +#include <linux/grinternal.h>
70580 +
70581 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
70582 +{
70583 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70584 + const struct inode *link_inode = link->dentry->d_inode;
70585 +
70586 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
70587 + /* ignore root-owned links, e.g. /proc/self */
70588 + gr_is_global_nonroot(link_inode->i_uid) && target &&
70589 + !uid_eq(link_inode->i_uid, target->i_uid)) {
70590 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
70591 + return 1;
70592 + }
70593 +#endif
70594 + return 0;
70595 +}
70596 +
70597 +int
70598 +gr_handle_follow_link(const struct inode *parent,
70599 + const struct inode *inode,
70600 + const struct dentry *dentry, const struct vfsmount *mnt)
70601 +{
70602 +#ifdef CONFIG_GRKERNSEC_LINK
70603 + const struct cred *cred = current_cred();
70604 +
70605 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
70606 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
70607 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
70608 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
70609 + return -EACCES;
70610 + }
70611 +#endif
70612 + return 0;
70613 +}
70614 +
70615 +int
70616 +gr_handle_hardlink(const struct dentry *dentry,
70617 + const struct vfsmount *mnt,
70618 + struct inode *inode, const int mode, const struct filename *to)
70619 +{
70620 +#ifdef CONFIG_GRKERNSEC_LINK
70621 + const struct cred *cred = current_cred();
70622 +
70623 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
70624 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
70625 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
70626 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
70627 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
70628 + return -EPERM;
70629 + }
70630 +#endif
70631 + return 0;
70632 +}
70633 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
70634 new file mode 100644
70635 index 0000000..dbe0a6b
70636 --- /dev/null
70637 +++ b/grsecurity/grsec_log.c
70638 @@ -0,0 +1,341 @@
70639 +#include <linux/kernel.h>
70640 +#include <linux/sched.h>
70641 +#include <linux/file.h>
70642 +#include <linux/tty.h>
70643 +#include <linux/fs.h>
70644 +#include <linux/mm.h>
70645 +#include <linux/grinternal.h>
70646 +
70647 +#ifdef CONFIG_TREE_PREEMPT_RCU
70648 +#define DISABLE_PREEMPT() preempt_disable()
70649 +#define ENABLE_PREEMPT() preempt_enable()
70650 +#else
70651 +#define DISABLE_PREEMPT()
70652 +#define ENABLE_PREEMPT()
70653 +#endif
70654 +
70655 +#define BEGIN_LOCKS(x) \
70656 + DISABLE_PREEMPT(); \
70657 + rcu_read_lock(); \
70658 + read_lock(&tasklist_lock); \
70659 + read_lock(&grsec_exec_file_lock); \
70660 + if (x != GR_DO_AUDIT) \
70661 + spin_lock(&grsec_alert_lock); \
70662 + else \
70663 + spin_lock(&grsec_audit_lock)
70664 +
70665 +#define END_LOCKS(x) \
70666 + if (x != GR_DO_AUDIT) \
70667 + spin_unlock(&grsec_alert_lock); \
70668 + else \
70669 + spin_unlock(&grsec_audit_lock); \
70670 + read_unlock(&grsec_exec_file_lock); \
70671 + read_unlock(&tasklist_lock); \
70672 + rcu_read_unlock(); \
70673 + ENABLE_PREEMPT(); \
70674 + if (x == GR_DONT_AUDIT) \
70675 + gr_handle_alertkill(current)
70676 +
70677 +enum {
70678 + FLOODING,
70679 + NO_FLOODING
70680 +};
70681 +
70682 +extern char *gr_alert_log_fmt;
70683 +extern char *gr_audit_log_fmt;
70684 +extern char *gr_alert_log_buf;
70685 +extern char *gr_audit_log_buf;
70686 +
70687 +static int gr_log_start(int audit)
70688 +{
70689 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
70690 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
70691 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70692 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
70693 + unsigned long curr_secs = get_seconds();
70694 +
70695 + if (audit == GR_DO_AUDIT)
70696 + goto set_fmt;
70697 +
70698 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
70699 + grsec_alert_wtime = curr_secs;
70700 + grsec_alert_fyet = 0;
70701 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
70702 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
70703 + grsec_alert_fyet++;
70704 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
70705 + grsec_alert_wtime = curr_secs;
70706 + grsec_alert_fyet++;
70707 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
70708 + return FLOODING;
70709 + }
70710 + else return FLOODING;
70711 +
70712 +set_fmt:
70713 +#endif
70714 + memset(buf, 0, PAGE_SIZE);
70715 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
70716 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
70717 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70718 + } else if (current->signal->curr_ip) {
70719 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
70720 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
70721 + } else if (gr_acl_is_enabled()) {
70722 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
70723 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70724 + } else {
70725 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
70726 + strcpy(buf, fmt);
70727 + }
70728 +
70729 + return NO_FLOODING;
70730 +}
70731 +
70732 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70733 + __attribute__ ((format (printf, 2, 0)));
70734 +
70735 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70736 +{
70737 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70738 + unsigned int len = strlen(buf);
70739 +
70740 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70741 +
70742 + return;
70743 +}
70744 +
70745 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70746 + __attribute__ ((format (printf, 2, 3)));
70747 +
70748 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70749 +{
70750 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70751 + unsigned int len = strlen(buf);
70752 + va_list ap;
70753 +
70754 + va_start(ap, msg);
70755 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70756 + va_end(ap);
70757 +
70758 + return;
70759 +}
70760 +
70761 +static void gr_log_end(int audit, int append_default)
70762 +{
70763 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70764 + if (append_default) {
70765 + struct task_struct *task = current;
70766 + struct task_struct *parent = task->real_parent;
70767 + const struct cred *cred = __task_cred(task);
70768 + const struct cred *pcred = __task_cred(parent);
70769 + unsigned int len = strlen(buf);
70770 +
70771 + 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));
70772 + }
70773 +
70774 + printk("%s\n", buf);
70775 +
70776 + return;
70777 +}
70778 +
70779 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70780 +{
70781 + int logtype;
70782 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70783 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70784 + void *voidptr = NULL;
70785 + int num1 = 0, num2 = 0;
70786 + unsigned long ulong1 = 0, ulong2 = 0;
70787 + struct dentry *dentry = NULL;
70788 + struct vfsmount *mnt = NULL;
70789 + struct file *file = NULL;
70790 + struct task_struct *task = NULL;
70791 + struct vm_area_struct *vma = NULL;
70792 + const struct cred *cred, *pcred;
70793 + va_list ap;
70794 +
70795 + BEGIN_LOCKS(audit);
70796 + logtype = gr_log_start(audit);
70797 + if (logtype == FLOODING) {
70798 + END_LOCKS(audit);
70799 + return;
70800 + }
70801 + va_start(ap, argtypes);
70802 + switch (argtypes) {
70803 + case GR_TTYSNIFF:
70804 + task = va_arg(ap, struct task_struct *);
70805 + 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));
70806 + break;
70807 + case GR_SYSCTL_HIDDEN:
70808 + str1 = va_arg(ap, char *);
70809 + gr_log_middle_varargs(audit, msg, result, str1);
70810 + break;
70811 + case GR_RBAC:
70812 + dentry = va_arg(ap, struct dentry *);
70813 + mnt = va_arg(ap, struct vfsmount *);
70814 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70815 + break;
70816 + case GR_RBAC_STR:
70817 + dentry = va_arg(ap, struct dentry *);
70818 + mnt = va_arg(ap, struct vfsmount *);
70819 + str1 = va_arg(ap, char *);
70820 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70821 + break;
70822 + case GR_STR_RBAC:
70823 + str1 = va_arg(ap, char *);
70824 + dentry = va_arg(ap, struct dentry *);
70825 + mnt = va_arg(ap, struct vfsmount *);
70826 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70827 + break;
70828 + case GR_RBAC_MODE2:
70829 + dentry = va_arg(ap, struct dentry *);
70830 + mnt = va_arg(ap, struct vfsmount *);
70831 + str1 = va_arg(ap, char *);
70832 + str2 = va_arg(ap, char *);
70833 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70834 + break;
70835 + case GR_RBAC_MODE3:
70836 + dentry = va_arg(ap, struct dentry *);
70837 + mnt = va_arg(ap, struct vfsmount *);
70838 + str1 = va_arg(ap, char *);
70839 + str2 = va_arg(ap, char *);
70840 + str3 = va_arg(ap, char *);
70841 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70842 + break;
70843 + case GR_FILENAME:
70844 + dentry = va_arg(ap, struct dentry *);
70845 + mnt = va_arg(ap, struct vfsmount *);
70846 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70847 + break;
70848 + case GR_STR_FILENAME:
70849 + str1 = va_arg(ap, char *);
70850 + dentry = va_arg(ap, struct dentry *);
70851 + mnt = va_arg(ap, struct vfsmount *);
70852 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70853 + break;
70854 + case GR_FILENAME_STR:
70855 + dentry = va_arg(ap, struct dentry *);
70856 + mnt = va_arg(ap, struct vfsmount *);
70857 + str1 = va_arg(ap, char *);
70858 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70859 + break;
70860 + case GR_FILENAME_TWO_INT:
70861 + dentry = va_arg(ap, struct dentry *);
70862 + mnt = va_arg(ap, struct vfsmount *);
70863 + num1 = va_arg(ap, int);
70864 + num2 = va_arg(ap, int);
70865 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70866 + break;
70867 + case GR_FILENAME_TWO_INT_STR:
70868 + dentry = va_arg(ap, struct dentry *);
70869 + mnt = va_arg(ap, struct vfsmount *);
70870 + num1 = va_arg(ap, int);
70871 + num2 = va_arg(ap, int);
70872 + str1 = va_arg(ap, char *);
70873 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70874 + break;
70875 + case GR_TEXTREL:
70876 + file = va_arg(ap, struct file *);
70877 + ulong1 = va_arg(ap, unsigned long);
70878 + ulong2 = va_arg(ap, unsigned long);
70879 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70880 + break;
70881 + case GR_PTRACE:
70882 + task = va_arg(ap, struct task_struct *);
70883 + 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));
70884 + break;
70885 + case GR_RESOURCE:
70886 + task = va_arg(ap, struct task_struct *);
70887 + cred = __task_cred(task);
70888 + pcred = __task_cred(task->real_parent);
70889 + ulong1 = va_arg(ap, unsigned long);
70890 + str1 = va_arg(ap, char *);
70891 + ulong2 = va_arg(ap, unsigned long);
70892 + 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));
70893 + break;
70894 + case GR_CAP:
70895 + task = va_arg(ap, struct task_struct *);
70896 + cred = __task_cred(task);
70897 + pcred = __task_cred(task->real_parent);
70898 + str1 = va_arg(ap, char *);
70899 + 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));
70900 + break;
70901 + case GR_SIG:
70902 + str1 = va_arg(ap, char *);
70903 + voidptr = va_arg(ap, void *);
70904 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70905 + break;
70906 + case GR_SIG2:
70907 + task = va_arg(ap, struct task_struct *);
70908 + cred = __task_cred(task);
70909 + pcred = __task_cred(task->real_parent);
70910 + num1 = va_arg(ap, int);
70911 + 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));
70912 + break;
70913 + case GR_CRASH1:
70914 + task = va_arg(ap, struct task_struct *);
70915 + cred = __task_cred(task);
70916 + pcred = __task_cred(task->real_parent);
70917 + ulong1 = va_arg(ap, unsigned long);
70918 + 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);
70919 + break;
70920 + case GR_CRASH2:
70921 + task = va_arg(ap, struct task_struct *);
70922 + cred = __task_cred(task);
70923 + pcred = __task_cred(task->real_parent);
70924 + ulong1 = va_arg(ap, unsigned long);
70925 + 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);
70926 + break;
70927 + case GR_RWXMAP:
70928 + file = va_arg(ap, struct file *);
70929 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70930 + break;
70931 + case GR_RWXMAPVMA:
70932 + vma = va_arg(ap, struct vm_area_struct *);
70933 + if (vma->vm_file)
70934 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70935 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70936 + str1 = "<stack>";
70937 + else if (vma->vm_start <= current->mm->brk &&
70938 + vma->vm_end >= current->mm->start_brk)
70939 + str1 = "<heap>";
70940 + else
70941 + str1 = "<anonymous mapping>";
70942 + gr_log_middle_varargs(audit, msg, str1);
70943 + break;
70944 + case GR_PSACCT:
70945 + {
70946 + unsigned int wday, cday;
70947 + __u8 whr, chr;
70948 + __u8 wmin, cmin;
70949 + __u8 wsec, csec;
70950 + char cur_tty[64] = { 0 };
70951 + char parent_tty[64] = { 0 };
70952 +
70953 + task = va_arg(ap, struct task_struct *);
70954 + wday = va_arg(ap, unsigned int);
70955 + cday = va_arg(ap, unsigned int);
70956 + whr = va_arg(ap, int);
70957 + chr = va_arg(ap, int);
70958 + wmin = va_arg(ap, int);
70959 + cmin = va_arg(ap, int);
70960 + wsec = va_arg(ap, int);
70961 + csec = va_arg(ap, int);
70962 + ulong1 = va_arg(ap, unsigned long);
70963 + cred = __task_cred(task);
70964 + pcred = __task_cred(task->real_parent);
70965 +
70966 + 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));
70967 + }
70968 + break;
70969 + default:
70970 + gr_log_middle(audit, msg, ap);
70971 + }
70972 + va_end(ap);
70973 + // these don't need DEFAULTSECARGS printed on the end
70974 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70975 + gr_log_end(audit, 0);
70976 + else
70977 + gr_log_end(audit, 1);
70978 + END_LOCKS(audit);
70979 +}
70980 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70981 new file mode 100644
70982 index 0000000..f536303
70983 --- /dev/null
70984 +++ b/grsecurity/grsec_mem.c
70985 @@ -0,0 +1,40 @@
70986 +#include <linux/kernel.h>
70987 +#include <linux/sched.h>
70988 +#include <linux/mm.h>
70989 +#include <linux/mman.h>
70990 +#include <linux/grinternal.h>
70991 +
70992 +void
70993 +gr_handle_ioperm(void)
70994 +{
70995 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70996 + return;
70997 +}
70998 +
70999 +void
71000 +gr_handle_iopl(void)
71001 +{
71002 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71003 + return;
71004 +}
71005 +
71006 +void
71007 +gr_handle_mem_readwrite(u64 from, u64 to)
71008 +{
71009 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71010 + return;
71011 +}
71012 +
71013 +void
71014 +gr_handle_vm86(void)
71015 +{
71016 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71017 + return;
71018 +}
71019 +
71020 +void
71021 +gr_log_badprocpid(const char *entry)
71022 +{
71023 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71024 + return;
71025 +}
71026 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71027 new file mode 100644
71028 index 0000000..2131422
71029 --- /dev/null
71030 +++ b/grsecurity/grsec_mount.c
71031 @@ -0,0 +1,62 @@
71032 +#include <linux/kernel.h>
71033 +#include <linux/sched.h>
71034 +#include <linux/mount.h>
71035 +#include <linux/grsecurity.h>
71036 +#include <linux/grinternal.h>
71037 +
71038 +void
71039 +gr_log_remount(const char *devname, const int retval)
71040 +{
71041 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71042 + if (grsec_enable_mount && (retval >= 0))
71043 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71044 +#endif
71045 + return;
71046 +}
71047 +
71048 +void
71049 +gr_log_unmount(const char *devname, const int retval)
71050 +{
71051 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71052 + if (grsec_enable_mount && (retval >= 0))
71053 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71054 +#endif
71055 + return;
71056 +}
71057 +
71058 +void
71059 +gr_log_mount(const char *from, const char *to, const int retval)
71060 +{
71061 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71062 + if (grsec_enable_mount && (retval >= 0))
71063 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71064 +#endif
71065 + return;
71066 +}
71067 +
71068 +int
71069 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71070 +{
71071 +#ifdef CONFIG_GRKERNSEC_ROFS
71072 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71073 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71074 + return -EPERM;
71075 + } else
71076 + return 0;
71077 +#endif
71078 + return 0;
71079 +}
71080 +
71081 +int
71082 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71083 +{
71084 +#ifdef CONFIG_GRKERNSEC_ROFS
71085 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71086 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71087 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71088 + return -EPERM;
71089 + } else
71090 + return 0;
71091 +#endif
71092 + return 0;
71093 +}
71094 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71095 new file mode 100644
71096 index 0000000..6ee9d50
71097 --- /dev/null
71098 +++ b/grsecurity/grsec_pax.c
71099 @@ -0,0 +1,45 @@
71100 +#include <linux/kernel.h>
71101 +#include <linux/sched.h>
71102 +#include <linux/mm.h>
71103 +#include <linux/file.h>
71104 +#include <linux/grinternal.h>
71105 +#include <linux/grsecurity.h>
71106 +
71107 +void
71108 +gr_log_textrel(struct vm_area_struct * vma)
71109 +{
71110 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71111 + if (grsec_enable_log_rwxmaps)
71112 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71113 +#endif
71114 + return;
71115 +}
71116 +
71117 +void gr_log_ptgnustack(struct file *file)
71118 +{
71119 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71120 + if (grsec_enable_log_rwxmaps)
71121 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71122 +#endif
71123 + return;
71124 +}
71125 +
71126 +void
71127 +gr_log_rwxmmap(struct file *file)
71128 +{
71129 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71130 + if (grsec_enable_log_rwxmaps)
71131 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71132 +#endif
71133 + return;
71134 +}
71135 +
71136 +void
71137 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71138 +{
71139 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71140 + if (grsec_enable_log_rwxmaps)
71141 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71142 +#endif
71143 + return;
71144 +}
71145 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71146 new file mode 100644
71147 index 0000000..f7f29aa
71148 --- /dev/null
71149 +++ b/grsecurity/grsec_ptrace.c
71150 @@ -0,0 +1,30 @@
71151 +#include <linux/kernel.h>
71152 +#include <linux/sched.h>
71153 +#include <linux/grinternal.h>
71154 +#include <linux/security.h>
71155 +
71156 +void
71157 +gr_audit_ptrace(struct task_struct *task)
71158 +{
71159 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71160 + if (grsec_enable_audit_ptrace)
71161 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71162 +#endif
71163 + return;
71164 +}
71165 +
71166 +int
71167 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71168 +{
71169 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71170 + const struct dentry *dentry = file->f_path.dentry;
71171 + const struct vfsmount *mnt = file->f_path.mnt;
71172 +
71173 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71174 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71175 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71176 + return -EACCES;
71177 + }
71178 +#endif
71179 + return 0;
71180 +}
71181 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71182 new file mode 100644
71183 index 0000000..4e29cc7
71184 --- /dev/null
71185 +++ b/grsecurity/grsec_sig.c
71186 @@ -0,0 +1,246 @@
71187 +#include <linux/kernel.h>
71188 +#include <linux/sched.h>
71189 +#include <linux/fs.h>
71190 +#include <linux/delay.h>
71191 +#include <linux/grsecurity.h>
71192 +#include <linux/grinternal.h>
71193 +#include <linux/hardirq.h>
71194 +
71195 +char *signames[] = {
71196 + [SIGSEGV] = "Segmentation fault",
71197 + [SIGILL] = "Illegal instruction",
71198 + [SIGABRT] = "Abort",
71199 + [SIGBUS] = "Invalid alignment/Bus error"
71200 +};
71201 +
71202 +void
71203 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71204 +{
71205 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71206 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71207 + (sig == SIGABRT) || (sig == SIGBUS))) {
71208 + if (task_pid_nr(t) == task_pid_nr(current)) {
71209 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71210 + } else {
71211 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71212 + }
71213 + }
71214 +#endif
71215 + return;
71216 +}
71217 +
71218 +int
71219 +gr_handle_signal(const struct task_struct *p, const int sig)
71220 +{
71221 +#ifdef CONFIG_GRKERNSEC
71222 + /* ignore the 0 signal for protected task checks */
71223 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71224 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71225 + return -EPERM;
71226 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71227 + return -EPERM;
71228 + }
71229 +#endif
71230 + return 0;
71231 +}
71232 +
71233 +#ifdef CONFIG_GRKERNSEC
71234 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71235 +
71236 +int gr_fake_force_sig(int sig, struct task_struct *t)
71237 +{
71238 + unsigned long int flags;
71239 + int ret, blocked, ignored;
71240 + struct k_sigaction *action;
71241 +
71242 + spin_lock_irqsave(&t->sighand->siglock, flags);
71243 + action = &t->sighand->action[sig-1];
71244 + ignored = action->sa.sa_handler == SIG_IGN;
71245 + blocked = sigismember(&t->blocked, sig);
71246 + if (blocked || ignored) {
71247 + action->sa.sa_handler = SIG_DFL;
71248 + if (blocked) {
71249 + sigdelset(&t->blocked, sig);
71250 + recalc_sigpending_and_wake(t);
71251 + }
71252 + }
71253 + if (action->sa.sa_handler == SIG_DFL)
71254 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71255 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71256 +
71257 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71258 +
71259 + return ret;
71260 +}
71261 +#endif
71262 +
71263 +#ifdef CONFIG_GRKERNSEC_BRUTE
71264 +#define GR_USER_BAN_TIME (15 * 60)
71265 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71266 +
71267 +static int __get_dumpable(unsigned long mm_flags)
71268 +{
71269 + int ret;
71270 +
71271 + ret = mm_flags & MMF_DUMPABLE_MASK;
71272 + return (ret >= 2) ? 2 : ret;
71273 +}
71274 +#endif
71275 +
71276 +void gr_handle_brute_attach(unsigned long mm_flags)
71277 +{
71278 +#ifdef CONFIG_GRKERNSEC_BRUTE
71279 + struct task_struct *p = current;
71280 + kuid_t uid = GLOBAL_ROOT_UID;
71281 + int daemon = 0;
71282 +
71283 + if (!grsec_enable_brute)
71284 + return;
71285 +
71286 + rcu_read_lock();
71287 + read_lock(&tasklist_lock);
71288 + read_lock(&grsec_exec_file_lock);
71289 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71290 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71291 + p->real_parent->brute = 1;
71292 + daemon = 1;
71293 + } else {
71294 + const struct cred *cred = __task_cred(p), *cred2;
71295 + struct task_struct *tsk, *tsk2;
71296 +
71297 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
71298 + struct user_struct *user;
71299 +
71300 + uid = cred->uid;
71301 +
71302 + /* this is put upon execution past expiration */
71303 + user = find_user(uid);
71304 + if (user == NULL)
71305 + goto unlock;
71306 + user->suid_banned = 1;
71307 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
71308 + if (user->suid_ban_expires == ~0UL)
71309 + user->suid_ban_expires--;
71310 +
71311 + /* only kill other threads of the same binary, from the same user */
71312 + do_each_thread(tsk2, tsk) {
71313 + cred2 = __task_cred(tsk);
71314 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
71315 + gr_fake_force_sig(SIGKILL, tsk);
71316 + } while_each_thread(tsk2, tsk);
71317 + }
71318 + }
71319 +unlock:
71320 + read_unlock(&grsec_exec_file_lock);
71321 + read_unlock(&tasklist_lock);
71322 + rcu_read_unlock();
71323 +
71324 + if (gr_is_global_nonroot(uid))
71325 + 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);
71326 + else if (daemon)
71327 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
71328 +
71329 +#endif
71330 + return;
71331 +}
71332 +
71333 +void gr_handle_brute_check(void)
71334 +{
71335 +#ifdef CONFIG_GRKERNSEC_BRUTE
71336 + struct task_struct *p = current;
71337 +
71338 + if (unlikely(p->brute)) {
71339 + if (!grsec_enable_brute)
71340 + p->brute = 0;
71341 + else if (time_before(get_seconds(), p->brute_expires))
71342 + msleep(30 * 1000);
71343 + }
71344 +#endif
71345 + return;
71346 +}
71347 +
71348 +void gr_handle_kernel_exploit(void)
71349 +{
71350 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71351 + const struct cred *cred;
71352 + struct task_struct *tsk, *tsk2;
71353 + struct user_struct *user;
71354 + kuid_t uid;
71355 +
71356 + if (in_irq() || in_serving_softirq() || in_nmi())
71357 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
71358 +
71359 + uid = current_uid();
71360 +
71361 + if (gr_is_global_root(uid))
71362 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
71363 + else {
71364 + /* kill all the processes of this user, hold a reference
71365 + to their creds struct, and prevent them from creating
71366 + another process until system reset
71367 + */
71368 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
71369 + GR_GLOBAL_UID(uid));
71370 + /* we intentionally leak this ref */
71371 + user = get_uid(current->cred->user);
71372 + if (user)
71373 + user->kernel_banned = 1;
71374 +
71375 + /* kill all processes of this user */
71376 + read_lock(&tasklist_lock);
71377 + do_each_thread(tsk2, tsk) {
71378 + cred = __task_cred(tsk);
71379 + if (uid_eq(cred->uid, uid))
71380 + gr_fake_force_sig(SIGKILL, tsk);
71381 + } while_each_thread(tsk2, tsk);
71382 + read_unlock(&tasklist_lock);
71383 + }
71384 +#endif
71385 +}
71386 +
71387 +#ifdef CONFIG_GRKERNSEC_BRUTE
71388 +static bool suid_ban_expired(struct user_struct *user)
71389 +{
71390 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
71391 + user->suid_banned = 0;
71392 + user->suid_ban_expires = 0;
71393 + free_uid(user);
71394 + return true;
71395 + }
71396 +
71397 + return false;
71398 +}
71399 +#endif
71400 +
71401 +int gr_process_kernel_exec_ban(void)
71402 +{
71403 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71404 + if (unlikely(current->cred->user->kernel_banned))
71405 + return -EPERM;
71406 +#endif
71407 + return 0;
71408 +}
71409 +
71410 +int gr_process_kernel_setuid_ban(struct user_struct *user)
71411 +{
71412 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71413 + if (unlikely(user->kernel_banned))
71414 + gr_fake_force_sig(SIGKILL, current);
71415 +#endif
71416 + return 0;
71417 +}
71418 +
71419 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
71420 +{
71421 +#ifdef CONFIG_GRKERNSEC_BRUTE
71422 + struct user_struct *user = current->cred->user;
71423 + if (unlikely(user->suid_banned)) {
71424 + if (suid_ban_expired(user))
71425 + return 0;
71426 + /* disallow execution of suid binaries only */
71427 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
71428 + return -EPERM;
71429 + }
71430 +#endif
71431 + return 0;
71432 +}
71433 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
71434 new file mode 100644
71435 index 0000000..4030d57
71436 --- /dev/null
71437 +++ b/grsecurity/grsec_sock.c
71438 @@ -0,0 +1,244 @@
71439 +#include <linux/kernel.h>
71440 +#include <linux/module.h>
71441 +#include <linux/sched.h>
71442 +#include <linux/file.h>
71443 +#include <linux/net.h>
71444 +#include <linux/in.h>
71445 +#include <linux/ip.h>
71446 +#include <net/sock.h>
71447 +#include <net/inet_sock.h>
71448 +#include <linux/grsecurity.h>
71449 +#include <linux/grinternal.h>
71450 +#include <linux/gracl.h>
71451 +
71452 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
71453 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
71454 +
71455 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
71456 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
71457 +
71458 +#ifdef CONFIG_UNIX_MODULE
71459 +EXPORT_SYMBOL(gr_acl_handle_unix);
71460 +EXPORT_SYMBOL(gr_acl_handle_mknod);
71461 +EXPORT_SYMBOL(gr_handle_chroot_unix);
71462 +EXPORT_SYMBOL(gr_handle_create);
71463 +#endif
71464 +
71465 +#ifdef CONFIG_GRKERNSEC
71466 +#define gr_conn_table_size 32749
71467 +struct conn_table_entry {
71468 + struct conn_table_entry *next;
71469 + struct signal_struct *sig;
71470 +};
71471 +
71472 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
71473 +DEFINE_SPINLOCK(gr_conn_table_lock);
71474 +
71475 +extern const char * gr_socktype_to_name(unsigned char type);
71476 +extern const char * gr_proto_to_name(unsigned char proto);
71477 +extern const char * gr_sockfamily_to_name(unsigned char family);
71478 +
71479 +static __inline__ int
71480 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
71481 +{
71482 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
71483 +}
71484 +
71485 +static __inline__ int
71486 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
71487 + __u16 sport, __u16 dport)
71488 +{
71489 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
71490 + sig->gr_sport == sport && sig->gr_dport == dport))
71491 + return 1;
71492 + else
71493 + return 0;
71494 +}
71495 +
71496 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
71497 +{
71498 + struct conn_table_entry **match;
71499 + unsigned int index;
71500 +
71501 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71502 + sig->gr_sport, sig->gr_dport,
71503 + gr_conn_table_size);
71504 +
71505 + newent->sig = sig;
71506 +
71507 + match = &gr_conn_table[index];
71508 + newent->next = *match;
71509 + *match = newent;
71510 +
71511 + return;
71512 +}
71513 +
71514 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
71515 +{
71516 + struct conn_table_entry *match, *last = NULL;
71517 + unsigned int index;
71518 +
71519 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71520 + sig->gr_sport, sig->gr_dport,
71521 + gr_conn_table_size);
71522 +
71523 + match = gr_conn_table[index];
71524 + while (match && !conn_match(match->sig,
71525 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
71526 + sig->gr_dport)) {
71527 + last = match;
71528 + match = match->next;
71529 + }
71530 +
71531 + if (match) {
71532 + if (last)
71533 + last->next = match->next;
71534 + else
71535 + gr_conn_table[index] = NULL;
71536 + kfree(match);
71537 + }
71538 +
71539 + return;
71540 +}
71541 +
71542 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
71543 + __u16 sport, __u16 dport)
71544 +{
71545 + struct conn_table_entry *match;
71546 + unsigned int index;
71547 +
71548 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
71549 +
71550 + match = gr_conn_table[index];
71551 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
71552 + match = match->next;
71553 +
71554 + if (match)
71555 + return match->sig;
71556 + else
71557 + return NULL;
71558 +}
71559 +
71560 +#endif
71561 +
71562 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
71563 +{
71564 +#ifdef CONFIG_GRKERNSEC
71565 + struct signal_struct *sig = task->signal;
71566 + struct conn_table_entry *newent;
71567 +
71568 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
71569 + if (newent == NULL)
71570 + return;
71571 + /* no bh lock needed since we are called with bh disabled */
71572 + spin_lock(&gr_conn_table_lock);
71573 + gr_del_task_from_ip_table_nolock(sig);
71574 + sig->gr_saddr = inet->inet_rcv_saddr;
71575 + sig->gr_daddr = inet->inet_daddr;
71576 + sig->gr_sport = inet->inet_sport;
71577 + sig->gr_dport = inet->inet_dport;
71578 + gr_add_to_task_ip_table_nolock(sig, newent);
71579 + spin_unlock(&gr_conn_table_lock);
71580 +#endif
71581 + return;
71582 +}
71583 +
71584 +void gr_del_task_from_ip_table(struct task_struct *task)
71585 +{
71586 +#ifdef CONFIG_GRKERNSEC
71587 + spin_lock_bh(&gr_conn_table_lock);
71588 + gr_del_task_from_ip_table_nolock(task->signal);
71589 + spin_unlock_bh(&gr_conn_table_lock);
71590 +#endif
71591 + return;
71592 +}
71593 +
71594 +void
71595 +gr_attach_curr_ip(const struct sock *sk)
71596 +{
71597 +#ifdef CONFIG_GRKERNSEC
71598 + struct signal_struct *p, *set;
71599 + const struct inet_sock *inet = inet_sk(sk);
71600 +
71601 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
71602 + return;
71603 +
71604 + set = current->signal;
71605 +
71606 + spin_lock_bh(&gr_conn_table_lock);
71607 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
71608 + inet->inet_dport, inet->inet_sport);
71609 + if (unlikely(p != NULL)) {
71610 + set->curr_ip = p->curr_ip;
71611 + set->used_accept = 1;
71612 + gr_del_task_from_ip_table_nolock(p);
71613 + spin_unlock_bh(&gr_conn_table_lock);
71614 + return;
71615 + }
71616 + spin_unlock_bh(&gr_conn_table_lock);
71617 +
71618 + set->curr_ip = inet->inet_daddr;
71619 + set->used_accept = 1;
71620 +#endif
71621 + return;
71622 +}
71623 +
71624 +int
71625 +gr_handle_sock_all(const int family, const int type, const int protocol)
71626 +{
71627 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71628 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
71629 + (family != AF_UNIX)) {
71630 + if (family == AF_INET)
71631 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
71632 + else
71633 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
71634 + return -EACCES;
71635 + }
71636 +#endif
71637 + return 0;
71638 +}
71639 +
71640 +int
71641 +gr_handle_sock_server(const struct sockaddr *sck)
71642 +{
71643 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71644 + if (grsec_enable_socket_server &&
71645 + in_group_p(grsec_socket_server_gid) &&
71646 + sck && (sck->sa_family != AF_UNIX) &&
71647 + (sck->sa_family != AF_LOCAL)) {
71648 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71649 + return -EACCES;
71650 + }
71651 +#endif
71652 + return 0;
71653 +}
71654 +
71655 +int
71656 +gr_handle_sock_server_other(const struct sock *sck)
71657 +{
71658 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71659 + if (grsec_enable_socket_server &&
71660 + in_group_p(grsec_socket_server_gid) &&
71661 + sck && (sck->sk_family != AF_UNIX) &&
71662 + (sck->sk_family != AF_LOCAL)) {
71663 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71664 + return -EACCES;
71665 + }
71666 +#endif
71667 + return 0;
71668 +}
71669 +
71670 +int
71671 +gr_handle_sock_client(const struct sockaddr *sck)
71672 +{
71673 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71674 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
71675 + sck && (sck->sa_family != AF_UNIX) &&
71676 + (sck->sa_family != AF_LOCAL)) {
71677 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
71678 + return -EACCES;
71679 + }
71680 +#endif
71681 + return 0;
71682 +}
71683 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
71684 new file mode 100644
71685 index 0000000..8159888
71686 --- /dev/null
71687 +++ b/grsecurity/grsec_sysctl.c
71688 @@ -0,0 +1,479 @@
71689 +#include <linux/kernel.h>
71690 +#include <linux/sched.h>
71691 +#include <linux/sysctl.h>
71692 +#include <linux/grsecurity.h>
71693 +#include <linux/grinternal.h>
71694 +
71695 +int
71696 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
71697 +{
71698 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71699 + if (dirname == NULL || name == NULL)
71700 + return 0;
71701 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
71702 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
71703 + return -EACCES;
71704 + }
71705 +#endif
71706 + return 0;
71707 +}
71708 +
71709 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
71710 +static int __maybe_unused __read_only one = 1;
71711 +#endif
71712 +
71713 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
71714 + defined(CONFIG_GRKERNSEC_DENYUSB)
71715 +struct ctl_table grsecurity_table[] = {
71716 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71717 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
71718 +#ifdef CONFIG_GRKERNSEC_IO
71719 + {
71720 + .procname = "disable_priv_io",
71721 + .data = &grsec_disable_privio,
71722 + .maxlen = sizeof(int),
71723 + .mode = 0600,
71724 + .proc_handler = &proc_dointvec,
71725 + },
71726 +#endif
71727 +#endif
71728 +#ifdef CONFIG_GRKERNSEC_LINK
71729 + {
71730 + .procname = "linking_restrictions",
71731 + .data = &grsec_enable_link,
71732 + .maxlen = sizeof(int),
71733 + .mode = 0600,
71734 + .proc_handler = &proc_dointvec,
71735 + },
71736 +#endif
71737 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71738 + {
71739 + .procname = "enforce_symlinksifowner",
71740 + .data = &grsec_enable_symlinkown,
71741 + .maxlen = sizeof(int),
71742 + .mode = 0600,
71743 + .proc_handler = &proc_dointvec,
71744 + },
71745 + {
71746 + .procname = "symlinkown_gid",
71747 + .data = &grsec_symlinkown_gid,
71748 + .maxlen = sizeof(int),
71749 + .mode = 0600,
71750 + .proc_handler = &proc_dointvec,
71751 + },
71752 +#endif
71753 +#ifdef CONFIG_GRKERNSEC_BRUTE
71754 + {
71755 + .procname = "deter_bruteforce",
71756 + .data = &grsec_enable_brute,
71757 + .maxlen = sizeof(int),
71758 + .mode = 0600,
71759 + .proc_handler = &proc_dointvec,
71760 + },
71761 +#endif
71762 +#ifdef CONFIG_GRKERNSEC_FIFO
71763 + {
71764 + .procname = "fifo_restrictions",
71765 + .data = &grsec_enable_fifo,
71766 + .maxlen = sizeof(int),
71767 + .mode = 0600,
71768 + .proc_handler = &proc_dointvec,
71769 + },
71770 +#endif
71771 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71772 + {
71773 + .procname = "ptrace_readexec",
71774 + .data = &grsec_enable_ptrace_readexec,
71775 + .maxlen = sizeof(int),
71776 + .mode = 0600,
71777 + .proc_handler = &proc_dointvec,
71778 + },
71779 +#endif
71780 +#ifdef CONFIG_GRKERNSEC_SETXID
71781 + {
71782 + .procname = "consistent_setxid",
71783 + .data = &grsec_enable_setxid,
71784 + .maxlen = sizeof(int),
71785 + .mode = 0600,
71786 + .proc_handler = &proc_dointvec,
71787 + },
71788 +#endif
71789 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71790 + {
71791 + .procname = "ip_blackhole",
71792 + .data = &grsec_enable_blackhole,
71793 + .maxlen = sizeof(int),
71794 + .mode = 0600,
71795 + .proc_handler = &proc_dointvec,
71796 + },
71797 + {
71798 + .procname = "lastack_retries",
71799 + .data = &grsec_lastack_retries,
71800 + .maxlen = sizeof(int),
71801 + .mode = 0600,
71802 + .proc_handler = &proc_dointvec,
71803 + },
71804 +#endif
71805 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71806 + {
71807 + .procname = "exec_logging",
71808 + .data = &grsec_enable_execlog,
71809 + .maxlen = sizeof(int),
71810 + .mode = 0600,
71811 + .proc_handler = &proc_dointvec,
71812 + },
71813 +#endif
71814 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71815 + {
71816 + .procname = "rwxmap_logging",
71817 + .data = &grsec_enable_log_rwxmaps,
71818 + .maxlen = sizeof(int),
71819 + .mode = 0600,
71820 + .proc_handler = &proc_dointvec,
71821 + },
71822 +#endif
71823 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71824 + {
71825 + .procname = "signal_logging",
71826 + .data = &grsec_enable_signal,
71827 + .maxlen = sizeof(int),
71828 + .mode = 0600,
71829 + .proc_handler = &proc_dointvec,
71830 + },
71831 +#endif
71832 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71833 + {
71834 + .procname = "forkfail_logging",
71835 + .data = &grsec_enable_forkfail,
71836 + .maxlen = sizeof(int),
71837 + .mode = 0600,
71838 + .proc_handler = &proc_dointvec,
71839 + },
71840 +#endif
71841 +#ifdef CONFIG_GRKERNSEC_TIME
71842 + {
71843 + .procname = "timechange_logging",
71844 + .data = &grsec_enable_time,
71845 + .maxlen = sizeof(int),
71846 + .mode = 0600,
71847 + .proc_handler = &proc_dointvec,
71848 + },
71849 +#endif
71850 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71851 + {
71852 + .procname = "chroot_deny_shmat",
71853 + .data = &grsec_enable_chroot_shmat,
71854 + .maxlen = sizeof(int),
71855 + .mode = 0600,
71856 + .proc_handler = &proc_dointvec,
71857 + },
71858 +#endif
71859 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71860 + {
71861 + .procname = "chroot_deny_unix",
71862 + .data = &grsec_enable_chroot_unix,
71863 + .maxlen = sizeof(int),
71864 + .mode = 0600,
71865 + .proc_handler = &proc_dointvec,
71866 + },
71867 +#endif
71868 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71869 + {
71870 + .procname = "chroot_deny_mount",
71871 + .data = &grsec_enable_chroot_mount,
71872 + .maxlen = sizeof(int),
71873 + .mode = 0600,
71874 + .proc_handler = &proc_dointvec,
71875 + },
71876 +#endif
71877 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71878 + {
71879 + .procname = "chroot_deny_fchdir",
71880 + .data = &grsec_enable_chroot_fchdir,
71881 + .maxlen = sizeof(int),
71882 + .mode = 0600,
71883 + .proc_handler = &proc_dointvec,
71884 + },
71885 +#endif
71886 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71887 + {
71888 + .procname = "chroot_deny_chroot",
71889 + .data = &grsec_enable_chroot_double,
71890 + .maxlen = sizeof(int),
71891 + .mode = 0600,
71892 + .proc_handler = &proc_dointvec,
71893 + },
71894 +#endif
71895 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71896 + {
71897 + .procname = "chroot_deny_pivot",
71898 + .data = &grsec_enable_chroot_pivot,
71899 + .maxlen = sizeof(int),
71900 + .mode = 0600,
71901 + .proc_handler = &proc_dointvec,
71902 + },
71903 +#endif
71904 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71905 + {
71906 + .procname = "chroot_enforce_chdir",
71907 + .data = &grsec_enable_chroot_chdir,
71908 + .maxlen = sizeof(int),
71909 + .mode = 0600,
71910 + .proc_handler = &proc_dointvec,
71911 + },
71912 +#endif
71913 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71914 + {
71915 + .procname = "chroot_deny_chmod",
71916 + .data = &grsec_enable_chroot_chmod,
71917 + .maxlen = sizeof(int),
71918 + .mode = 0600,
71919 + .proc_handler = &proc_dointvec,
71920 + },
71921 +#endif
71922 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71923 + {
71924 + .procname = "chroot_deny_mknod",
71925 + .data = &grsec_enable_chroot_mknod,
71926 + .maxlen = sizeof(int),
71927 + .mode = 0600,
71928 + .proc_handler = &proc_dointvec,
71929 + },
71930 +#endif
71931 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71932 + {
71933 + .procname = "chroot_restrict_nice",
71934 + .data = &grsec_enable_chroot_nice,
71935 + .maxlen = sizeof(int),
71936 + .mode = 0600,
71937 + .proc_handler = &proc_dointvec,
71938 + },
71939 +#endif
71940 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71941 + {
71942 + .procname = "chroot_execlog",
71943 + .data = &grsec_enable_chroot_execlog,
71944 + .maxlen = sizeof(int),
71945 + .mode = 0600,
71946 + .proc_handler = &proc_dointvec,
71947 + },
71948 +#endif
71949 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71950 + {
71951 + .procname = "chroot_caps",
71952 + .data = &grsec_enable_chroot_caps,
71953 + .maxlen = sizeof(int),
71954 + .mode = 0600,
71955 + .proc_handler = &proc_dointvec,
71956 + },
71957 +#endif
71958 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71959 + {
71960 + .procname = "chroot_deny_sysctl",
71961 + .data = &grsec_enable_chroot_sysctl,
71962 + .maxlen = sizeof(int),
71963 + .mode = 0600,
71964 + .proc_handler = &proc_dointvec,
71965 + },
71966 +#endif
71967 +#ifdef CONFIG_GRKERNSEC_TPE
71968 + {
71969 + .procname = "tpe",
71970 + .data = &grsec_enable_tpe,
71971 + .maxlen = sizeof(int),
71972 + .mode = 0600,
71973 + .proc_handler = &proc_dointvec,
71974 + },
71975 + {
71976 + .procname = "tpe_gid",
71977 + .data = &grsec_tpe_gid,
71978 + .maxlen = sizeof(int),
71979 + .mode = 0600,
71980 + .proc_handler = &proc_dointvec,
71981 + },
71982 +#endif
71983 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71984 + {
71985 + .procname = "tpe_invert",
71986 + .data = &grsec_enable_tpe_invert,
71987 + .maxlen = sizeof(int),
71988 + .mode = 0600,
71989 + .proc_handler = &proc_dointvec,
71990 + },
71991 +#endif
71992 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71993 + {
71994 + .procname = "tpe_restrict_all",
71995 + .data = &grsec_enable_tpe_all,
71996 + .maxlen = sizeof(int),
71997 + .mode = 0600,
71998 + .proc_handler = &proc_dointvec,
71999 + },
72000 +#endif
72001 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72002 + {
72003 + .procname = "socket_all",
72004 + .data = &grsec_enable_socket_all,
72005 + .maxlen = sizeof(int),
72006 + .mode = 0600,
72007 + .proc_handler = &proc_dointvec,
72008 + },
72009 + {
72010 + .procname = "socket_all_gid",
72011 + .data = &grsec_socket_all_gid,
72012 + .maxlen = sizeof(int),
72013 + .mode = 0600,
72014 + .proc_handler = &proc_dointvec,
72015 + },
72016 +#endif
72017 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72018 + {
72019 + .procname = "socket_client",
72020 + .data = &grsec_enable_socket_client,
72021 + .maxlen = sizeof(int),
72022 + .mode = 0600,
72023 + .proc_handler = &proc_dointvec,
72024 + },
72025 + {
72026 + .procname = "socket_client_gid",
72027 + .data = &grsec_socket_client_gid,
72028 + .maxlen = sizeof(int),
72029 + .mode = 0600,
72030 + .proc_handler = &proc_dointvec,
72031 + },
72032 +#endif
72033 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72034 + {
72035 + .procname = "socket_server",
72036 + .data = &grsec_enable_socket_server,
72037 + .maxlen = sizeof(int),
72038 + .mode = 0600,
72039 + .proc_handler = &proc_dointvec,
72040 + },
72041 + {
72042 + .procname = "socket_server_gid",
72043 + .data = &grsec_socket_server_gid,
72044 + .maxlen = sizeof(int),
72045 + .mode = 0600,
72046 + .proc_handler = &proc_dointvec,
72047 + },
72048 +#endif
72049 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72050 + {
72051 + .procname = "audit_group",
72052 + .data = &grsec_enable_group,
72053 + .maxlen = sizeof(int),
72054 + .mode = 0600,
72055 + .proc_handler = &proc_dointvec,
72056 + },
72057 + {
72058 + .procname = "audit_gid",
72059 + .data = &grsec_audit_gid,
72060 + .maxlen = sizeof(int),
72061 + .mode = 0600,
72062 + .proc_handler = &proc_dointvec,
72063 + },
72064 +#endif
72065 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72066 + {
72067 + .procname = "audit_chdir",
72068 + .data = &grsec_enable_chdir,
72069 + .maxlen = sizeof(int),
72070 + .mode = 0600,
72071 + .proc_handler = &proc_dointvec,
72072 + },
72073 +#endif
72074 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72075 + {
72076 + .procname = "audit_mount",
72077 + .data = &grsec_enable_mount,
72078 + .maxlen = sizeof(int),
72079 + .mode = 0600,
72080 + .proc_handler = &proc_dointvec,
72081 + },
72082 +#endif
72083 +#ifdef CONFIG_GRKERNSEC_DMESG
72084 + {
72085 + .procname = "dmesg",
72086 + .data = &grsec_enable_dmesg,
72087 + .maxlen = sizeof(int),
72088 + .mode = 0600,
72089 + .proc_handler = &proc_dointvec,
72090 + },
72091 +#endif
72092 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72093 + {
72094 + .procname = "chroot_findtask",
72095 + .data = &grsec_enable_chroot_findtask,
72096 + .maxlen = sizeof(int),
72097 + .mode = 0600,
72098 + .proc_handler = &proc_dointvec,
72099 + },
72100 +#endif
72101 +#ifdef CONFIG_GRKERNSEC_RESLOG
72102 + {
72103 + .procname = "resource_logging",
72104 + .data = &grsec_resource_logging,
72105 + .maxlen = sizeof(int),
72106 + .mode = 0600,
72107 + .proc_handler = &proc_dointvec,
72108 + },
72109 +#endif
72110 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72111 + {
72112 + .procname = "audit_ptrace",
72113 + .data = &grsec_enable_audit_ptrace,
72114 + .maxlen = sizeof(int),
72115 + .mode = 0600,
72116 + .proc_handler = &proc_dointvec,
72117 + },
72118 +#endif
72119 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72120 + {
72121 + .procname = "harden_ptrace",
72122 + .data = &grsec_enable_harden_ptrace,
72123 + .maxlen = sizeof(int),
72124 + .mode = 0600,
72125 + .proc_handler = &proc_dointvec,
72126 + },
72127 +#endif
72128 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
72129 + {
72130 + .procname = "harden_ipc",
72131 + .data = &grsec_enable_harden_ipc,
72132 + .maxlen = sizeof(int),
72133 + .mode = 0600,
72134 + .proc_handler = &proc_dointvec,
72135 + },
72136 +#endif
72137 + {
72138 + .procname = "grsec_lock",
72139 + .data = &grsec_lock,
72140 + .maxlen = sizeof(int),
72141 + .mode = 0600,
72142 + .proc_handler = &proc_dointvec,
72143 + },
72144 +#endif
72145 +#ifdef CONFIG_GRKERNSEC_ROFS
72146 + {
72147 + .procname = "romount_protect",
72148 + .data = &grsec_enable_rofs,
72149 + .maxlen = sizeof(int),
72150 + .mode = 0600,
72151 + .proc_handler = &proc_dointvec_minmax,
72152 + .extra1 = &one,
72153 + .extra2 = &one,
72154 + },
72155 +#endif
72156 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
72157 + {
72158 + .procname = "deny_new_usb",
72159 + .data = &grsec_deny_new_usb,
72160 + .maxlen = sizeof(int),
72161 + .mode = 0600,
72162 + .proc_handler = &proc_dointvec,
72163 + },
72164 +#endif
72165 + { }
72166 +};
72167 +#endif
72168 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72169 new file mode 100644
72170 index 0000000..0dc13c3
72171 --- /dev/null
72172 +++ b/grsecurity/grsec_time.c
72173 @@ -0,0 +1,16 @@
72174 +#include <linux/kernel.h>
72175 +#include <linux/sched.h>
72176 +#include <linux/grinternal.h>
72177 +#include <linux/module.h>
72178 +
72179 +void
72180 +gr_log_timechange(void)
72181 +{
72182 +#ifdef CONFIG_GRKERNSEC_TIME
72183 + if (grsec_enable_time)
72184 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72185 +#endif
72186 + return;
72187 +}
72188 +
72189 +EXPORT_SYMBOL(gr_log_timechange);
72190 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72191 new file mode 100644
72192 index 0000000..ee57dcf
72193 --- /dev/null
72194 +++ b/grsecurity/grsec_tpe.c
72195 @@ -0,0 +1,73 @@
72196 +#include <linux/kernel.h>
72197 +#include <linux/sched.h>
72198 +#include <linux/file.h>
72199 +#include <linux/fs.h>
72200 +#include <linux/grinternal.h>
72201 +
72202 +extern int gr_acl_tpe_check(void);
72203 +
72204 +int
72205 +gr_tpe_allow(const struct file *file)
72206 +{
72207 +#ifdef CONFIG_GRKERNSEC
72208 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72209 + const struct cred *cred = current_cred();
72210 + char *msg = NULL;
72211 + char *msg2 = NULL;
72212 +
72213 + // never restrict root
72214 + if (gr_is_global_root(cred->uid))
72215 + return 1;
72216 +
72217 + if (grsec_enable_tpe) {
72218 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72219 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72220 + msg = "not being in trusted group";
72221 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72222 + msg = "being in untrusted group";
72223 +#else
72224 + if (in_group_p(grsec_tpe_gid))
72225 + msg = "being in untrusted group";
72226 +#endif
72227 + }
72228 + if (!msg && gr_acl_tpe_check())
72229 + msg = "being in untrusted role";
72230 +
72231 + // not in any affected group/role
72232 + if (!msg)
72233 + goto next_check;
72234 +
72235 + if (gr_is_global_nonroot(inode->i_uid))
72236 + msg2 = "file in non-root-owned directory";
72237 + else if (inode->i_mode & S_IWOTH)
72238 + msg2 = "file in world-writable directory";
72239 + else if (inode->i_mode & S_IWGRP)
72240 + msg2 = "file in group-writable directory";
72241 +
72242 + if (msg && msg2) {
72243 + char fullmsg[70] = {0};
72244 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72245 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72246 + return 0;
72247 + }
72248 + msg = NULL;
72249 +next_check:
72250 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72251 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72252 + return 1;
72253 +
72254 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72255 + msg = "directory not owned by user";
72256 + else if (inode->i_mode & S_IWOTH)
72257 + msg = "file in world-writable directory";
72258 + else if (inode->i_mode & S_IWGRP)
72259 + msg = "file in group-writable directory";
72260 +
72261 + if (msg) {
72262 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72263 + return 0;
72264 + }
72265 +#endif
72266 +#endif
72267 + return 1;
72268 +}
72269 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72270 new file mode 100644
72271 index 0000000..ae02d8e
72272 --- /dev/null
72273 +++ b/grsecurity/grsec_usb.c
72274 @@ -0,0 +1,15 @@
72275 +#include <linux/kernel.h>
72276 +#include <linux/grinternal.h>
72277 +#include <linux/module.h>
72278 +
72279 +int gr_handle_new_usb(void)
72280 +{
72281 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72282 + if (grsec_deny_new_usb) {
72283 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72284 + return 1;
72285 + }
72286 +#endif
72287 + return 0;
72288 +}
72289 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72290 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72291 new file mode 100644
72292 index 0000000..9f7b1ac
72293 --- /dev/null
72294 +++ b/grsecurity/grsum.c
72295 @@ -0,0 +1,61 @@
72296 +#include <linux/err.h>
72297 +#include <linux/kernel.h>
72298 +#include <linux/sched.h>
72299 +#include <linux/mm.h>
72300 +#include <linux/scatterlist.h>
72301 +#include <linux/crypto.h>
72302 +#include <linux/gracl.h>
72303 +
72304 +
72305 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
72306 +#error "crypto and sha256 must be built into the kernel"
72307 +#endif
72308 +
72309 +int
72310 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
72311 +{
72312 + char *p;
72313 + struct crypto_hash *tfm;
72314 + struct hash_desc desc;
72315 + struct scatterlist sg;
72316 + unsigned char temp_sum[GR_SHA_LEN];
72317 + volatile int retval = 0;
72318 + volatile int dummy = 0;
72319 + unsigned int i;
72320 +
72321 + sg_init_table(&sg, 1);
72322 +
72323 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
72324 + if (IS_ERR(tfm)) {
72325 + /* should never happen, since sha256 should be built in */
72326 + return 1;
72327 + }
72328 +
72329 + desc.tfm = tfm;
72330 + desc.flags = 0;
72331 +
72332 + crypto_hash_init(&desc);
72333 +
72334 + p = salt;
72335 + sg_set_buf(&sg, p, GR_SALT_LEN);
72336 + crypto_hash_update(&desc, &sg, sg.length);
72337 +
72338 + p = entry->pw;
72339 + sg_set_buf(&sg, p, strlen(p));
72340 +
72341 + crypto_hash_update(&desc, &sg, sg.length);
72342 +
72343 + crypto_hash_final(&desc, temp_sum);
72344 +
72345 + memset(entry->pw, 0, GR_PW_LEN);
72346 +
72347 + for (i = 0; i < GR_SHA_LEN; i++)
72348 + if (sum[i] != temp_sum[i])
72349 + retval = 1;
72350 + else
72351 + dummy = 1; // waste a cycle
72352 +
72353 + crypto_free_hash(tfm);
72354 +
72355 + return retval;
72356 +}
72357 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
72358 index 77ff547..181834f 100644
72359 --- a/include/asm-generic/4level-fixup.h
72360 +++ b/include/asm-generic/4level-fixup.h
72361 @@ -13,8 +13,10 @@
72362 #define pmd_alloc(mm, pud, address) \
72363 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
72364 NULL: pmd_offset(pud, address))
72365 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
72366
72367 #define pud_alloc(mm, pgd, address) (pgd)
72368 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
72369 #define pud_offset(pgd, start) (pgd)
72370 #define pud_none(pud) 0
72371 #define pud_bad(pud) 0
72372 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
72373 index b7babf0..04ad282 100644
72374 --- a/include/asm-generic/atomic-long.h
72375 +++ b/include/asm-generic/atomic-long.h
72376 @@ -22,6 +22,12 @@
72377
72378 typedef atomic64_t atomic_long_t;
72379
72380 +#ifdef CONFIG_PAX_REFCOUNT
72381 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
72382 +#else
72383 +typedef atomic64_t atomic_long_unchecked_t;
72384 +#endif
72385 +
72386 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
72387
72388 static inline long atomic_long_read(atomic_long_t *l)
72389 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72390 return (long)atomic64_read(v);
72391 }
72392
72393 +#ifdef CONFIG_PAX_REFCOUNT
72394 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72395 +{
72396 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72397 +
72398 + return (long)atomic64_read_unchecked(v);
72399 +}
72400 +#endif
72401 +
72402 static inline void atomic_long_set(atomic_long_t *l, long i)
72403 {
72404 atomic64_t *v = (atomic64_t *)l;
72405 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72406 atomic64_set(v, i);
72407 }
72408
72409 +#ifdef CONFIG_PAX_REFCOUNT
72410 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72411 +{
72412 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72413 +
72414 + atomic64_set_unchecked(v, i);
72415 +}
72416 +#endif
72417 +
72418 static inline void atomic_long_inc(atomic_long_t *l)
72419 {
72420 atomic64_t *v = (atomic64_t *)l;
72421 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72422 atomic64_inc(v);
72423 }
72424
72425 +#ifdef CONFIG_PAX_REFCOUNT
72426 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72427 +{
72428 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72429 +
72430 + atomic64_inc_unchecked(v);
72431 +}
72432 +#endif
72433 +
72434 static inline void atomic_long_dec(atomic_long_t *l)
72435 {
72436 atomic64_t *v = (atomic64_t *)l;
72437 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72438 atomic64_dec(v);
72439 }
72440
72441 +#ifdef CONFIG_PAX_REFCOUNT
72442 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72443 +{
72444 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72445 +
72446 + atomic64_dec_unchecked(v);
72447 +}
72448 +#endif
72449 +
72450 static inline void atomic_long_add(long i, atomic_long_t *l)
72451 {
72452 atomic64_t *v = (atomic64_t *)l;
72453 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72454 atomic64_add(i, v);
72455 }
72456
72457 +#ifdef CONFIG_PAX_REFCOUNT
72458 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72459 +{
72460 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72461 +
72462 + atomic64_add_unchecked(i, v);
72463 +}
72464 +#endif
72465 +
72466 static inline void atomic_long_sub(long i, atomic_long_t *l)
72467 {
72468 atomic64_t *v = (atomic64_t *)l;
72469 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72470 atomic64_sub(i, v);
72471 }
72472
72473 +#ifdef CONFIG_PAX_REFCOUNT
72474 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72475 +{
72476 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72477 +
72478 + atomic64_sub_unchecked(i, v);
72479 +}
72480 +#endif
72481 +
72482 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72483 {
72484 atomic64_t *v = (atomic64_t *)l;
72485 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72486 return (long)atomic64_add_return(i, v);
72487 }
72488
72489 +#ifdef CONFIG_PAX_REFCOUNT
72490 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72491 +{
72492 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72493 +
72494 + return (long)atomic64_add_return_unchecked(i, v);
72495 +}
72496 +#endif
72497 +
72498 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72499 {
72500 atomic64_t *v = (atomic64_t *)l;
72501 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72502 return (long)atomic64_inc_return(v);
72503 }
72504
72505 +#ifdef CONFIG_PAX_REFCOUNT
72506 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72507 +{
72508 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72509 +
72510 + return (long)atomic64_inc_return_unchecked(v);
72511 +}
72512 +#endif
72513 +
72514 static inline long atomic_long_dec_return(atomic_long_t *l)
72515 {
72516 atomic64_t *v = (atomic64_t *)l;
72517 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72518
72519 typedef atomic_t atomic_long_t;
72520
72521 +#ifdef CONFIG_PAX_REFCOUNT
72522 +typedef atomic_unchecked_t atomic_long_unchecked_t;
72523 +#else
72524 +typedef atomic_t atomic_long_unchecked_t;
72525 +#endif
72526 +
72527 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
72528 static inline long atomic_long_read(atomic_long_t *l)
72529 {
72530 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72531 return (long)atomic_read(v);
72532 }
72533
72534 +#ifdef CONFIG_PAX_REFCOUNT
72535 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72536 +{
72537 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72538 +
72539 + return (long)atomic_read_unchecked(v);
72540 +}
72541 +#endif
72542 +
72543 static inline void atomic_long_set(atomic_long_t *l, long i)
72544 {
72545 atomic_t *v = (atomic_t *)l;
72546 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72547 atomic_set(v, i);
72548 }
72549
72550 +#ifdef CONFIG_PAX_REFCOUNT
72551 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72552 +{
72553 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72554 +
72555 + atomic_set_unchecked(v, i);
72556 +}
72557 +#endif
72558 +
72559 static inline void atomic_long_inc(atomic_long_t *l)
72560 {
72561 atomic_t *v = (atomic_t *)l;
72562 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72563 atomic_inc(v);
72564 }
72565
72566 +#ifdef CONFIG_PAX_REFCOUNT
72567 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72568 +{
72569 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72570 +
72571 + atomic_inc_unchecked(v);
72572 +}
72573 +#endif
72574 +
72575 static inline void atomic_long_dec(atomic_long_t *l)
72576 {
72577 atomic_t *v = (atomic_t *)l;
72578 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72579 atomic_dec(v);
72580 }
72581
72582 +#ifdef CONFIG_PAX_REFCOUNT
72583 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72584 +{
72585 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72586 +
72587 + atomic_dec_unchecked(v);
72588 +}
72589 +#endif
72590 +
72591 static inline void atomic_long_add(long i, atomic_long_t *l)
72592 {
72593 atomic_t *v = (atomic_t *)l;
72594 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72595 atomic_add(i, v);
72596 }
72597
72598 +#ifdef CONFIG_PAX_REFCOUNT
72599 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72600 +{
72601 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72602 +
72603 + atomic_add_unchecked(i, v);
72604 +}
72605 +#endif
72606 +
72607 static inline void atomic_long_sub(long i, atomic_long_t *l)
72608 {
72609 atomic_t *v = (atomic_t *)l;
72610 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72611 atomic_sub(i, v);
72612 }
72613
72614 +#ifdef CONFIG_PAX_REFCOUNT
72615 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72616 +{
72617 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72618 +
72619 + atomic_sub_unchecked(i, v);
72620 +}
72621 +#endif
72622 +
72623 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72624 {
72625 atomic_t *v = (atomic_t *)l;
72626 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72627 return (long)atomic_add_return(i, v);
72628 }
72629
72630 +#ifdef CONFIG_PAX_REFCOUNT
72631 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72632 +{
72633 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72634 +
72635 + return (long)atomic_add_return_unchecked(i, v);
72636 +}
72637 +
72638 +#endif
72639 +
72640 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72641 {
72642 atomic_t *v = (atomic_t *)l;
72643 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72644 return (long)atomic_inc_return(v);
72645 }
72646
72647 +#ifdef CONFIG_PAX_REFCOUNT
72648 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72649 +{
72650 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72651 +
72652 + return (long)atomic_inc_return_unchecked(v);
72653 +}
72654 +#endif
72655 +
72656 static inline long atomic_long_dec_return(atomic_long_t *l)
72657 {
72658 atomic_t *v = (atomic_t *)l;
72659 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72660
72661 #endif /* BITS_PER_LONG == 64 */
72662
72663 +#ifdef CONFIG_PAX_REFCOUNT
72664 +static inline void pax_refcount_needs_these_functions(void)
72665 +{
72666 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
72667 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
72668 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
72669 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
72670 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
72671 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
72672 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
72673 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
72674 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
72675 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
72676 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
72677 +#ifdef CONFIG_X86
72678 + atomic_clear_mask_unchecked(0, NULL);
72679 + atomic_set_mask_unchecked(0, NULL);
72680 +#endif
72681 +
72682 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
72683 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
72684 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
72685 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
72686 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
72687 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
72688 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
72689 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
72690 +}
72691 +#else
72692 +#define atomic_read_unchecked(v) atomic_read(v)
72693 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
72694 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
72695 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
72696 +#define atomic_inc_unchecked(v) atomic_inc(v)
72697 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
72698 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
72699 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
72700 +#define atomic_dec_unchecked(v) atomic_dec(v)
72701 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
72702 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
72703 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
72704 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
72705 +
72706 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
72707 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
72708 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
72709 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
72710 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
72711 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
72712 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
72713 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
72714 +#endif
72715 +
72716 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
72717 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
72718 index 33bd2de..f31bff97 100644
72719 --- a/include/asm-generic/atomic.h
72720 +++ b/include/asm-generic/atomic.h
72721 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
72722 * Atomically clears the bits set in @mask from @v
72723 */
72724 #ifndef atomic_clear_mask
72725 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
72726 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
72727 {
72728 unsigned long flags;
72729
72730 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
72731 index b18ce4f..2ee2843 100644
72732 --- a/include/asm-generic/atomic64.h
72733 +++ b/include/asm-generic/atomic64.h
72734 @@ -16,6 +16,8 @@ typedef struct {
72735 long long counter;
72736 } atomic64_t;
72737
72738 +typedef atomic64_t atomic64_unchecked_t;
72739 +
72740 #define ATOMIC64_INIT(i) { (i) }
72741
72742 extern long long atomic64_read(const atomic64_t *v);
72743 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
72744 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
72745 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
72746
72747 +#define atomic64_read_unchecked(v) atomic64_read(v)
72748 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
72749 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
72750 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
72751 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
72752 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
72753 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
72754 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
72755 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
72756 +
72757 #endif /* _ASM_GENERIC_ATOMIC64_H */
72758 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
72759 index 1bfcfe5..e04c5c9 100644
72760 --- a/include/asm-generic/cache.h
72761 +++ b/include/asm-generic/cache.h
72762 @@ -6,7 +6,7 @@
72763 * cache lines need to provide their own cache.h.
72764 */
72765
72766 -#define L1_CACHE_SHIFT 5
72767 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72768 +#define L1_CACHE_SHIFT 5UL
72769 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72770
72771 #endif /* __ASM_GENERIC_CACHE_H */
72772 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72773 index 0d68a1e..b74a761 100644
72774 --- a/include/asm-generic/emergency-restart.h
72775 +++ b/include/asm-generic/emergency-restart.h
72776 @@ -1,7 +1,7 @@
72777 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72778 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72779
72780 -static inline void machine_emergency_restart(void)
72781 +static inline __noreturn void machine_emergency_restart(void)
72782 {
72783 machine_restart(NULL);
72784 }
72785 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72786 index 90f99c7..00ce236 100644
72787 --- a/include/asm-generic/kmap_types.h
72788 +++ b/include/asm-generic/kmap_types.h
72789 @@ -2,9 +2,9 @@
72790 #define _ASM_GENERIC_KMAP_TYPES_H
72791
72792 #ifdef __WITH_KM_FENCE
72793 -# define KM_TYPE_NR 41
72794 +# define KM_TYPE_NR 42
72795 #else
72796 -# define KM_TYPE_NR 20
72797 +# define KM_TYPE_NR 21
72798 #endif
72799
72800 #endif
72801 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72802 index 9ceb03b..62b0b8f 100644
72803 --- a/include/asm-generic/local.h
72804 +++ b/include/asm-generic/local.h
72805 @@ -23,24 +23,37 @@ typedef struct
72806 atomic_long_t a;
72807 } local_t;
72808
72809 +typedef struct {
72810 + atomic_long_unchecked_t a;
72811 +} local_unchecked_t;
72812 +
72813 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72814
72815 #define local_read(l) atomic_long_read(&(l)->a)
72816 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72817 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72818 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72819 #define local_inc(l) atomic_long_inc(&(l)->a)
72820 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72821 #define local_dec(l) atomic_long_dec(&(l)->a)
72822 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72823 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72824 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72825 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72826 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72827
72828 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72829 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72830 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72831 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72832 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72833 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72834 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72835 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72836 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72837
72838 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72839 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72840 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72841 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72842 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72843 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72844 index 725612b..9cc513a 100644
72845 --- a/include/asm-generic/pgtable-nopmd.h
72846 +++ b/include/asm-generic/pgtable-nopmd.h
72847 @@ -1,14 +1,19 @@
72848 #ifndef _PGTABLE_NOPMD_H
72849 #define _PGTABLE_NOPMD_H
72850
72851 -#ifndef __ASSEMBLY__
72852 -
72853 #include <asm-generic/pgtable-nopud.h>
72854
72855 -struct mm_struct;
72856 -
72857 #define __PAGETABLE_PMD_FOLDED
72858
72859 +#define PMD_SHIFT PUD_SHIFT
72860 +#define PTRS_PER_PMD 1
72861 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72862 +#define PMD_MASK (~(PMD_SIZE-1))
72863 +
72864 +#ifndef __ASSEMBLY__
72865 +
72866 +struct mm_struct;
72867 +
72868 /*
72869 * Having the pmd type consist of a pud gets the size right, and allows
72870 * us to conceptually access the pud entry that this pmd is folded into
72871 @@ -16,11 +21,6 @@ struct mm_struct;
72872 */
72873 typedef struct { pud_t pud; } pmd_t;
72874
72875 -#define PMD_SHIFT PUD_SHIFT
72876 -#define PTRS_PER_PMD 1
72877 -#define PMD_SIZE (1UL << PMD_SHIFT)
72878 -#define PMD_MASK (~(PMD_SIZE-1))
72879 -
72880 /*
72881 * The "pud_xxx()" functions here are trivial for a folded two-level
72882 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72883 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72884 index 810431d..0ec4804f 100644
72885 --- a/include/asm-generic/pgtable-nopud.h
72886 +++ b/include/asm-generic/pgtable-nopud.h
72887 @@ -1,10 +1,15 @@
72888 #ifndef _PGTABLE_NOPUD_H
72889 #define _PGTABLE_NOPUD_H
72890
72891 -#ifndef __ASSEMBLY__
72892 -
72893 #define __PAGETABLE_PUD_FOLDED
72894
72895 +#define PUD_SHIFT PGDIR_SHIFT
72896 +#define PTRS_PER_PUD 1
72897 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72898 +#define PUD_MASK (~(PUD_SIZE-1))
72899 +
72900 +#ifndef __ASSEMBLY__
72901 +
72902 /*
72903 * Having the pud type consist of a pgd gets the size right, and allows
72904 * us to conceptually access the pgd entry that this pud is folded into
72905 @@ -12,11 +17,6 @@
72906 */
72907 typedef struct { pgd_t pgd; } pud_t;
72908
72909 -#define PUD_SHIFT PGDIR_SHIFT
72910 -#define PTRS_PER_PUD 1
72911 -#define PUD_SIZE (1UL << PUD_SHIFT)
72912 -#define PUD_MASK (~(PUD_SIZE-1))
72913 -
72914 /*
72915 * The "pgd_xxx()" functions here are trivial for a folded two-level
72916 * setup: the pud is never bad, and a pud always exists (as it's folded
72917 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72918 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72919
72920 #define pgd_populate(mm, pgd, pud) do { } while (0)
72921 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72922 /*
72923 * (puds are folded into pgds so this doesn't get actually called,
72924 * but the define is needed for a generic inline function.)
72925 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72926 index f330d28..83ce28f 100644
72927 --- a/include/asm-generic/pgtable.h
72928 +++ b/include/asm-generic/pgtable.h
72929 @@ -737,6 +737,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72930 }
72931 #endif /* CONFIG_NUMA_BALANCING */
72932
72933 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72934 +#ifdef CONFIG_PAX_KERNEXEC
72935 +#error KERNEXEC requires pax_open_kernel
72936 +#else
72937 +static inline unsigned long pax_open_kernel(void) { return 0; }
72938 +#endif
72939 +#endif
72940 +
72941 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72942 +#ifdef CONFIG_PAX_KERNEXEC
72943 +#error KERNEXEC requires pax_close_kernel
72944 +#else
72945 +static inline unsigned long pax_close_kernel(void) { return 0; }
72946 +#endif
72947 +#endif
72948 +
72949 #endif /* CONFIG_MMU */
72950
72951 #endif /* !__ASSEMBLY__ */
72952 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72953 index dc1269c..48a4f51 100644
72954 --- a/include/asm-generic/uaccess.h
72955 +++ b/include/asm-generic/uaccess.h
72956 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72957 return __clear_user(to, n);
72958 }
72959
72960 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72961 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72962 +#error UDEREF requires pax_open_userland
72963 +#else
72964 +static inline unsigned long pax_open_userland(void) { return 0; }
72965 +#endif
72966 +#endif
72967 +
72968 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72969 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72970 +#error UDEREF requires pax_close_userland
72971 +#else
72972 +static inline unsigned long pax_close_userland(void) { return 0; }
72973 +#endif
72974 +#endif
72975 +
72976 #endif /* __ASM_GENERIC_UACCESS_H */
72977 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72978 index 83e2c31..eeb4a04 100644
72979 --- a/include/asm-generic/vmlinux.lds.h
72980 +++ b/include/asm-generic/vmlinux.lds.h
72981 @@ -232,6 +232,7 @@
72982 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72983 VMLINUX_SYMBOL(__start_rodata) = .; \
72984 *(.rodata) *(.rodata.*) \
72985 + *(.data..read_only) \
72986 *(__vermagic) /* Kernel version magic */ \
72987 . = ALIGN(8); \
72988 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72989 @@ -715,17 +716,18 @@
72990 * section in the linker script will go there too. @phdr should have
72991 * a leading colon.
72992 *
72993 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72994 + * Note that this macros defines per_cpu_load as an absolute symbol.
72995 * If there is no need to put the percpu section at a predetermined
72996 * address, use PERCPU_SECTION.
72997 */
72998 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72999 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73000 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73001 + per_cpu_load = .; \
73002 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73003 - LOAD_OFFSET) { \
73004 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73005 PERCPU_INPUT(cacheline) \
73006 } phdr \
73007 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73008 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73009
73010 /**
73011 * PERCPU_SECTION - define output section for percpu area, simple version
73012 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73013 index 418d270..bfd2794 100644
73014 --- a/include/crypto/algapi.h
73015 +++ b/include/crypto/algapi.h
73016 @@ -34,7 +34,7 @@ struct crypto_type {
73017 unsigned int maskclear;
73018 unsigned int maskset;
73019 unsigned int tfmsize;
73020 -};
73021 +} __do_const;
73022
73023 struct crypto_instance {
73024 struct crypto_alg alg;
73025 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73026 index b46fb45..b30d6d5 100644
73027 --- a/include/drm/drmP.h
73028 +++ b/include/drm/drmP.h
73029 @@ -66,6 +66,7 @@
73030 #include <linux/workqueue.h>
73031 #include <linux/poll.h>
73032 #include <asm/pgalloc.h>
73033 +#include <asm/local.h>
73034 #include <drm/drm.h>
73035 #include <drm/drm_sarea.h>
73036 #include <drm/drm_vma_manager.h>
73037 @@ -277,10 +278,12 @@ do { \
73038 * \param cmd command.
73039 * \param arg argument.
73040 */
73041 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73042 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73043 + struct drm_file *file_priv);
73044 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73045 struct drm_file *file_priv);
73046
73047 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73048 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73049 unsigned long arg);
73050
73051 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73052 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73053 struct drm_ioctl_desc {
73054 unsigned int cmd;
73055 int flags;
73056 - drm_ioctl_t *func;
73057 + drm_ioctl_t func;
73058 unsigned int cmd_drv;
73059 const char *name;
73060 -};
73061 +} __do_const;
73062
73063 /**
73064 * Creates a driver or general drm_ioctl_desc array entry for the given
73065 @@ -1027,7 +1030,7 @@ struct drm_info_list {
73066 int (*show)(struct seq_file*, void*); /** show callback */
73067 u32 driver_features; /**< Required driver features for this entry */
73068 void *data;
73069 -};
73070 +} __do_const;
73071
73072 /**
73073 * debugfs node structure. This structure represents a debugfs file.
73074 @@ -1098,7 +1101,7 @@ struct drm_device {
73075
73076 /** \name Usage Counters */
73077 /*@{ */
73078 - int open_count; /**< Outstanding files open */
73079 + local_t open_count; /**< Outstanding files open */
73080 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73081 atomic_t vma_count; /**< Outstanding vma areas open */
73082 int buf_use; /**< Buffers in use -- cannot alloc */
73083 @@ -1109,7 +1112,7 @@ struct drm_device {
73084 /*@{ */
73085 unsigned long counters;
73086 enum drm_stat_type types[15];
73087 - atomic_t counts[15];
73088 + atomic_unchecked_t counts[15];
73089 /*@} */
73090
73091 struct list_head filelist;
73092 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73093 index f43d556..94d9343 100644
73094 --- a/include/drm/drm_crtc_helper.h
73095 +++ b/include/drm/drm_crtc_helper.h
73096 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73097 struct drm_connector *connector);
73098 /* disable encoder when not in use - more explicit than dpms off */
73099 void (*disable)(struct drm_encoder *encoder);
73100 -};
73101 +} __no_const;
73102
73103 /**
73104 * drm_connector_helper_funcs - helper operations for connectors
73105 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
73106 index 8a10f5c..5de7f5c 100644
73107 --- a/include/drm/i915_pciids.h
73108 +++ b/include/drm/i915_pciids.h
73109 @@ -37,7 +37,7 @@
73110 */
73111 #define INTEL_VGA_DEVICE(id, info) { \
73112 0x8086, id, \
73113 - ~0, ~0, \
73114 + PCI_ANY_ID, PCI_ANY_ID, \
73115 0x030000, 0xff0000, \
73116 (unsigned long) info }
73117
73118 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73119 index 72dcbe8..8db58d7 100644
73120 --- a/include/drm/ttm/ttm_memory.h
73121 +++ b/include/drm/ttm/ttm_memory.h
73122 @@ -48,7 +48,7 @@
73123
73124 struct ttm_mem_shrink {
73125 int (*do_shrink) (struct ttm_mem_shrink *);
73126 -};
73127 +} __no_const;
73128
73129 /**
73130 * struct ttm_mem_global - Global memory accounting structure.
73131 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73132 index 4b840e8..155d235 100644
73133 --- a/include/keys/asymmetric-subtype.h
73134 +++ b/include/keys/asymmetric-subtype.h
73135 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73136 /* Verify the signature on a key of this subtype (optional) */
73137 int (*verify_signature)(const struct key *key,
73138 const struct public_key_signature *sig);
73139 -};
73140 +} __do_const;
73141
73142 /**
73143 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73144 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73145 index c1da539..1dcec55 100644
73146 --- a/include/linux/atmdev.h
73147 +++ b/include/linux/atmdev.h
73148 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73149 #endif
73150
73151 struct k_atm_aal_stats {
73152 -#define __HANDLE_ITEM(i) atomic_t i
73153 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73154 __AAL_STAT_ITEMS
73155 #undef __HANDLE_ITEM
73156 };
73157 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73158 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73159 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73160 struct module *owner;
73161 -};
73162 +} __do_const ;
73163
73164 struct atmphy_ops {
73165 int (*start)(struct atm_dev *dev);
73166 diff --git a/include/linux/audit.h b/include/linux/audit.h
73167 index 729a4d1..9b304ae 100644
73168 --- a/include/linux/audit.h
73169 +++ b/include/linux/audit.h
73170 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
73171 extern unsigned int audit_serial(void);
73172 extern int auditsc_get_stamp(struct audit_context *ctx,
73173 struct timespec *t, unsigned int *serial);
73174 -extern int audit_set_loginuid(kuid_t loginuid);
73175 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
73176
73177 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
73178 {
73179 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73180 index 7554fd4..0f86379 100644
73181 --- a/include/linux/binfmts.h
73182 +++ b/include/linux/binfmts.h
73183 @@ -73,8 +73,10 @@ struct linux_binfmt {
73184 int (*load_binary)(struct linux_binprm *);
73185 int (*load_shlib)(struct file *);
73186 int (*core_dump)(struct coredump_params *cprm);
73187 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73188 + void (*handle_mmap)(struct file *);
73189 unsigned long min_coredump; /* minimal dump size */
73190 -};
73191 +} __do_const;
73192
73193 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73194
73195 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
73196 index a3b6b82..cd8f69c 100644
73197 --- a/include/linux/bitops.h
73198 +++ b/include/linux/bitops.h
73199 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
73200 * @word: value to rotate
73201 * @shift: bits to roll
73202 */
73203 -static inline __u32 rol32(__u32 word, unsigned int shift)
73204 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
73205 {
73206 return (word << shift) | (word >> (32 - shift));
73207 }
73208 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
73209 * @word: value to rotate
73210 * @shift: bits to roll
73211 */
73212 -static inline __u32 ror32(__u32 word, unsigned int shift)
73213 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
73214 {
73215 return (word >> shift) | (word << (32 - shift));
73216 }
73217 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73218 index 0e6f765..885bb2b 100644
73219 --- a/include/linux/blkdev.h
73220 +++ b/include/linux/blkdev.h
73221 @@ -1537,7 +1537,7 @@ struct block_device_operations {
73222 /* this callback is with swap_lock and sometimes page table lock held */
73223 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73224 struct module *owner;
73225 -};
73226 +} __do_const;
73227
73228 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73229 unsigned long);
73230 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73231 index 7c2e030..b72475d 100644
73232 --- a/include/linux/blktrace_api.h
73233 +++ b/include/linux/blktrace_api.h
73234 @@ -23,7 +23,7 @@ struct blk_trace {
73235 struct dentry *dir;
73236 struct dentry *dropped_file;
73237 struct dentry *msg_file;
73238 - atomic_t dropped;
73239 + atomic_unchecked_t dropped;
73240 };
73241
73242 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
73243 diff --git a/include/linux/cache.h b/include/linux/cache.h
73244 index 4c57065..40346da 100644
73245 --- a/include/linux/cache.h
73246 +++ b/include/linux/cache.h
73247 @@ -16,6 +16,14 @@
73248 #define __read_mostly
73249 #endif
73250
73251 +#ifndef __read_only
73252 +#ifdef CONFIG_PAX_KERNEXEC
73253 +#error KERNEXEC requires __read_only
73254 +#else
73255 +#define __read_only __read_mostly
73256 +#endif
73257 +#endif
73258 +
73259 #ifndef ____cacheline_aligned
73260 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
73261 #endif
73262 diff --git a/include/linux/capability.h b/include/linux/capability.h
73263 index a6ee1f9..e1ca49d 100644
73264 --- a/include/linux/capability.h
73265 +++ b/include/linux/capability.h
73266 @@ -212,8 +212,13 @@ extern bool capable(int cap);
73267 extern bool ns_capable(struct user_namespace *ns, int cap);
73268 extern bool inode_capable(const struct inode *inode, int cap);
73269 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
73270 +extern bool capable_nolog(int cap);
73271 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
73272 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
73273
73274 /* audit system wants to get cap info from files as well */
73275 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
73276
73277 +extern int is_privileged_binary(const struct dentry *dentry);
73278 +
73279 #endif /* !_LINUX_CAPABILITY_H */
73280 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
73281 index 8609d57..86e4d79 100644
73282 --- a/include/linux/cdrom.h
73283 +++ b/include/linux/cdrom.h
73284 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
73285
73286 /* driver specifications */
73287 const int capability; /* capability flags */
73288 - int n_minors; /* number of active minor devices */
73289 /* handle uniform packets for scsi type devices (scsi,atapi) */
73290 int (*generic_packet) (struct cdrom_device_info *,
73291 struct packet_command *);
73292 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
73293 index 4ce9056..86caac6 100644
73294 --- a/include/linux/cleancache.h
73295 +++ b/include/linux/cleancache.h
73296 @@ -31,7 +31,7 @@ struct cleancache_ops {
73297 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
73298 void (*invalidate_inode)(int, struct cleancache_filekey);
73299 void (*invalidate_fs)(int);
73300 -};
73301 +} __no_const;
73302
73303 extern struct cleancache_ops *
73304 cleancache_register_ops(struct cleancache_ops *ops);
73305 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
73306 index 73bdb69..d66d47a 100644
73307 --- a/include/linux/clk-provider.h
73308 +++ b/include/linux/clk-provider.h
73309 @@ -141,6 +141,7 @@ struct clk_ops {
73310 unsigned long);
73311 void (*init)(struct clk_hw *hw);
73312 };
73313 +typedef struct clk_ops __no_const clk_ops_no_const;
73314
73315 /**
73316 * struct clk_init_data - holds init data that's common to all clocks and is
73317 diff --git a/include/linux/compat.h b/include/linux/compat.h
73318 index 345da00..b6eff26 100644
73319 --- a/include/linux/compat.h
73320 +++ b/include/linux/compat.h
73321 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
73322 compat_size_t __user *len_ptr);
73323
73324 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
73325 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
73326 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
73327 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
73328 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
73329 compat_ssize_t msgsz, int msgflg);
73330 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
73331 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73332 compat_ulong_t addr, compat_ulong_t data);
73333 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
73334 - compat_long_t addr, compat_long_t data);
73335 + compat_ulong_t addr, compat_ulong_t data);
73336
73337 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
73338 /*
73339 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
73340 index ded4299..da50e3b 100644
73341 --- a/include/linux/compiler-gcc4.h
73342 +++ b/include/linux/compiler-gcc4.h
73343 @@ -39,9 +39,29 @@
73344 # define __compiletime_warning(message) __attribute__((warning(message)))
73345 # define __compiletime_error(message) __attribute__((error(message)))
73346 #endif /* __CHECKER__ */
73347 +
73348 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
73349 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
73350 +#define __bos0(ptr) __bos((ptr), 0)
73351 +#define __bos1(ptr) __bos((ptr), 1)
73352 #endif /* GCC_VERSION >= 40300 */
73353
73354 #if GCC_VERSION >= 40500
73355 +
73356 +#ifdef CONSTIFY_PLUGIN
73357 +#define __no_const __attribute__((no_const))
73358 +#define __do_const __attribute__((do_const))
73359 +#endif
73360 +
73361 +#ifdef SIZE_OVERFLOW_PLUGIN
73362 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
73363 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
73364 +#endif
73365 +
73366 +#ifdef LATENT_ENTROPY_PLUGIN
73367 +#define __latent_entropy __attribute__((latent_entropy))
73368 +#endif
73369 +
73370 /*
73371 * Mark a position in code as unreachable. This can be used to
73372 * suppress control flow warnings after asm blocks that transfer
73373 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
73374 index 92669cd..1771a15 100644
73375 --- a/include/linux/compiler.h
73376 +++ b/include/linux/compiler.h
73377 @@ -5,11 +5,14 @@
73378
73379 #ifdef __CHECKER__
73380 # define __user __attribute__((noderef, address_space(1)))
73381 +# define __force_user __force __user
73382 # define __kernel __attribute__((address_space(0)))
73383 +# define __force_kernel __force __kernel
73384 # define __safe __attribute__((safe))
73385 # define __force __attribute__((force))
73386 # define __nocast __attribute__((nocast))
73387 # define __iomem __attribute__((noderef, address_space(2)))
73388 +# define __force_iomem __force __iomem
73389 # define __must_hold(x) __attribute__((context(x,1,1)))
73390 # define __acquires(x) __attribute__((context(x,0,1)))
73391 # define __releases(x) __attribute__((context(x,1,0)))
73392 @@ -17,20 +20,37 @@
73393 # define __release(x) __context__(x,-1)
73394 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
73395 # define __percpu __attribute__((noderef, address_space(3)))
73396 +# define __force_percpu __force __percpu
73397 #ifdef CONFIG_SPARSE_RCU_POINTER
73398 # define __rcu __attribute__((noderef, address_space(4)))
73399 +# define __force_rcu __force __rcu
73400 #else
73401 # define __rcu
73402 +# define __force_rcu
73403 #endif
73404 extern void __chk_user_ptr(const volatile void __user *);
73405 extern void __chk_io_ptr(const volatile void __iomem *);
73406 #else
73407 -# define __user
73408 -# define __kernel
73409 +# ifdef CHECKER_PLUGIN
73410 +//# define __user
73411 +//# define __force_user
73412 +//# define __kernel
73413 +//# define __force_kernel
73414 +# else
73415 +# ifdef STRUCTLEAK_PLUGIN
73416 +# define __user __attribute__((user))
73417 +# else
73418 +# define __user
73419 +# endif
73420 +# define __force_user
73421 +# define __kernel
73422 +# define __force_kernel
73423 +# endif
73424 # define __safe
73425 # define __force
73426 # define __nocast
73427 # define __iomem
73428 +# define __force_iomem
73429 # define __chk_user_ptr(x) (void)0
73430 # define __chk_io_ptr(x) (void)0
73431 # define __builtin_warning(x, y...) (1)
73432 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
73433 # define __release(x) (void)0
73434 # define __cond_lock(x,c) (c)
73435 # define __percpu
73436 +# define __force_percpu
73437 # define __rcu
73438 +# define __force_rcu
73439 #endif
73440
73441 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
73442 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73443 # define __attribute_const__ /* unimplemented */
73444 #endif
73445
73446 +#ifndef __no_const
73447 +# define __no_const
73448 +#endif
73449 +
73450 +#ifndef __do_const
73451 +# define __do_const
73452 +#endif
73453 +
73454 +#ifndef __size_overflow
73455 +# define __size_overflow(...)
73456 +#endif
73457 +
73458 +#ifndef __intentional_overflow
73459 +# define __intentional_overflow(...)
73460 +#endif
73461 +
73462 +#ifndef __latent_entropy
73463 +# define __latent_entropy
73464 +#endif
73465 +
73466 /*
73467 * Tell gcc if a function is cold. The compiler will assume any path
73468 * directly leading to the call is unlikely.
73469 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73470 #define __cold
73471 #endif
73472
73473 +#ifndef __alloc_size
73474 +#define __alloc_size(...)
73475 +#endif
73476 +
73477 +#ifndef __bos
73478 +#define __bos(ptr, arg)
73479 +#endif
73480 +
73481 +#ifndef __bos0
73482 +#define __bos0(ptr)
73483 +#endif
73484 +
73485 +#ifndef __bos1
73486 +#define __bos1(ptr)
73487 +#endif
73488 +
73489 /* Simple shorthand for a section definition */
73490 #ifndef __section
73491 # define __section(S) __attribute__ ((__section__(#S)))
73492 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73493 * use is to mediate communication between process-level code and irq/NMI
73494 * handlers, all running on the same CPU.
73495 */
73496 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
73497 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
73498 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
73499
73500 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
73501 #ifdef CONFIG_KPROBES
73502 diff --git a/include/linux/completion.h b/include/linux/completion.h
73503 index 3cd574d..240dcb0 100644
73504 --- a/include/linux/completion.h
73505 +++ b/include/linux/completion.h
73506 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
73507
73508 extern void wait_for_completion(struct completion *);
73509 extern void wait_for_completion_io(struct completion *);
73510 -extern int wait_for_completion_interruptible(struct completion *x);
73511 -extern int wait_for_completion_killable(struct completion *x);
73512 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
73513 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
73514 extern unsigned long wait_for_completion_timeout(struct completion *x,
73515 - unsigned long timeout);
73516 + unsigned long timeout) __intentional_overflow(-1);
73517 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
73518 - unsigned long timeout);
73519 + unsigned long timeout) __intentional_overflow(-1);
73520 extern long wait_for_completion_interruptible_timeout(
73521 - struct completion *x, unsigned long timeout);
73522 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73523 extern long wait_for_completion_killable_timeout(
73524 - struct completion *x, unsigned long timeout);
73525 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73526 extern bool try_wait_for_completion(struct completion *x);
73527 extern bool completion_done(struct completion *x);
73528
73529 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
73530 index 34025df..d94bbbc 100644
73531 --- a/include/linux/configfs.h
73532 +++ b/include/linux/configfs.h
73533 @@ -125,7 +125,7 @@ struct configfs_attribute {
73534 const char *ca_name;
73535 struct module *ca_owner;
73536 umode_t ca_mode;
73537 -};
73538 +} __do_const;
73539
73540 /*
73541 * Users often need to create attribute structures for their configurable
73542 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
73543 index fcabc42..cba5d93 100644
73544 --- a/include/linux/cpufreq.h
73545 +++ b/include/linux/cpufreq.h
73546 @@ -167,6 +167,7 @@ struct global_attr {
73547 ssize_t (*store)(struct kobject *a, struct attribute *b,
73548 const char *c, size_t count);
73549 };
73550 +typedef struct global_attr __no_const global_attr_no_const;
73551
73552 #define define_one_global_ro(_name) \
73553 static struct global_attr _name = \
73554 @@ -208,7 +209,7 @@ struct cpufreq_driver {
73555 int (*suspend) (struct cpufreq_policy *policy);
73556 int (*resume) (struct cpufreq_policy *policy);
73557 struct freq_attr **attr;
73558 -};
73559 +} __do_const;
73560
73561 /* flags */
73562 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
73563 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
73564 index 781addc..d1e1fe6 100644
73565 --- a/include/linux/cpuidle.h
73566 +++ b/include/linux/cpuidle.h
73567 @@ -50,7 +50,8 @@ struct cpuidle_state {
73568 int index);
73569
73570 int (*enter_dead) (struct cpuidle_device *dev, int index);
73571 -};
73572 +} __do_const;
73573 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
73574
73575 /* Idle State Flags */
73576 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
73577 @@ -192,7 +193,7 @@ struct cpuidle_governor {
73578 void (*reflect) (struct cpuidle_device *dev, int index);
73579
73580 struct module *owner;
73581 -};
73582 +} __do_const;
73583
73584 #ifdef CONFIG_CPU_IDLE
73585
73586 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
73587 index d08e4d2..95fad61 100644
73588 --- a/include/linux/cpumask.h
73589 +++ b/include/linux/cpumask.h
73590 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73591 }
73592
73593 /* Valid inputs for n are -1 and 0. */
73594 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73595 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73596 {
73597 return n+1;
73598 }
73599
73600 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73601 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73602 {
73603 return n+1;
73604 }
73605
73606 -static inline unsigned int cpumask_next_and(int n,
73607 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
73608 const struct cpumask *srcp,
73609 const struct cpumask *andp)
73610 {
73611 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73612 *
73613 * Returns >= nr_cpu_ids if no further cpus set.
73614 */
73615 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73616 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73617 {
73618 /* -1 is a legal arg here. */
73619 if (n != -1)
73620 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73621 *
73622 * Returns >= nr_cpu_ids if no further cpus unset.
73623 */
73624 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73625 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73626 {
73627 /* -1 is a legal arg here. */
73628 if (n != -1)
73629 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73630 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
73631 }
73632
73633 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
73634 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
73635 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
73636
73637 /**
73638 diff --git a/include/linux/cred.h b/include/linux/cred.h
73639 index 04421e8..6bce4ef 100644
73640 --- a/include/linux/cred.h
73641 +++ b/include/linux/cred.h
73642 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
73643 static inline void validate_process_creds(void)
73644 {
73645 }
73646 +static inline void validate_task_creds(struct task_struct *task)
73647 +{
73648 +}
73649 #endif
73650
73651 /**
73652 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
73653 index b92eadf..b4ecdc1 100644
73654 --- a/include/linux/crypto.h
73655 +++ b/include/linux/crypto.h
73656 @@ -373,7 +373,7 @@ struct cipher_tfm {
73657 const u8 *key, unsigned int keylen);
73658 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73659 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73660 -};
73661 +} __no_const;
73662
73663 struct hash_tfm {
73664 int (*init)(struct hash_desc *desc);
73665 @@ -394,13 +394,13 @@ struct compress_tfm {
73666 int (*cot_decompress)(struct crypto_tfm *tfm,
73667 const u8 *src, unsigned int slen,
73668 u8 *dst, unsigned int *dlen);
73669 -};
73670 +} __no_const;
73671
73672 struct rng_tfm {
73673 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
73674 unsigned int dlen);
73675 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
73676 -};
73677 +} __no_const;
73678
73679 #define crt_ablkcipher crt_u.ablkcipher
73680 #define crt_aead crt_u.aead
73681 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
73682 index 653589e..4ef254a 100644
73683 --- a/include/linux/ctype.h
73684 +++ b/include/linux/ctype.h
73685 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
73686 * Fast implementation of tolower() for internal usage. Do not use in your
73687 * code.
73688 */
73689 -static inline char _tolower(const char c)
73690 +static inline unsigned char _tolower(const unsigned char c)
73691 {
73692 return c | 0x20;
73693 }
73694 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
73695 index 7925bf0..d5143d2 100644
73696 --- a/include/linux/decompress/mm.h
73697 +++ b/include/linux/decompress/mm.h
73698 @@ -77,7 +77,7 @@ static void free(void *where)
73699 * warnings when not needed (indeed large_malloc / large_free are not
73700 * needed by inflate */
73701
73702 -#define malloc(a) kmalloc(a, GFP_KERNEL)
73703 +#define malloc(a) kmalloc((a), GFP_KERNEL)
73704 #define free(a) kfree(a)
73705
73706 #define large_malloc(a) vmalloc(a)
73707 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
73708 index 5f1ab92..39c35ae 100644
73709 --- a/include/linux/devfreq.h
73710 +++ b/include/linux/devfreq.h
73711 @@ -114,7 +114,7 @@ struct devfreq_governor {
73712 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
73713 int (*event_handler)(struct devfreq *devfreq,
73714 unsigned int event, void *data);
73715 -};
73716 +} __do_const;
73717
73718 /**
73719 * struct devfreq - Device devfreq structure
73720 diff --git a/include/linux/device.h b/include/linux/device.h
73721 index 2a9d6ed..d14551e3 100644
73722 --- a/include/linux/device.h
73723 +++ b/include/linux/device.h
73724 @@ -313,7 +313,7 @@ struct subsys_interface {
73725 struct list_head node;
73726 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
73727 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
73728 -};
73729 +} __do_const;
73730
73731 int subsys_interface_register(struct subsys_interface *sif);
73732 void subsys_interface_unregister(struct subsys_interface *sif);
73733 @@ -501,7 +501,7 @@ struct device_type {
73734 void (*release)(struct device *dev);
73735
73736 const struct dev_pm_ops *pm;
73737 -};
73738 +} __do_const;
73739
73740 /* interface for exporting device attributes */
73741 struct device_attribute {
73742 @@ -511,11 +511,12 @@ struct device_attribute {
73743 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
73744 const char *buf, size_t count);
73745 };
73746 +typedef struct device_attribute __no_const device_attribute_no_const;
73747
73748 struct dev_ext_attribute {
73749 struct device_attribute attr;
73750 void *var;
73751 -};
73752 +} __do_const;
73753
73754 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
73755 char *buf);
73756 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
73757 index 3a8d0a2..c762be2 100644
73758 --- a/include/linux/dma-mapping.h
73759 +++ b/include/linux/dma-mapping.h
73760 @@ -54,7 +54,7 @@ struct dma_map_ops {
73761 u64 (*get_required_mask)(struct device *dev);
73762 #endif
73763 int is_phys;
73764 -};
73765 +} __do_const;
73766
73767 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
73768
73769 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
73770 index 0bc7275..4ccbf11 100644
73771 --- a/include/linux/dmaengine.h
73772 +++ b/include/linux/dmaengine.h
73773 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
73774 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
73775 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
73776
73777 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73778 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73779 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
73780 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73781 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73782 struct dma_pinned_list *pinned_list, struct page *page,
73783 unsigned int offset, size_t len);
73784
73785 diff --git a/include/linux/efi.h b/include/linux/efi.h
73786 index 5f8f176..62a0556 100644
73787 --- a/include/linux/efi.h
73788 +++ b/include/linux/efi.h
73789 @@ -745,6 +745,7 @@ struct efivar_operations {
73790 efi_set_variable_t *set_variable;
73791 efi_query_variable_store_t *query_variable_store;
73792 };
73793 +typedef struct efivar_operations __no_const efivar_operations_no_const;
73794
73795 struct efivars {
73796 /*
73797 diff --git a/include/linux/elf.h b/include/linux/elf.h
73798 index 40a3c0e..4c45a38 100644
73799 --- a/include/linux/elf.h
73800 +++ b/include/linux/elf.h
73801 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
73802 #define elf_note elf32_note
73803 #define elf_addr_t Elf32_Off
73804 #define Elf_Half Elf32_Half
73805 +#define elf_dyn Elf32_Dyn
73806
73807 #else
73808
73809 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
73810 #define elf_note elf64_note
73811 #define elf_addr_t Elf64_Off
73812 #define Elf_Half Elf64_Half
73813 +#define elf_dyn Elf64_Dyn
73814
73815 #endif
73816
73817 diff --git a/include/linux/err.h b/include/linux/err.h
73818 index 15f92e0..e825a8e 100644
73819 --- a/include/linux/err.h
73820 +++ b/include/linux/err.h
73821 @@ -19,12 +19,12 @@
73822
73823 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
73824
73825 -static inline void * __must_check ERR_PTR(long error)
73826 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73827 {
73828 return (void *) error;
73829 }
73830
73831 -static inline long __must_check PTR_ERR(__force const void *ptr)
73832 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73833 {
73834 return (long) ptr;
73835 }
73836 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73837 index fcb51c8..bdafcf6 100644
73838 --- a/include/linux/extcon.h
73839 +++ b/include/linux/extcon.h
73840 @@ -134,7 +134,7 @@ struct extcon_dev {
73841 /* /sys/class/extcon/.../mutually_exclusive/... */
73842 struct attribute_group attr_g_muex;
73843 struct attribute **attrs_muex;
73844 - struct device_attribute *d_attrs_muex;
73845 + device_attribute_no_const *d_attrs_muex;
73846 };
73847
73848 /**
73849 diff --git a/include/linux/fb.h b/include/linux/fb.h
73850 index ffac70a..ca3e711 100644
73851 --- a/include/linux/fb.h
73852 +++ b/include/linux/fb.h
73853 @@ -304,7 +304,7 @@ struct fb_ops {
73854 /* called at KDB enter and leave time to prepare the console */
73855 int (*fb_debug_enter)(struct fb_info *info);
73856 int (*fb_debug_leave)(struct fb_info *info);
73857 -};
73858 +} __do_const;
73859
73860 #ifdef CONFIG_FB_TILEBLITTING
73861 #define FB_TILE_CURSOR_NONE 0
73862 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73863 index 085197b..0fa6f0b 100644
73864 --- a/include/linux/fdtable.h
73865 +++ b/include/linux/fdtable.h
73866 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73867 void put_files_struct(struct files_struct *fs);
73868 void reset_files_struct(struct files_struct *);
73869 int unshare_files(struct files_struct **);
73870 -struct files_struct *dup_fd(struct files_struct *, int *);
73871 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73872 void do_close_on_exec(struct files_struct *);
73873 int iterate_fd(struct files_struct *, unsigned,
73874 int (*)(const void *, struct file *, unsigned),
73875 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73876 index 8293262..2b3b8bd 100644
73877 --- a/include/linux/frontswap.h
73878 +++ b/include/linux/frontswap.h
73879 @@ -11,7 +11,7 @@ struct frontswap_ops {
73880 int (*load)(unsigned, pgoff_t, struct page *);
73881 void (*invalidate_page)(unsigned, pgoff_t);
73882 void (*invalidate_area)(unsigned);
73883 -};
73884 +} __no_const;
73885
73886 extern bool frontswap_enabled;
73887 extern struct frontswap_ops *
73888 diff --git a/include/linux/fs.h b/include/linux/fs.h
73889 index 3f40547..46f76eb 100644
73890 --- a/include/linux/fs.h
73891 +++ b/include/linux/fs.h
73892 @@ -1552,7 +1552,8 @@ struct file_operations {
73893 long (*fallocate)(struct file *file, int mode, loff_t offset,
73894 loff_t len);
73895 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73896 -};
73897 +} __do_const;
73898 +typedef struct file_operations __no_const file_operations_no_const;
73899
73900 struct inode_operations {
73901 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73902 @@ -2745,4 +2746,14 @@ static inline bool dir_relax(struct inode *inode)
73903 return !IS_DEADDIR(inode);
73904 }
73905
73906 +static inline bool is_sidechannel_device(const struct inode *inode)
73907 +{
73908 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73909 + umode_t mode = inode->i_mode;
73910 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73911 +#else
73912 + return false;
73913 +#endif
73914 +}
73915 +
73916 #endif /* _LINUX_FS_H */
73917 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73918 index 0efc3e6..e0e1e5f 100644
73919 --- a/include/linux/fs_struct.h
73920 +++ b/include/linux/fs_struct.h
73921 @@ -6,7 +6,7 @@
73922 #include <linux/seqlock.h>
73923
73924 struct fs_struct {
73925 - int users;
73926 + atomic_t users;
73927 spinlock_t lock;
73928 seqcount_t seq;
73929 int umask;
73930 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73931 index 7823e9e..56b6f2f 100644
73932 --- a/include/linux/fscache-cache.h
73933 +++ b/include/linux/fscache-cache.h
73934 @@ -113,7 +113,7 @@ struct fscache_operation {
73935 fscache_operation_release_t release;
73936 };
73937
73938 -extern atomic_t fscache_op_debug_id;
73939 +extern atomic_unchecked_t fscache_op_debug_id;
73940 extern void fscache_op_work_func(struct work_struct *work);
73941
73942 extern void fscache_enqueue_operation(struct fscache_operation *);
73943 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73944 INIT_WORK(&op->work, fscache_op_work_func);
73945 atomic_set(&op->usage, 1);
73946 op->state = FSCACHE_OP_ST_INITIALISED;
73947 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73948 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73949 op->processor = processor;
73950 op->release = release;
73951 INIT_LIST_HEAD(&op->pend_link);
73952 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73953 index 19b4645..3b73dfc 100644
73954 --- a/include/linux/fscache.h
73955 +++ b/include/linux/fscache.h
73956 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73957 * - this is mandatory for any object that may have data
73958 */
73959 void (*now_uncached)(void *cookie_netfs_data);
73960 -};
73961 +} __do_const;
73962
73963 /*
73964 * fscache cached network filesystem type
73965 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73966 index 1c804b0..1432c2b 100644
73967 --- a/include/linux/fsnotify.h
73968 +++ b/include/linux/fsnotify.h
73969 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73970 struct inode *inode = file_inode(file);
73971 __u32 mask = FS_ACCESS;
73972
73973 + if (is_sidechannel_device(inode))
73974 + return;
73975 +
73976 if (S_ISDIR(inode->i_mode))
73977 mask |= FS_ISDIR;
73978
73979 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73980 struct inode *inode = file_inode(file);
73981 __u32 mask = FS_MODIFY;
73982
73983 + if (is_sidechannel_device(inode))
73984 + return;
73985 +
73986 if (S_ISDIR(inode->i_mode))
73987 mask |= FS_ISDIR;
73988
73989 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73990 */
73991 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73992 {
73993 - return kstrdup(name, GFP_KERNEL);
73994 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73995 }
73996
73997 /*
73998 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73999 index 9f3c275..8bdff5d 100644
74000 --- a/include/linux/genhd.h
74001 +++ b/include/linux/genhd.h
74002 @@ -194,7 +194,7 @@ struct gendisk {
74003 struct kobject *slave_dir;
74004
74005 struct timer_rand_state *random;
74006 - atomic_t sync_io; /* RAID */
74007 + atomic_unchecked_t sync_io; /* RAID */
74008 struct disk_events *ev;
74009 #ifdef CONFIG_BLK_DEV_INTEGRITY
74010 struct blk_integrity *integrity;
74011 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
74012 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
74013
74014 /* drivers/char/random.c */
74015 -extern void add_disk_randomness(struct gendisk *disk);
74016 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
74017 extern void rand_initialize_disk(struct gendisk *disk);
74018
74019 static inline sector_t get_start_sect(struct block_device *bdev)
74020 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74021 index 023bc34..b02b46a 100644
74022 --- a/include/linux/genl_magic_func.h
74023 +++ b/include/linux/genl_magic_func.h
74024 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74025 },
74026
74027 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74028 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74029 +static struct genl_ops ZZZ_genl_ops[] = {
74030 #include GENL_MAGIC_INCLUDE_FILE
74031 };
74032
74033 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74034 index 9b4dd49..61fd41d 100644
74035 --- a/include/linux/gfp.h
74036 +++ b/include/linux/gfp.h
74037 @@ -35,6 +35,13 @@ struct vm_area_struct;
74038 #define ___GFP_NO_KSWAPD 0x400000u
74039 #define ___GFP_OTHER_NODE 0x800000u
74040 #define ___GFP_WRITE 0x1000000u
74041 +
74042 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74043 +#define ___GFP_USERCOPY 0x2000000u
74044 +#else
74045 +#define ___GFP_USERCOPY 0
74046 +#endif
74047 +
74048 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74049
74050 /*
74051 @@ -92,6 +99,7 @@ struct vm_area_struct;
74052 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74053 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74054 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74055 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74056
74057 /*
74058 * This may seem redundant, but it's a way of annotating false positives vs.
74059 @@ -99,7 +107,7 @@ struct vm_area_struct;
74060 */
74061 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74062
74063 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74064 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74065 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74066
74067 /* This equals 0, but use constants in case they ever change */
74068 @@ -153,6 +161,8 @@ struct vm_area_struct;
74069 /* 4GB DMA on some platforms */
74070 #define GFP_DMA32 __GFP_DMA32
74071
74072 +#define GFP_USERCOPY __GFP_USERCOPY
74073 +
74074 /* Convert GFP flags to their corresponding migrate type */
74075 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74076 {
74077 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74078 new file mode 100644
74079 index 0000000..edb2cb6
74080 --- /dev/null
74081 +++ b/include/linux/gracl.h
74082 @@ -0,0 +1,340 @@
74083 +#ifndef GR_ACL_H
74084 +#define GR_ACL_H
74085 +
74086 +#include <linux/grdefs.h>
74087 +#include <linux/resource.h>
74088 +#include <linux/capability.h>
74089 +#include <linux/dcache.h>
74090 +#include <asm/resource.h>
74091 +
74092 +/* Major status information */
74093 +
74094 +#define GR_VERSION "grsecurity 3.0"
74095 +#define GRSECURITY_VERSION 0x3000
74096 +
74097 +enum {
74098 + GR_SHUTDOWN = 0,
74099 + GR_ENABLE = 1,
74100 + GR_SPROLE = 2,
74101 + GR_OLDRELOAD = 3,
74102 + GR_SEGVMOD = 4,
74103 + GR_STATUS = 5,
74104 + GR_UNSPROLE = 6,
74105 + GR_PASSSET = 7,
74106 + GR_SPROLEPAM = 8,
74107 + GR_RELOAD = 9,
74108 +};
74109 +
74110 +/* Password setup definitions
74111 + * kernel/grhash.c */
74112 +enum {
74113 + GR_PW_LEN = 128,
74114 + GR_SALT_LEN = 16,
74115 + GR_SHA_LEN = 32,
74116 +};
74117 +
74118 +enum {
74119 + GR_SPROLE_LEN = 64,
74120 +};
74121 +
74122 +enum {
74123 + GR_NO_GLOB = 0,
74124 + GR_REG_GLOB,
74125 + GR_CREATE_GLOB
74126 +};
74127 +
74128 +#define GR_NLIMITS 32
74129 +
74130 +/* Begin Data Structures */
74131 +
74132 +struct sprole_pw {
74133 + unsigned char *rolename;
74134 + unsigned char salt[GR_SALT_LEN];
74135 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74136 +};
74137 +
74138 +struct name_entry {
74139 + __u32 key;
74140 + ino_t inode;
74141 + dev_t device;
74142 + char *name;
74143 + __u16 len;
74144 + __u8 deleted;
74145 + struct name_entry *prev;
74146 + struct name_entry *next;
74147 +};
74148 +
74149 +struct inodev_entry {
74150 + struct name_entry *nentry;
74151 + struct inodev_entry *prev;
74152 + struct inodev_entry *next;
74153 +};
74154 +
74155 +struct acl_role_db {
74156 + struct acl_role_label **r_hash;
74157 + __u32 r_size;
74158 +};
74159 +
74160 +struct inodev_db {
74161 + struct inodev_entry **i_hash;
74162 + __u32 i_size;
74163 +};
74164 +
74165 +struct name_db {
74166 + struct name_entry **n_hash;
74167 + __u32 n_size;
74168 +};
74169 +
74170 +struct crash_uid {
74171 + uid_t uid;
74172 + unsigned long expires;
74173 +};
74174 +
74175 +struct gr_hash_struct {
74176 + void **table;
74177 + void **nametable;
74178 + void *first;
74179 + __u32 table_size;
74180 + __u32 used_size;
74181 + int type;
74182 +};
74183 +
74184 +/* Userspace Grsecurity ACL data structures */
74185 +
74186 +struct acl_subject_label {
74187 + char *filename;
74188 + ino_t inode;
74189 + dev_t device;
74190 + __u32 mode;
74191 + kernel_cap_t cap_mask;
74192 + kernel_cap_t cap_lower;
74193 + kernel_cap_t cap_invert_audit;
74194 +
74195 + struct rlimit res[GR_NLIMITS];
74196 + __u32 resmask;
74197 +
74198 + __u8 user_trans_type;
74199 + __u8 group_trans_type;
74200 + uid_t *user_transitions;
74201 + gid_t *group_transitions;
74202 + __u16 user_trans_num;
74203 + __u16 group_trans_num;
74204 +
74205 + __u32 sock_families[2];
74206 + __u32 ip_proto[8];
74207 + __u32 ip_type;
74208 + struct acl_ip_label **ips;
74209 + __u32 ip_num;
74210 + __u32 inaddr_any_override;
74211 +
74212 + __u32 crashes;
74213 + unsigned long expires;
74214 +
74215 + struct acl_subject_label *parent_subject;
74216 + struct gr_hash_struct *hash;
74217 + struct acl_subject_label *prev;
74218 + struct acl_subject_label *next;
74219 +
74220 + struct acl_object_label **obj_hash;
74221 + __u32 obj_hash_size;
74222 + __u16 pax_flags;
74223 +};
74224 +
74225 +struct role_allowed_ip {
74226 + __u32 addr;
74227 + __u32 netmask;
74228 +
74229 + struct role_allowed_ip *prev;
74230 + struct role_allowed_ip *next;
74231 +};
74232 +
74233 +struct role_transition {
74234 + char *rolename;
74235 +
74236 + struct role_transition *prev;
74237 + struct role_transition *next;
74238 +};
74239 +
74240 +struct acl_role_label {
74241 + char *rolename;
74242 + uid_t uidgid;
74243 + __u16 roletype;
74244 +
74245 + __u16 auth_attempts;
74246 + unsigned long expires;
74247 +
74248 + struct acl_subject_label *root_label;
74249 + struct gr_hash_struct *hash;
74250 +
74251 + struct acl_role_label *prev;
74252 + struct acl_role_label *next;
74253 +
74254 + struct role_transition *transitions;
74255 + struct role_allowed_ip *allowed_ips;
74256 + uid_t *domain_children;
74257 + __u16 domain_child_num;
74258 +
74259 + umode_t umask;
74260 +
74261 + struct acl_subject_label **subj_hash;
74262 + __u32 subj_hash_size;
74263 +};
74264 +
74265 +struct user_acl_role_db {
74266 + struct acl_role_label **r_table;
74267 + __u32 num_pointers; /* Number of allocations to track */
74268 + __u32 num_roles; /* Number of roles */
74269 + __u32 num_domain_children; /* Number of domain children */
74270 + __u32 num_subjects; /* Number of subjects */
74271 + __u32 num_objects; /* Number of objects */
74272 +};
74273 +
74274 +struct acl_object_label {
74275 + char *filename;
74276 + ino_t inode;
74277 + dev_t device;
74278 + __u32 mode;
74279 +
74280 + struct acl_subject_label *nested;
74281 + struct acl_object_label *globbed;
74282 +
74283 + /* next two structures not used */
74284 +
74285 + struct acl_object_label *prev;
74286 + struct acl_object_label *next;
74287 +};
74288 +
74289 +struct acl_ip_label {
74290 + char *iface;
74291 + __u32 addr;
74292 + __u32 netmask;
74293 + __u16 low, high;
74294 + __u8 mode;
74295 + __u32 type;
74296 + __u32 proto[8];
74297 +
74298 + /* next two structures not used */
74299 +
74300 + struct acl_ip_label *prev;
74301 + struct acl_ip_label *next;
74302 +};
74303 +
74304 +struct gr_arg {
74305 + struct user_acl_role_db role_db;
74306 + unsigned char pw[GR_PW_LEN];
74307 + unsigned char salt[GR_SALT_LEN];
74308 + unsigned char sum[GR_SHA_LEN];
74309 + unsigned char sp_role[GR_SPROLE_LEN];
74310 + struct sprole_pw *sprole_pws;
74311 + dev_t segv_device;
74312 + ino_t segv_inode;
74313 + uid_t segv_uid;
74314 + __u16 num_sprole_pws;
74315 + __u16 mode;
74316 +};
74317 +
74318 +struct gr_arg_wrapper {
74319 + struct gr_arg *arg;
74320 + __u32 version;
74321 + __u32 size;
74322 +};
74323 +
74324 +struct subject_map {
74325 + struct acl_subject_label *user;
74326 + struct acl_subject_label *kernel;
74327 + struct subject_map *prev;
74328 + struct subject_map *next;
74329 +};
74330 +
74331 +struct acl_subj_map_db {
74332 + struct subject_map **s_hash;
74333 + __u32 s_size;
74334 +};
74335 +
74336 +struct gr_policy_state {
74337 + struct sprole_pw **acl_special_roles;
74338 + __u16 num_sprole_pws;
74339 + struct acl_role_label *kernel_role;
74340 + struct acl_role_label *role_list;
74341 + struct acl_role_label *default_role;
74342 + struct acl_role_db acl_role_set;
74343 + struct acl_subj_map_db subj_map_set;
74344 + struct name_db name_set;
74345 + struct inodev_db inodev_set;
74346 +};
74347 +
74348 +struct gr_alloc_state {
74349 + unsigned long alloc_stack_next;
74350 + unsigned long alloc_stack_size;
74351 + void **alloc_stack;
74352 +};
74353 +
74354 +struct gr_reload_state {
74355 + struct gr_policy_state oldpolicy;
74356 + struct gr_alloc_state oldalloc;
74357 + struct gr_policy_state newpolicy;
74358 + struct gr_alloc_state newalloc;
74359 + struct gr_policy_state *oldpolicy_ptr;
74360 + struct gr_alloc_state *oldalloc_ptr;
74361 + unsigned char oldmode;
74362 +};
74363 +
74364 +/* End Data Structures Section */
74365 +
74366 +/* Hash functions generated by empirical testing by Brad Spengler
74367 + Makes good use of the low bits of the inode. Generally 0-1 times
74368 + in loop for successful match. 0-3 for unsuccessful match.
74369 + Shift/add algorithm with modulus of table size and an XOR*/
74370 +
74371 +static __inline__ unsigned int
74372 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
74373 +{
74374 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
74375 +}
74376 +
74377 + static __inline__ unsigned int
74378 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
74379 +{
74380 + return ((const unsigned long)userp % sz);
74381 +}
74382 +
74383 +static __inline__ unsigned int
74384 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
74385 +{
74386 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
74387 +}
74388 +
74389 +static __inline__ unsigned int
74390 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
74391 +{
74392 + return full_name_hash((const unsigned char *)name, len) % sz;
74393 +}
74394 +
74395 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
74396 + subj = NULL; \
74397 + iter = 0; \
74398 + while (iter < role->subj_hash_size) { \
74399 + if (subj == NULL) \
74400 + subj = role->subj_hash[iter]; \
74401 + if (subj == NULL) { \
74402 + iter++; \
74403 + continue; \
74404 + }
74405 +
74406 +#define FOR_EACH_SUBJECT_END(subj,iter) \
74407 + subj = subj->next; \
74408 + if (subj == NULL) \
74409 + iter++; \
74410 + }
74411 +
74412 +
74413 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
74414 + subj = role->hash->first; \
74415 + while (subj != NULL) {
74416 +
74417 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
74418 + subj = subj->next; \
74419 + }
74420 +
74421 +#endif
74422 +
74423 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
74424 new file mode 100644
74425 index 0000000..33ebd1f
74426 --- /dev/null
74427 +++ b/include/linux/gracl_compat.h
74428 @@ -0,0 +1,156 @@
74429 +#ifndef GR_ACL_COMPAT_H
74430 +#define GR_ACL_COMPAT_H
74431 +
74432 +#include <linux/resource.h>
74433 +#include <asm/resource.h>
74434 +
74435 +struct sprole_pw_compat {
74436 + compat_uptr_t rolename;
74437 + unsigned char salt[GR_SALT_LEN];
74438 + unsigned char sum[GR_SHA_LEN];
74439 +};
74440 +
74441 +struct gr_hash_struct_compat {
74442 + compat_uptr_t table;
74443 + compat_uptr_t nametable;
74444 + compat_uptr_t first;
74445 + __u32 table_size;
74446 + __u32 used_size;
74447 + int type;
74448 +};
74449 +
74450 +struct acl_subject_label_compat {
74451 + compat_uptr_t filename;
74452 + compat_ino_t inode;
74453 + __u32 device;
74454 + __u32 mode;
74455 + kernel_cap_t cap_mask;
74456 + kernel_cap_t cap_lower;
74457 + kernel_cap_t cap_invert_audit;
74458 +
74459 + struct compat_rlimit res[GR_NLIMITS];
74460 + __u32 resmask;
74461 +
74462 + __u8 user_trans_type;
74463 + __u8 group_trans_type;
74464 + compat_uptr_t user_transitions;
74465 + compat_uptr_t group_transitions;
74466 + __u16 user_trans_num;
74467 + __u16 group_trans_num;
74468 +
74469 + __u32 sock_families[2];
74470 + __u32 ip_proto[8];
74471 + __u32 ip_type;
74472 + compat_uptr_t ips;
74473 + __u32 ip_num;
74474 + __u32 inaddr_any_override;
74475 +
74476 + __u32 crashes;
74477 + compat_ulong_t expires;
74478 +
74479 + compat_uptr_t parent_subject;
74480 + compat_uptr_t hash;
74481 + compat_uptr_t prev;
74482 + compat_uptr_t next;
74483 +
74484 + compat_uptr_t obj_hash;
74485 + __u32 obj_hash_size;
74486 + __u16 pax_flags;
74487 +};
74488 +
74489 +struct role_allowed_ip_compat {
74490 + __u32 addr;
74491 + __u32 netmask;
74492 +
74493 + compat_uptr_t prev;
74494 + compat_uptr_t next;
74495 +};
74496 +
74497 +struct role_transition_compat {
74498 + compat_uptr_t rolename;
74499 +
74500 + compat_uptr_t prev;
74501 + compat_uptr_t next;
74502 +};
74503 +
74504 +struct acl_role_label_compat {
74505 + compat_uptr_t rolename;
74506 + uid_t uidgid;
74507 + __u16 roletype;
74508 +
74509 + __u16 auth_attempts;
74510 + compat_ulong_t expires;
74511 +
74512 + compat_uptr_t root_label;
74513 + compat_uptr_t hash;
74514 +
74515 + compat_uptr_t prev;
74516 + compat_uptr_t next;
74517 +
74518 + compat_uptr_t transitions;
74519 + compat_uptr_t allowed_ips;
74520 + compat_uptr_t domain_children;
74521 + __u16 domain_child_num;
74522 +
74523 + umode_t umask;
74524 +
74525 + compat_uptr_t subj_hash;
74526 + __u32 subj_hash_size;
74527 +};
74528 +
74529 +struct user_acl_role_db_compat {
74530 + compat_uptr_t r_table;
74531 + __u32 num_pointers;
74532 + __u32 num_roles;
74533 + __u32 num_domain_children;
74534 + __u32 num_subjects;
74535 + __u32 num_objects;
74536 +};
74537 +
74538 +struct acl_object_label_compat {
74539 + compat_uptr_t filename;
74540 + compat_ino_t inode;
74541 + __u32 device;
74542 + __u32 mode;
74543 +
74544 + compat_uptr_t nested;
74545 + compat_uptr_t globbed;
74546 +
74547 + compat_uptr_t prev;
74548 + compat_uptr_t next;
74549 +};
74550 +
74551 +struct acl_ip_label_compat {
74552 + compat_uptr_t iface;
74553 + __u32 addr;
74554 + __u32 netmask;
74555 + __u16 low, high;
74556 + __u8 mode;
74557 + __u32 type;
74558 + __u32 proto[8];
74559 +
74560 + compat_uptr_t prev;
74561 + compat_uptr_t next;
74562 +};
74563 +
74564 +struct gr_arg_compat {
74565 + struct user_acl_role_db_compat role_db;
74566 + unsigned char pw[GR_PW_LEN];
74567 + unsigned char salt[GR_SALT_LEN];
74568 + unsigned char sum[GR_SHA_LEN];
74569 + unsigned char sp_role[GR_SPROLE_LEN];
74570 + compat_uptr_t sprole_pws;
74571 + __u32 segv_device;
74572 + compat_ino_t segv_inode;
74573 + uid_t segv_uid;
74574 + __u16 num_sprole_pws;
74575 + __u16 mode;
74576 +};
74577 +
74578 +struct gr_arg_wrapper_compat {
74579 + compat_uptr_t arg;
74580 + __u32 version;
74581 + __u32 size;
74582 +};
74583 +
74584 +#endif
74585 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
74586 new file mode 100644
74587 index 0000000..323ecf2
74588 --- /dev/null
74589 +++ b/include/linux/gralloc.h
74590 @@ -0,0 +1,9 @@
74591 +#ifndef __GRALLOC_H
74592 +#define __GRALLOC_H
74593 +
74594 +void acl_free_all(void);
74595 +int acl_alloc_stack_init(unsigned long size);
74596 +void *acl_alloc(unsigned long len);
74597 +void *acl_alloc_num(unsigned long num, unsigned long len);
74598 +
74599 +#endif
74600 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
74601 new file mode 100644
74602 index 0000000..be66033
74603 --- /dev/null
74604 +++ b/include/linux/grdefs.h
74605 @@ -0,0 +1,140 @@
74606 +#ifndef GRDEFS_H
74607 +#define GRDEFS_H
74608 +
74609 +/* Begin grsecurity status declarations */
74610 +
74611 +enum {
74612 + GR_READY = 0x01,
74613 + GR_STATUS_INIT = 0x00 // disabled state
74614 +};
74615 +
74616 +/* Begin ACL declarations */
74617 +
74618 +/* Role flags */
74619 +
74620 +enum {
74621 + GR_ROLE_USER = 0x0001,
74622 + GR_ROLE_GROUP = 0x0002,
74623 + GR_ROLE_DEFAULT = 0x0004,
74624 + GR_ROLE_SPECIAL = 0x0008,
74625 + GR_ROLE_AUTH = 0x0010,
74626 + GR_ROLE_NOPW = 0x0020,
74627 + GR_ROLE_GOD = 0x0040,
74628 + GR_ROLE_LEARN = 0x0080,
74629 + GR_ROLE_TPE = 0x0100,
74630 + GR_ROLE_DOMAIN = 0x0200,
74631 + GR_ROLE_PAM = 0x0400,
74632 + GR_ROLE_PERSIST = 0x0800
74633 +};
74634 +
74635 +/* ACL Subject and Object mode flags */
74636 +enum {
74637 + GR_DELETED = 0x80000000
74638 +};
74639 +
74640 +/* ACL Object-only mode flags */
74641 +enum {
74642 + GR_READ = 0x00000001,
74643 + GR_APPEND = 0x00000002,
74644 + GR_WRITE = 0x00000004,
74645 + GR_EXEC = 0x00000008,
74646 + GR_FIND = 0x00000010,
74647 + GR_INHERIT = 0x00000020,
74648 + GR_SETID = 0x00000040,
74649 + GR_CREATE = 0x00000080,
74650 + GR_DELETE = 0x00000100,
74651 + GR_LINK = 0x00000200,
74652 + GR_AUDIT_READ = 0x00000400,
74653 + GR_AUDIT_APPEND = 0x00000800,
74654 + GR_AUDIT_WRITE = 0x00001000,
74655 + GR_AUDIT_EXEC = 0x00002000,
74656 + GR_AUDIT_FIND = 0x00004000,
74657 + GR_AUDIT_INHERIT= 0x00008000,
74658 + GR_AUDIT_SETID = 0x00010000,
74659 + GR_AUDIT_CREATE = 0x00020000,
74660 + GR_AUDIT_DELETE = 0x00040000,
74661 + GR_AUDIT_LINK = 0x00080000,
74662 + GR_PTRACERD = 0x00100000,
74663 + GR_NOPTRACE = 0x00200000,
74664 + GR_SUPPRESS = 0x00400000,
74665 + GR_NOLEARN = 0x00800000,
74666 + GR_INIT_TRANSFER= 0x01000000
74667 +};
74668 +
74669 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
74670 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
74671 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
74672 +
74673 +/* ACL subject-only mode flags */
74674 +enum {
74675 + GR_KILL = 0x00000001,
74676 + GR_VIEW = 0x00000002,
74677 + GR_PROTECTED = 0x00000004,
74678 + GR_LEARN = 0x00000008,
74679 + GR_OVERRIDE = 0x00000010,
74680 + /* just a placeholder, this mode is only used in userspace */
74681 + GR_DUMMY = 0x00000020,
74682 + GR_PROTSHM = 0x00000040,
74683 + GR_KILLPROC = 0x00000080,
74684 + GR_KILLIPPROC = 0x00000100,
74685 + /* just a placeholder, this mode is only used in userspace */
74686 + GR_NOTROJAN = 0x00000200,
74687 + GR_PROTPROCFD = 0x00000400,
74688 + GR_PROCACCT = 0x00000800,
74689 + GR_RELAXPTRACE = 0x00001000,
74690 + //GR_NESTED = 0x00002000,
74691 + GR_INHERITLEARN = 0x00004000,
74692 + GR_PROCFIND = 0x00008000,
74693 + GR_POVERRIDE = 0x00010000,
74694 + GR_KERNELAUTH = 0x00020000,
74695 + GR_ATSECURE = 0x00040000,
74696 + GR_SHMEXEC = 0x00080000
74697 +};
74698 +
74699 +enum {
74700 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
74701 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
74702 + GR_PAX_ENABLE_MPROTECT = 0x0004,
74703 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
74704 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
74705 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
74706 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
74707 + GR_PAX_DISABLE_MPROTECT = 0x0400,
74708 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
74709 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
74710 +};
74711 +
74712 +enum {
74713 + GR_ID_USER = 0x01,
74714 + GR_ID_GROUP = 0x02,
74715 +};
74716 +
74717 +enum {
74718 + GR_ID_ALLOW = 0x01,
74719 + GR_ID_DENY = 0x02,
74720 +};
74721 +
74722 +#define GR_CRASH_RES 31
74723 +#define GR_UIDTABLE_MAX 500
74724 +
74725 +/* begin resource learning section */
74726 +enum {
74727 + GR_RLIM_CPU_BUMP = 60,
74728 + GR_RLIM_FSIZE_BUMP = 50000,
74729 + GR_RLIM_DATA_BUMP = 10000,
74730 + GR_RLIM_STACK_BUMP = 1000,
74731 + GR_RLIM_CORE_BUMP = 10000,
74732 + GR_RLIM_RSS_BUMP = 500000,
74733 + GR_RLIM_NPROC_BUMP = 1,
74734 + GR_RLIM_NOFILE_BUMP = 5,
74735 + GR_RLIM_MEMLOCK_BUMP = 50000,
74736 + GR_RLIM_AS_BUMP = 500000,
74737 + GR_RLIM_LOCKS_BUMP = 2,
74738 + GR_RLIM_SIGPENDING_BUMP = 5,
74739 + GR_RLIM_MSGQUEUE_BUMP = 10000,
74740 + GR_RLIM_NICE_BUMP = 1,
74741 + GR_RLIM_RTPRIO_BUMP = 1,
74742 + GR_RLIM_RTTIME_BUMP = 1000000
74743 +};
74744 +
74745 +#endif
74746 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
74747 new file mode 100644
74748 index 0000000..d25522e
74749 --- /dev/null
74750 +++ b/include/linux/grinternal.h
74751 @@ -0,0 +1,229 @@
74752 +#ifndef __GRINTERNAL_H
74753 +#define __GRINTERNAL_H
74754 +
74755 +#ifdef CONFIG_GRKERNSEC
74756 +
74757 +#include <linux/fs.h>
74758 +#include <linux/mnt_namespace.h>
74759 +#include <linux/nsproxy.h>
74760 +#include <linux/gracl.h>
74761 +#include <linux/grdefs.h>
74762 +#include <linux/grmsg.h>
74763 +
74764 +void gr_add_learn_entry(const char *fmt, ...)
74765 + __attribute__ ((format (printf, 1, 2)));
74766 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
74767 + const struct vfsmount *mnt);
74768 +__u32 gr_check_create(const struct dentry *new_dentry,
74769 + const struct dentry *parent,
74770 + const struct vfsmount *mnt, const __u32 mode);
74771 +int gr_check_protected_task(const struct task_struct *task);
74772 +__u32 to_gr_audit(const __u32 reqmode);
74773 +int gr_set_acls(const int type);
74774 +int gr_acl_is_enabled(void);
74775 +char gr_roletype_to_char(void);
74776 +
74777 +void gr_handle_alertkill(struct task_struct *task);
74778 +char *gr_to_filename(const struct dentry *dentry,
74779 + const struct vfsmount *mnt);
74780 +char *gr_to_filename1(const struct dentry *dentry,
74781 + const struct vfsmount *mnt);
74782 +char *gr_to_filename2(const struct dentry *dentry,
74783 + const struct vfsmount *mnt);
74784 +char *gr_to_filename3(const struct dentry *dentry,
74785 + const struct vfsmount *mnt);
74786 +
74787 +extern int grsec_enable_ptrace_readexec;
74788 +extern int grsec_enable_harden_ptrace;
74789 +extern int grsec_enable_link;
74790 +extern int grsec_enable_fifo;
74791 +extern int grsec_enable_execve;
74792 +extern int grsec_enable_shm;
74793 +extern int grsec_enable_execlog;
74794 +extern int grsec_enable_signal;
74795 +extern int grsec_enable_audit_ptrace;
74796 +extern int grsec_enable_forkfail;
74797 +extern int grsec_enable_time;
74798 +extern int grsec_enable_rofs;
74799 +extern int grsec_deny_new_usb;
74800 +extern int grsec_enable_chroot_shmat;
74801 +extern int grsec_enable_chroot_mount;
74802 +extern int grsec_enable_chroot_double;
74803 +extern int grsec_enable_chroot_pivot;
74804 +extern int grsec_enable_chroot_chdir;
74805 +extern int grsec_enable_chroot_chmod;
74806 +extern int grsec_enable_chroot_mknod;
74807 +extern int grsec_enable_chroot_fchdir;
74808 +extern int grsec_enable_chroot_nice;
74809 +extern int grsec_enable_chroot_execlog;
74810 +extern int grsec_enable_chroot_caps;
74811 +extern int grsec_enable_chroot_sysctl;
74812 +extern int grsec_enable_chroot_unix;
74813 +extern int grsec_enable_symlinkown;
74814 +extern kgid_t grsec_symlinkown_gid;
74815 +extern int grsec_enable_tpe;
74816 +extern kgid_t grsec_tpe_gid;
74817 +extern int grsec_enable_tpe_all;
74818 +extern int grsec_enable_tpe_invert;
74819 +extern int grsec_enable_socket_all;
74820 +extern kgid_t grsec_socket_all_gid;
74821 +extern int grsec_enable_socket_client;
74822 +extern kgid_t grsec_socket_client_gid;
74823 +extern int grsec_enable_socket_server;
74824 +extern kgid_t grsec_socket_server_gid;
74825 +extern kgid_t grsec_audit_gid;
74826 +extern int grsec_enable_group;
74827 +extern int grsec_enable_log_rwxmaps;
74828 +extern int grsec_enable_mount;
74829 +extern int grsec_enable_chdir;
74830 +extern int grsec_resource_logging;
74831 +extern int grsec_enable_blackhole;
74832 +extern int grsec_lastack_retries;
74833 +extern int grsec_enable_brute;
74834 +extern int grsec_enable_harden_ipc;
74835 +extern int grsec_lock;
74836 +
74837 +extern spinlock_t grsec_alert_lock;
74838 +extern unsigned long grsec_alert_wtime;
74839 +extern unsigned long grsec_alert_fyet;
74840 +
74841 +extern spinlock_t grsec_audit_lock;
74842 +
74843 +extern rwlock_t grsec_exec_file_lock;
74844 +
74845 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74846 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74847 + (tsk)->exec_file->f_path.mnt) : "/")
74848 +
74849 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74850 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74851 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74852 +
74853 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74854 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74855 + (tsk)->exec_file->f_path.mnt) : "/")
74856 +
74857 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74858 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74859 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74860 +
74861 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74862 +
74863 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74864 +
74865 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74866 +{
74867 + if (file1 && file2) {
74868 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74869 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74870 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74871 + return true;
74872 + }
74873 +
74874 + return false;
74875 +}
74876 +
74877 +#define GR_CHROOT_CAPS {{ \
74878 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74879 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74880 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74881 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74882 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74883 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74884 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74885 +
74886 +#define security_learn(normal_msg,args...) \
74887 +({ \
74888 + read_lock(&grsec_exec_file_lock); \
74889 + gr_add_learn_entry(normal_msg "\n", ## args); \
74890 + read_unlock(&grsec_exec_file_lock); \
74891 +})
74892 +
74893 +enum {
74894 + GR_DO_AUDIT,
74895 + GR_DONT_AUDIT,
74896 + /* used for non-audit messages that we shouldn't kill the task on */
74897 + GR_DONT_AUDIT_GOOD
74898 +};
74899 +
74900 +enum {
74901 + GR_TTYSNIFF,
74902 + GR_RBAC,
74903 + GR_RBAC_STR,
74904 + GR_STR_RBAC,
74905 + GR_RBAC_MODE2,
74906 + GR_RBAC_MODE3,
74907 + GR_FILENAME,
74908 + GR_SYSCTL_HIDDEN,
74909 + GR_NOARGS,
74910 + GR_ONE_INT,
74911 + GR_ONE_INT_TWO_STR,
74912 + GR_ONE_STR,
74913 + GR_STR_INT,
74914 + GR_TWO_STR_INT,
74915 + GR_TWO_INT,
74916 + GR_TWO_U64,
74917 + GR_THREE_INT,
74918 + GR_FIVE_INT_TWO_STR,
74919 + GR_TWO_STR,
74920 + GR_THREE_STR,
74921 + GR_FOUR_STR,
74922 + GR_STR_FILENAME,
74923 + GR_FILENAME_STR,
74924 + GR_FILENAME_TWO_INT,
74925 + GR_FILENAME_TWO_INT_STR,
74926 + GR_TEXTREL,
74927 + GR_PTRACE,
74928 + GR_RESOURCE,
74929 + GR_CAP,
74930 + GR_SIG,
74931 + GR_SIG2,
74932 + GR_CRASH1,
74933 + GR_CRASH2,
74934 + GR_PSACCT,
74935 + GR_RWXMAP,
74936 + GR_RWXMAPVMA
74937 +};
74938 +
74939 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74940 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74941 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74942 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74943 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74944 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74945 +#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)
74946 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74947 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74948 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74949 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74950 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74951 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74952 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74953 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74954 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74955 +#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)
74956 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74957 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74958 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74959 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74960 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74961 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74962 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74963 +#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)
74964 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74965 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74966 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74967 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74968 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74969 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74970 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74971 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74972 +#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)
74973 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74974 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74975 +
74976 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74977 +
74978 +#endif
74979 +
74980 +#endif
74981 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74982 new file mode 100644
74983 index 0000000..378a81a
74984 --- /dev/null
74985 +++ b/include/linux/grmsg.h
74986 @@ -0,0 +1,114 @@
74987 +#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"
74988 +#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"
74989 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74990 +#define GR_STOPMOD_MSG "denied modification of module state by "
74991 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74992 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74993 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74994 +#define GR_IOPL_MSG "denied use of iopl() by "
74995 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74996 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74997 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74998 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74999 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75000 +#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"
75001 +#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"
75002 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75003 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75004 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75005 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75006 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75007 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75008 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75009 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75010 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75011 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75012 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75013 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75014 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75015 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75016 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75017 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75018 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75019 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75020 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75021 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75022 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75023 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75024 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75025 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75026 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75027 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75028 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75029 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75030 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75031 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75032 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75033 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75034 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75035 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75036 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75037 +#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"
75038 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75039 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75040 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75041 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75042 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75043 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75044 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75045 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75046 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75047 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75048 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75049 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75050 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75051 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75052 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75053 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75054 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75055 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75056 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75057 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75058 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75059 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75060 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75061 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75062 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75063 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75064 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75065 +#define GR_TIME_MSG "time set by "
75066 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75067 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75068 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75069 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75070 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75071 +#define GR_BIND_MSG "denied bind() by "
75072 +#define GR_CONNECT_MSG "denied connect() by "
75073 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75074 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75075 +#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"
75076 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75077 +#define GR_CAP_ACL_MSG "use of %s denied for "
75078 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75079 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75080 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75081 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75082 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75083 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75084 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75085 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75086 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75087 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75088 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75089 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75090 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75091 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75092 +#define GR_VM86_MSG "denied use of vm86 by "
75093 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75094 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75095 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75096 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75097 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75098 +#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 "
75099 +#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 "
75100 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
75101 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75102 new file mode 100644
75103 index 0000000..b2edfb1
75104 --- /dev/null
75105 +++ b/include/linux/grsecurity.h
75106 @@ -0,0 +1,243 @@
75107 +#ifndef GR_SECURITY_H
75108 +#define GR_SECURITY_H
75109 +#include <linux/fs.h>
75110 +#include <linux/fs_struct.h>
75111 +#include <linux/binfmts.h>
75112 +#include <linux/gracl.h>
75113 +
75114 +/* notify of brain-dead configs */
75115 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75116 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75117 +#endif
75118 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75119 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75120 +#endif
75121 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75122 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75123 +#endif
75124 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75125 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75126 +#endif
75127 +
75128 +int gr_handle_new_usb(void);
75129 +
75130 +void gr_handle_brute_attach(unsigned long mm_flags);
75131 +void gr_handle_brute_check(void);
75132 +void gr_handle_kernel_exploit(void);
75133 +
75134 +char gr_roletype_to_char(void);
75135 +
75136 +int gr_acl_enable_at_secure(void);
75137 +
75138 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75139 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75140 +
75141 +void gr_del_task_from_ip_table(struct task_struct *p);
75142 +
75143 +int gr_pid_is_chrooted(struct task_struct *p);
75144 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75145 +int gr_handle_chroot_nice(void);
75146 +int gr_handle_chroot_sysctl(const int op);
75147 +int gr_handle_chroot_setpriority(struct task_struct *p,
75148 + const int niceval);
75149 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75150 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75151 + const struct vfsmount *mnt);
75152 +void gr_handle_chroot_chdir(const struct path *path);
75153 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75154 + const struct vfsmount *mnt, const int mode);
75155 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75156 + const struct vfsmount *mnt, const int mode);
75157 +int gr_handle_chroot_mount(const struct dentry *dentry,
75158 + const struct vfsmount *mnt,
75159 + const char *dev_name);
75160 +int gr_handle_chroot_pivot(void);
75161 +int gr_handle_chroot_unix(const pid_t pid);
75162 +
75163 +int gr_handle_rawio(const struct inode *inode);
75164 +
75165 +void gr_handle_ioperm(void);
75166 +void gr_handle_iopl(void);
75167 +
75168 +umode_t gr_acl_umask(void);
75169 +
75170 +int gr_tpe_allow(const struct file *file);
75171 +
75172 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75173 +void gr_clear_chroot_entries(struct task_struct *task);
75174 +
75175 +void gr_log_forkfail(const int retval);
75176 +void gr_log_timechange(void);
75177 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75178 +void gr_log_chdir(const struct dentry *dentry,
75179 + const struct vfsmount *mnt);
75180 +void gr_log_chroot_exec(const struct dentry *dentry,
75181 + const struct vfsmount *mnt);
75182 +void gr_log_remount(const char *devname, const int retval);
75183 +void gr_log_unmount(const char *devname, const int retval);
75184 +void gr_log_mount(const char *from, const char *to, const int retval);
75185 +void gr_log_textrel(struct vm_area_struct *vma);
75186 +void gr_log_ptgnustack(struct file *file);
75187 +void gr_log_rwxmmap(struct file *file);
75188 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75189 +
75190 +int gr_handle_follow_link(const struct inode *parent,
75191 + const struct inode *inode,
75192 + const struct dentry *dentry,
75193 + const struct vfsmount *mnt);
75194 +int gr_handle_fifo(const struct dentry *dentry,
75195 + const struct vfsmount *mnt,
75196 + const struct dentry *dir, const int flag,
75197 + const int acc_mode);
75198 +int gr_handle_hardlink(const struct dentry *dentry,
75199 + const struct vfsmount *mnt,
75200 + struct inode *inode,
75201 + const int mode, const struct filename *to);
75202 +
75203 +int gr_is_capable(const int cap);
75204 +int gr_is_capable_nolog(const int cap);
75205 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75206 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75207 +
75208 +void gr_copy_label(struct task_struct *tsk);
75209 +void gr_handle_crash(struct task_struct *task, const int sig);
75210 +int gr_handle_signal(const struct task_struct *p, const int sig);
75211 +int gr_check_crash_uid(const kuid_t uid);
75212 +int gr_check_protected_task(const struct task_struct *task);
75213 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75214 +int gr_acl_handle_mmap(const struct file *file,
75215 + const unsigned long prot);
75216 +int gr_acl_handle_mprotect(const struct file *file,
75217 + const unsigned long prot);
75218 +int gr_check_hidden_task(const struct task_struct *tsk);
75219 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75220 + const struct vfsmount *mnt);
75221 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75222 + const struct vfsmount *mnt);
75223 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75224 + const struct vfsmount *mnt, const int fmode);
75225 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75226 + const struct vfsmount *mnt, umode_t *mode);
75227 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75228 + const struct vfsmount *mnt);
75229 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75230 + const struct vfsmount *mnt);
75231 +int gr_handle_ptrace(struct task_struct *task, const long request);
75232 +int gr_handle_proc_ptrace(struct task_struct *task);
75233 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75234 + const struct vfsmount *mnt);
75235 +int gr_check_crash_exec(const struct file *filp);
75236 +int gr_acl_is_enabled(void);
75237 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75238 + const kgid_t gid);
75239 +int gr_set_proc_label(const struct dentry *dentry,
75240 + const struct vfsmount *mnt,
75241 + const int unsafe_flags);
75242 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
75243 + const struct vfsmount *mnt);
75244 +__u32 gr_acl_handle_open(const struct dentry *dentry,
75245 + const struct vfsmount *mnt, int acc_mode);
75246 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
75247 + const struct dentry *p_dentry,
75248 + const struct vfsmount *p_mnt,
75249 + int open_flags, int acc_mode, const int imode);
75250 +void gr_handle_create(const struct dentry *dentry,
75251 + const struct vfsmount *mnt);
75252 +void gr_handle_proc_create(const struct dentry *dentry,
75253 + const struct inode *inode);
75254 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
75255 + const struct dentry *parent_dentry,
75256 + const struct vfsmount *parent_mnt,
75257 + const int mode);
75258 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
75259 + const struct dentry *parent_dentry,
75260 + const struct vfsmount *parent_mnt);
75261 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
75262 + const struct vfsmount *mnt);
75263 +void gr_handle_delete(const ino_t ino, const dev_t dev);
75264 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
75265 + const struct vfsmount *mnt);
75266 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
75267 + const struct dentry *parent_dentry,
75268 + const struct vfsmount *parent_mnt,
75269 + const struct filename *from);
75270 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
75271 + const struct dentry *parent_dentry,
75272 + const struct vfsmount *parent_mnt,
75273 + const struct dentry *old_dentry,
75274 + const struct vfsmount *old_mnt, const struct filename *to);
75275 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
75276 +int gr_acl_handle_rename(struct dentry *new_dentry,
75277 + struct dentry *parent_dentry,
75278 + const struct vfsmount *parent_mnt,
75279 + struct dentry *old_dentry,
75280 + struct inode *old_parent_inode,
75281 + struct vfsmount *old_mnt, const struct filename *newname);
75282 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
75283 + struct dentry *old_dentry,
75284 + struct dentry *new_dentry,
75285 + struct vfsmount *mnt, const __u8 replace);
75286 +__u32 gr_check_link(const struct dentry *new_dentry,
75287 + const struct dentry *parent_dentry,
75288 + const struct vfsmount *parent_mnt,
75289 + const struct dentry *old_dentry,
75290 + const struct vfsmount *old_mnt);
75291 +int gr_acl_handle_filldir(const struct file *file, const char *name,
75292 + const unsigned int namelen, const ino_t ino);
75293 +
75294 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
75295 + const struct vfsmount *mnt);
75296 +void gr_acl_handle_exit(void);
75297 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
75298 +int gr_acl_handle_procpidmem(const struct task_struct *task);
75299 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
75300 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
75301 +void gr_audit_ptrace(struct task_struct *task);
75302 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
75303 +void gr_put_exec_file(struct task_struct *task);
75304 +
75305 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
75306 +
75307 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
75308 +extern void gr_learn_resource(const struct task_struct *task, const int res,
75309 + const unsigned long wanted, const int gt);
75310 +#else
75311 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
75312 + const unsigned long wanted, const int gt)
75313 +{
75314 +}
75315 +#endif
75316 +
75317 +#ifdef CONFIG_GRKERNSEC_RESLOG
75318 +extern void gr_log_resource(const struct task_struct *task, const int res,
75319 + const unsigned long wanted, const int gt);
75320 +#else
75321 +static inline void gr_log_resource(const struct task_struct *task, const int res,
75322 + const unsigned long wanted, const int gt)
75323 +{
75324 +}
75325 +#endif
75326 +
75327 +#ifdef CONFIG_GRKERNSEC
75328 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
75329 +void gr_handle_vm86(void);
75330 +void gr_handle_mem_readwrite(u64 from, u64 to);
75331 +
75332 +void gr_log_badprocpid(const char *entry);
75333 +
75334 +extern int grsec_enable_dmesg;
75335 +extern int grsec_disable_privio;
75336 +
75337 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75338 +extern kgid_t grsec_proc_gid;
75339 +#endif
75340 +
75341 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
75342 +extern int grsec_enable_chroot_findtask;
75343 +#endif
75344 +#ifdef CONFIG_GRKERNSEC_SETXID
75345 +extern int grsec_enable_setxid;
75346 +#endif
75347 +#endif
75348 +
75349 +#endif
75350 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
75351 new file mode 100644
75352 index 0000000..e7ffaaf
75353 --- /dev/null
75354 +++ b/include/linux/grsock.h
75355 @@ -0,0 +1,19 @@
75356 +#ifndef __GRSOCK_H
75357 +#define __GRSOCK_H
75358 +
75359 +extern void gr_attach_curr_ip(const struct sock *sk);
75360 +extern int gr_handle_sock_all(const int family, const int type,
75361 + const int protocol);
75362 +extern int gr_handle_sock_server(const struct sockaddr *sck);
75363 +extern int gr_handle_sock_server_other(const struct sock *sck);
75364 +extern int gr_handle_sock_client(const struct sockaddr *sck);
75365 +extern int gr_search_connect(struct socket * sock,
75366 + struct sockaddr_in * addr);
75367 +extern int gr_search_bind(struct socket * sock,
75368 + struct sockaddr_in * addr);
75369 +extern int gr_search_listen(struct socket * sock);
75370 +extern int gr_search_accept(struct socket * sock);
75371 +extern int gr_search_socket(const int domain, const int type,
75372 + const int protocol);
75373 +
75374 +#endif
75375 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
75376 index 7fb31da..08b5114 100644
75377 --- a/include/linux/highmem.h
75378 +++ b/include/linux/highmem.h
75379 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
75380 kunmap_atomic(kaddr);
75381 }
75382
75383 +static inline void sanitize_highpage(struct page *page)
75384 +{
75385 + void *kaddr;
75386 + unsigned long flags;
75387 +
75388 + local_irq_save(flags);
75389 + kaddr = kmap_atomic(page);
75390 + clear_page(kaddr);
75391 + kunmap_atomic(kaddr);
75392 + local_irq_restore(flags);
75393 +}
75394 +
75395 static inline void zero_user_segments(struct page *page,
75396 unsigned start1, unsigned end1,
75397 unsigned start2, unsigned end2)
75398 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
75399 index 1c7b89a..7dda400 100644
75400 --- a/include/linux/hwmon-sysfs.h
75401 +++ b/include/linux/hwmon-sysfs.h
75402 @@ -25,7 +25,8 @@
75403 struct sensor_device_attribute{
75404 struct device_attribute dev_attr;
75405 int index;
75406 -};
75407 +} __do_const;
75408 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
75409 #define to_sensor_dev_attr(_dev_attr) \
75410 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
75411
75412 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
75413 struct device_attribute dev_attr;
75414 u8 index;
75415 u8 nr;
75416 -};
75417 +} __do_const;
75418 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
75419 #define to_sensor_dev_attr_2(_dev_attr) \
75420 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
75421
75422 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
75423 index 2ab11dc..663a3f2 100644
75424 --- a/include/linux/i2c.h
75425 +++ b/include/linux/i2c.h
75426 @@ -366,6 +366,7 @@ struct i2c_algorithm {
75427 /* To determine what the adapter supports */
75428 u32 (*functionality) (struct i2c_adapter *);
75429 };
75430 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
75431
75432 /**
75433 * struct i2c_bus_recovery_info - I2C bus recovery information
75434 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
75435 index d23c3c2..eb63c81 100644
75436 --- a/include/linux/i2o.h
75437 +++ b/include/linux/i2o.h
75438 @@ -565,7 +565,7 @@ struct i2o_controller {
75439 struct i2o_device *exec; /* Executive */
75440 #if BITS_PER_LONG == 64
75441 spinlock_t context_list_lock; /* lock for context_list */
75442 - atomic_t context_list_counter; /* needed for unique contexts */
75443 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
75444 struct list_head context_list; /* list of context id's
75445 and pointers */
75446 #endif
75447 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
75448 index aff7ad8..3942bbd 100644
75449 --- a/include/linux/if_pppox.h
75450 +++ b/include/linux/if_pppox.h
75451 @@ -76,7 +76,7 @@ struct pppox_proto {
75452 int (*ioctl)(struct socket *sock, unsigned int cmd,
75453 unsigned long arg);
75454 struct module *owner;
75455 -};
75456 +} __do_const;
75457
75458 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
75459 extern void unregister_pppox_proto(int proto_num);
75460 diff --git a/include/linux/init.h b/include/linux/init.h
75461 index f1c27a71..7d6010e 100644
75462 --- a/include/linux/init.h
75463 +++ b/include/linux/init.h
75464 @@ -39,9 +39,17 @@
75465 * Also note, that this data cannot be "const".
75466 */
75467
75468 +#define add_init_latent_entropy __latent_entropy
75469 +
75470 +#ifdef CONFIG_MEMORY_HOTPLUG
75471 +#define add_meminit_latent_entropy
75472 +#else
75473 +#define add_meminit_latent_entropy __latent_entropy
75474 +#endif
75475 +
75476 /* These are for everybody (although not all archs will actually
75477 discard it in modules) */
75478 -#define __init __section(.init.text) __cold notrace
75479 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
75480 #define __initdata __section(.init.data)
75481 #define __initconst __constsection(.init.rodata)
75482 #define __exitdata __section(.exit.data)
75483 @@ -102,7 +110,7 @@
75484 #define __cpuexitconst
75485
75486 /* Used for MEMORY_HOTPLUG */
75487 -#define __meminit __section(.meminit.text) __cold notrace
75488 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
75489 #define __meminitdata __section(.meminit.data)
75490 #define __meminitconst __constsection(.meminit.rodata)
75491 #define __memexit __section(.memexit.text) __exitused __cold notrace
75492 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
75493 index 5cd0f09..c9f67cc 100644
75494 --- a/include/linux/init_task.h
75495 +++ b/include/linux/init_task.h
75496 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
75497
75498 #define INIT_TASK_COMM "swapper"
75499
75500 +#ifdef CONFIG_X86
75501 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
75502 +#else
75503 +#define INIT_TASK_THREAD_INFO
75504 +#endif
75505 +
75506 /*
75507 * INIT_TASK is used to set up the first task table, touch at
75508 * your own risk!. Base=0, limit=0x1fffff (=2MB)
75509 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
75510 RCU_POINTER_INITIALIZER(cred, &init_cred), \
75511 .comm = INIT_TASK_COMM, \
75512 .thread = INIT_THREAD, \
75513 + INIT_TASK_THREAD_INFO \
75514 .fs = &init_fs, \
75515 .files = &init_files, \
75516 .signal = &init_signals, \
75517 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
75518 index 5e865b5..71bd258 100644
75519 --- a/include/linux/interrupt.h
75520 +++ b/include/linux/interrupt.h
75521 @@ -361,7 +361,7 @@ enum
75522 /* map softirq index to softirq name. update 'softirq_to_name' in
75523 * kernel/softirq.c when adding a new softirq.
75524 */
75525 -extern char *softirq_to_name[NR_SOFTIRQS];
75526 +extern const char * const softirq_to_name[NR_SOFTIRQS];
75527
75528 /* softirq mask and active fields moved to irq_cpustat_t in
75529 * asm/hardirq.h to get better cache usage. KAO
75530 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
75531
75532 struct softirq_action
75533 {
75534 - void (*action)(struct softirq_action *);
75535 -};
75536 + void (*action)(void);
75537 +} __no_const;
75538
75539 asmlinkage void do_softirq(void);
75540 asmlinkage void __do_softirq(void);
75541 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
75542 +extern void open_softirq(int nr, void (*action)(void));
75543 extern void softirq_init(void);
75544 extern void __raise_softirq_irqoff(unsigned int nr);
75545
75546 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
75547 index 7ea319e..f9e971d 100644
75548 --- a/include/linux/iommu.h
75549 +++ b/include/linux/iommu.h
75550 @@ -129,7 +129,7 @@ struct iommu_ops {
75551 u32 (*domain_get_windows)(struct iommu_domain *domain);
75552
75553 unsigned long pgsize_bitmap;
75554 -};
75555 +} __do_const;
75556
75557 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
75558 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
75559 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
75560 index 89b7c24..382af74 100644
75561 --- a/include/linux/ioport.h
75562 +++ b/include/linux/ioport.h
75563 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
75564 int adjust_resource(struct resource *res, resource_size_t start,
75565 resource_size_t size);
75566 resource_size_t resource_alignment(struct resource *res);
75567 -static inline resource_size_t resource_size(const struct resource *res)
75568 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
75569 {
75570 return res->end - res->start + 1;
75571 }
75572 diff --git a/include/linux/irq.h b/include/linux/irq.h
75573 index 56bb0dc..8ae94d62 100644
75574 --- a/include/linux/irq.h
75575 +++ b/include/linux/irq.h
75576 @@ -333,7 +333,8 @@ struct irq_chip {
75577 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
75578
75579 unsigned long flags;
75580 -};
75581 +} __do_const;
75582 +typedef struct irq_chip __no_const irq_chip_no_const;
75583
75584 /*
75585 * irq_chip specific flags
75586 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
75587 index 0e5d9ec..46acb3a 100644
75588 --- a/include/linux/irqchip/arm-gic.h
75589 +++ b/include/linux/irqchip/arm-gic.h
75590 @@ -59,9 +59,11 @@
75591
75592 #ifndef __ASSEMBLY__
75593
75594 +#include <linux/irq.h>
75595 +
75596 struct device_node;
75597
75598 -extern struct irq_chip gic_arch_extn;
75599 +extern irq_chip_no_const gic_arch_extn;
75600
75601 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
75602 u32 offset, struct device_node *);
75603 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
75604 index d235e88..8ccbe74 100644
75605 --- a/include/linux/jiffies.h
75606 +++ b/include/linux/jiffies.h
75607 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
75608 /*
75609 * Convert various time units to each other:
75610 */
75611 -extern unsigned int jiffies_to_msecs(const unsigned long j);
75612 -extern unsigned int jiffies_to_usecs(const unsigned long j);
75613 -extern unsigned long msecs_to_jiffies(const unsigned int m);
75614 -extern unsigned long usecs_to_jiffies(const unsigned int u);
75615 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
75616 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
75617 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
75618 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
75619 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
75620 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
75621 extern void jiffies_to_timespec(const unsigned long jiffies,
75622 struct timespec *value);
75623 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
75624 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
75625 extern void jiffies_to_timeval(const unsigned long jiffies,
75626 struct timeval *value);
75627
75628 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
75629 index 6883e19..e854fcb 100644
75630 --- a/include/linux/kallsyms.h
75631 +++ b/include/linux/kallsyms.h
75632 @@ -15,7 +15,8 @@
75633
75634 struct module;
75635
75636 -#ifdef CONFIG_KALLSYMS
75637 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
75638 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75639 /* Lookup the address for a symbol. Returns 0 if not found. */
75640 unsigned long kallsyms_lookup_name(const char *name);
75641
75642 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
75643 /* Stupid that this does nothing, but I didn't create this mess. */
75644 #define __print_symbol(fmt, addr)
75645 #endif /*CONFIG_KALLSYMS*/
75646 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
75647 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
75648 +extern unsigned long kallsyms_lookup_name(const char *name);
75649 +extern void __print_symbol(const char *fmt, unsigned long address);
75650 +extern int sprint_backtrace(char *buffer, unsigned long address);
75651 +extern int sprint_symbol(char *buffer, unsigned long address);
75652 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
75653 +const char *kallsyms_lookup(unsigned long addr,
75654 + unsigned long *symbolsize,
75655 + unsigned long *offset,
75656 + char **modname, char *namebuf);
75657 +extern int kallsyms_lookup_size_offset(unsigned long addr,
75658 + unsigned long *symbolsize,
75659 + unsigned long *offset);
75660 +#endif
75661
75662 /* This macro allows us to keep printk typechecking */
75663 static __printf(1, 2)
75664 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
75665 index 518a53a..5e28358 100644
75666 --- a/include/linux/key-type.h
75667 +++ b/include/linux/key-type.h
75668 @@ -125,7 +125,7 @@ struct key_type {
75669 /* internal fields */
75670 struct list_head link; /* link in types list */
75671 struct lock_class_key lock_class; /* key->sem lock class */
75672 -};
75673 +} __do_const;
75674
75675 extern struct key_type key_type_keyring;
75676
75677 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
75678 index c6e091b..a940adf 100644
75679 --- a/include/linux/kgdb.h
75680 +++ b/include/linux/kgdb.h
75681 @@ -52,7 +52,7 @@ extern int kgdb_connected;
75682 extern int kgdb_io_module_registered;
75683
75684 extern atomic_t kgdb_setting_breakpoint;
75685 -extern atomic_t kgdb_cpu_doing_single_step;
75686 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
75687
75688 extern struct task_struct *kgdb_usethread;
75689 extern struct task_struct *kgdb_contthread;
75690 @@ -254,7 +254,7 @@ struct kgdb_arch {
75691 void (*correct_hw_break)(void);
75692
75693 void (*enable_nmi)(bool on);
75694 -};
75695 +} __do_const;
75696
75697 /**
75698 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
75699 @@ -279,7 +279,7 @@ struct kgdb_io {
75700 void (*pre_exception) (void);
75701 void (*post_exception) (void);
75702 int is_console;
75703 -};
75704 +} __do_const;
75705
75706 extern struct kgdb_arch arch_kgdb_ops;
75707
75708 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
75709 index 0555cc6..40116ce 100644
75710 --- a/include/linux/kmod.h
75711 +++ b/include/linux/kmod.h
75712 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
75713 * usually useless though. */
75714 extern __printf(2, 3)
75715 int __request_module(bool wait, const char *name, ...);
75716 +extern __printf(3, 4)
75717 +int ___request_module(bool wait, char *param_name, const char *name, ...);
75718 #define request_module(mod...) __request_module(true, mod)
75719 #define request_module_nowait(mod...) __request_module(false, mod)
75720 #define try_then_request_module(x, mod...) \
75721 @@ -57,6 +59,9 @@ struct subprocess_info {
75722 struct work_struct work;
75723 struct completion *complete;
75724 char *path;
75725 +#ifdef CONFIG_GRKERNSEC
75726 + char *origpath;
75727 +#endif
75728 char **argv;
75729 char **envp;
75730 int wait;
75731 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
75732 index de6dcbcc..4735f88 100644
75733 --- a/include/linux/kobject.h
75734 +++ b/include/linux/kobject.h
75735 @@ -115,7 +115,7 @@ struct kobj_type {
75736 struct attribute **default_attrs;
75737 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
75738 const void *(*namespace)(struct kobject *kobj);
75739 -};
75740 +} __do_const;
75741
75742 struct kobj_uevent_env {
75743 char *envp[UEVENT_NUM_ENVP];
75744 @@ -138,6 +138,7 @@ struct kobj_attribute {
75745 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
75746 const char *buf, size_t count);
75747 };
75748 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
75749
75750 extern const struct sysfs_ops kobj_sysfs_ops;
75751
75752 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
75753 index df32d25..fb52e27 100644
75754 --- a/include/linux/kobject_ns.h
75755 +++ b/include/linux/kobject_ns.h
75756 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
75757 const void *(*netlink_ns)(struct sock *sk);
75758 const void *(*initial_ns)(void);
75759 void (*drop_ns)(void *);
75760 -};
75761 +} __do_const;
75762
75763 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
75764 int kobj_ns_type_registered(enum kobj_ns_type type);
75765 diff --git a/include/linux/kref.h b/include/linux/kref.h
75766 index 484604d..0f6c5b6 100644
75767 --- a/include/linux/kref.h
75768 +++ b/include/linux/kref.h
75769 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
75770 static inline int kref_sub(struct kref *kref, unsigned int count,
75771 void (*release)(struct kref *kref))
75772 {
75773 - WARN_ON(release == NULL);
75774 + BUG_ON(release == NULL);
75775
75776 if (atomic_sub_and_test((int) count, &kref->refcount)) {
75777 release(kref);
75778 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
75779 index 0fbbc7a..db081e3 100644
75780 --- a/include/linux/kvm_host.h
75781 +++ b/include/linux/kvm_host.h
75782 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
75783 {
75784 }
75785 #endif
75786 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75787 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75788 struct module *module);
75789 void kvm_exit(void);
75790
75791 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
75792 struct kvm_guest_debug *dbg);
75793 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
75794
75795 -int kvm_arch_init(void *opaque);
75796 +int kvm_arch_init(const void *opaque);
75797 void kvm_arch_exit(void);
75798
75799 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
75800 diff --git a/include/linux/libata.h b/include/linux/libata.h
75801 index 0e23c26..6ad8c33 100644
75802 --- a/include/linux/libata.h
75803 +++ b/include/linux/libata.h
75804 @@ -972,7 +972,7 @@ struct ata_port_operations {
75805 * fields must be pointers.
75806 */
75807 const struct ata_port_operations *inherits;
75808 -};
75809 +} __do_const;
75810
75811 struct ata_port_info {
75812 unsigned long flags;
75813 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
75814 index d3e8ad2..a949f68 100644
75815 --- a/include/linux/linkage.h
75816 +++ b/include/linux/linkage.h
75817 @@ -31,6 +31,7 @@
75818 #endif
75819
75820 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
75821 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
75822 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
75823
75824 /*
75825 diff --git a/include/linux/list.h b/include/linux/list.h
75826 index f4d8a2f..38e6e46 100644
75827 --- a/include/linux/list.h
75828 +++ b/include/linux/list.h
75829 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
75830 extern void list_del(struct list_head *entry);
75831 #endif
75832
75833 +extern void __pax_list_add(struct list_head *new,
75834 + struct list_head *prev,
75835 + struct list_head *next);
75836 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
75837 +{
75838 + __pax_list_add(new, head, head->next);
75839 +}
75840 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
75841 +{
75842 + __pax_list_add(new, head->prev, head);
75843 +}
75844 +extern void pax_list_del(struct list_head *entry);
75845 +
75846 /**
75847 * list_replace - replace old entry by new one
75848 * @old : the element to be replaced
75849 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
75850 INIT_LIST_HEAD(entry);
75851 }
75852
75853 +extern void pax_list_del_init(struct list_head *entry);
75854 +
75855 /**
75856 * list_move - delete from one list and add as another's head
75857 * @list: the entry to move
75858 diff --git a/include/linux/math64.h b/include/linux/math64.h
75859 index 69ed5f5..243ed51 100644
75860 --- a/include/linux/math64.h
75861 +++ b/include/linux/math64.h
75862 @@ -15,7 +15,7 @@
75863 * This is commonly provided by 32bit archs to provide an optimized 64bit
75864 * divide.
75865 */
75866 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75867 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75868 {
75869 *remainder = dividend % divisor;
75870 return dividend / divisor;
75871 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
75872 /**
75873 * div64_u64 - unsigned 64bit divide with 64bit divisor
75874 */
75875 -static inline u64 div64_u64(u64 dividend, u64 divisor)
75876 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
75877 {
75878 return dividend / divisor;
75879 }
75880 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75881 #define div64_ul(x, y) div_u64((x), (y))
75882
75883 #ifndef div_u64_rem
75884 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75885 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75886 {
75887 *remainder = do_div(dividend, divisor);
75888 return dividend;
75889 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
75890 #endif
75891
75892 #ifndef div64_u64
75893 -extern u64 div64_u64(u64 dividend, u64 divisor);
75894 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
75895 #endif
75896
75897 #ifndef div64_s64
75898 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75899 * divide.
75900 */
75901 #ifndef div_u64
75902 -static inline u64 div_u64(u64 dividend, u32 divisor)
75903 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75904 {
75905 u32 remainder;
75906 return div_u64_rem(dividend, divisor, &remainder);
75907 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
75908 index da6716b..2e31db3 100644
75909 --- a/include/linux/mempolicy.h
75910 +++ b/include/linux/mempolicy.h
75911 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
75912 }
75913
75914 #define vma_policy(vma) ((vma)->vm_policy)
75915 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
75916 +{
75917 + vma->vm_policy = pol;
75918 +}
75919
75920 static inline void mpol_get(struct mempolicy *pol)
75921 {
75922 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
75923 }
75924
75925 #define vma_policy(vma) NULL
75926 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
75927 +{
75928 +}
75929
75930 static inline int
75931 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
75932 diff --git a/include/linux/mm.h b/include/linux/mm.h
75933 index 8b6e55e..c4edf39 100644
75934 --- a/include/linux/mm.h
75935 +++ b/include/linux/mm.h
75936 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75937 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75938 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75939 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75940 +
75941 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75942 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75943 +#endif
75944 +
75945 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75946
75947 #ifdef CONFIG_MEM_SOFT_DIRTY
75948 @@ -215,8 +220,8 @@ struct vm_operations_struct {
75949 /* called by access_process_vm when get_user_pages() fails, typically
75950 * for use by special VMAs that can switch between memory and hardware
75951 */
75952 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75953 - void *buf, int len, int write);
75954 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75955 + void *buf, size_t len, int write);
75956 #ifdef CONFIG_NUMA
75957 /*
75958 * set_policy() op must add a reference to any non-NULL @new mempolicy
75959 @@ -246,6 +251,7 @@ struct vm_operations_struct {
75960 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75961 unsigned long size, pgoff_t pgoff);
75962 };
75963 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75964
75965 struct mmu_gather;
75966 struct inode;
75967 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75968 unsigned long *pfn);
75969 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75970 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75971 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75972 - void *buf, int len, int write);
75973 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75974 + void *buf, size_t len, int write);
75975
75976 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75977 loff_t const holebegin, loff_t const holelen)
75978 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75979 }
75980 #endif
75981
75982 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75983 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75984 - void *buf, int len, int write);
75985 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75986 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75987 + void *buf, size_t len, int write);
75988
75989 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75990 unsigned long start, unsigned long nr_pages,
75991 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
75992 int set_page_dirty_lock(struct page *page);
75993 int clear_page_dirty_for_io(struct page *page);
75994
75995 -/* Is the vma a continuation of the stack vma above it? */
75996 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75997 -{
75998 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75999 -}
76000 -
76001 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76002 - unsigned long addr)
76003 -{
76004 - return (vma->vm_flags & VM_GROWSDOWN) &&
76005 - (vma->vm_start == addr) &&
76006 - !vma_growsdown(vma->vm_prev, addr);
76007 -}
76008 -
76009 -/* Is the vma a continuation of the stack vma below it? */
76010 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76011 -{
76012 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76013 -}
76014 -
76015 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76016 - unsigned long addr)
76017 -{
76018 - return (vma->vm_flags & VM_GROWSUP) &&
76019 - (vma->vm_end == addr) &&
76020 - !vma_growsup(vma->vm_next, addr);
76021 -}
76022 -
76023 extern pid_t
76024 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76025
76026 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76027 }
76028 #endif
76029
76030 +#ifdef CONFIG_MMU
76031 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76032 +#else
76033 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76034 +{
76035 + return __pgprot(0);
76036 +}
76037 +#endif
76038 +
76039 int vma_wants_writenotify(struct vm_area_struct *vma);
76040
76041 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76042 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76043 {
76044 return 0;
76045 }
76046 +
76047 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76048 + unsigned long address)
76049 +{
76050 + return 0;
76051 +}
76052 #else
76053 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76054 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76055 #endif
76056
76057 #ifdef __PAGETABLE_PMD_FOLDED
76058 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76059 {
76060 return 0;
76061 }
76062 +
76063 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76064 + unsigned long address)
76065 +{
76066 + return 0;
76067 +}
76068 #else
76069 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76070 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76071 #endif
76072
76073 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76074 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76075 NULL: pud_offset(pgd, address);
76076 }
76077
76078 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76079 +{
76080 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76081 + NULL: pud_offset(pgd, address);
76082 +}
76083 +
76084 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76085 {
76086 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76087 NULL: pmd_offset(pud, address);
76088 }
76089 +
76090 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76091 +{
76092 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76093 + NULL: pmd_offset(pud, address);
76094 +}
76095 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76096
76097 #if USE_SPLIT_PTLOCKS
76098 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
76099 unsigned long addr, unsigned long len,
76100 unsigned long flags, struct page **pages);
76101
76102 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
76103 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
76104
76105 extern unsigned long mmap_region(struct file *file, unsigned long addr,
76106 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
76107 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76108 unsigned long len, unsigned long prot, unsigned long flags,
76109 unsigned long pgoff, unsigned long *populate);
76110 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76111 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76112
76113 #ifdef CONFIG_MMU
76114 extern int __mm_populate(unsigned long addr, unsigned long len,
76115 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
76116 unsigned long high_limit;
76117 unsigned long align_mask;
76118 unsigned long align_offset;
76119 + unsigned long threadstack_offset;
76120 };
76121
76122 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76123 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76124 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76125 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76126
76127 /*
76128 * Search for an unmapped address range.
76129 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76130 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76131 */
76132 static inline unsigned long
76133 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76134 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76135 {
76136 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76137 return unmapped_area(info);
76138 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76139 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76140 struct vm_area_struct **pprev);
76141
76142 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76143 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76144 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76145 +
76146 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76147 NULL if none. Assume start_addr < end_addr. */
76148 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76149 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76150 return vma;
76151 }
76152
76153 -#ifdef CONFIG_MMU
76154 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76155 -#else
76156 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76157 -{
76158 - return __pgprot(0);
76159 -}
76160 -#endif
76161 -
76162 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76163 unsigned long change_prot_numa(struct vm_area_struct *vma,
76164 unsigned long start, unsigned long end);
76165 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76166 static inline void vm_stat_account(struct mm_struct *mm,
76167 unsigned long flags, struct file *file, long pages)
76168 {
76169 +
76170 +#ifdef CONFIG_PAX_RANDMMAP
76171 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76172 +#endif
76173 +
76174 mm->total_vm += pages;
76175 }
76176 #endif /* CONFIG_PROC_FS */
76177 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
76178 extern int sysctl_memory_failure_early_kill;
76179 extern int sysctl_memory_failure_recovery;
76180 extern void shake_page(struct page *p, int access);
76181 -extern atomic_long_t num_poisoned_pages;
76182 +extern atomic_long_unchecked_t num_poisoned_pages;
76183 extern int soft_offline_page(struct page *page, int flags);
76184
76185 extern void dump_page(struct page *page);
76186 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
76187 static inline void setup_nr_node_ids(void) {}
76188 #endif
76189
76190 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76191 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76192 +#else
76193 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76194 +#endif
76195 +
76196 #endif /* __KERNEL__ */
76197 #endif /* _LINUX_MM_H */
76198 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76199 index d9851ee..619492d 100644
76200 --- a/include/linux/mm_types.h
76201 +++ b/include/linux/mm_types.h
76202 @@ -289,6 +289,8 @@ struct vm_area_struct {
76203 #ifdef CONFIG_NUMA
76204 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76205 #endif
76206 +
76207 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76208 };
76209
76210 struct core_thread {
76211 @@ -436,6 +438,24 @@ struct mm_struct {
76212 int first_nid;
76213 #endif
76214 struct uprobes_state uprobes_state;
76215 +
76216 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76217 + unsigned long pax_flags;
76218 +#endif
76219 +
76220 +#ifdef CONFIG_PAX_DLRESOLVE
76221 + unsigned long call_dl_resolve;
76222 +#endif
76223 +
76224 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76225 + unsigned long call_syscall;
76226 +#endif
76227 +
76228 +#ifdef CONFIG_PAX_ASLR
76229 + unsigned long delta_mmap; /* randomized offset */
76230 + unsigned long delta_stack; /* randomized offset */
76231 +#endif
76232 +
76233 };
76234
76235 /* first nid will either be a valid NID or one of these values */
76236 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76237 index c5d5278..f0b68c8 100644
76238 --- a/include/linux/mmiotrace.h
76239 +++ b/include/linux/mmiotrace.h
76240 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
76241 /* Called from ioremap.c */
76242 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
76243 void __iomem *addr);
76244 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
76245 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
76246
76247 /* For anyone to insert markers. Remember trailing newline. */
76248 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
76249 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
76250 {
76251 }
76252
76253 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
76254 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
76255 {
76256 }
76257
76258 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
76259 index bd791e4..8617c34f 100644
76260 --- a/include/linux/mmzone.h
76261 +++ b/include/linux/mmzone.h
76262 @@ -396,7 +396,7 @@ struct zone {
76263 unsigned long flags; /* zone flags, see below */
76264
76265 /* Zone statistics */
76266 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76267 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76268
76269 /*
76270 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
76271 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
76272 index 45e9214..a7227d6 100644
76273 --- a/include/linux/mod_devicetable.h
76274 +++ b/include/linux/mod_devicetable.h
76275 @@ -13,7 +13,7 @@
76276 typedef unsigned long kernel_ulong_t;
76277 #endif
76278
76279 -#define PCI_ANY_ID (~0)
76280 +#define PCI_ANY_ID ((__u16)~0)
76281
76282 struct pci_device_id {
76283 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
76284 @@ -139,7 +139,7 @@ struct usb_device_id {
76285 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
76286 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
76287
76288 -#define HID_ANY_ID (~0)
76289 +#define HID_ANY_ID (~0U)
76290 #define HID_BUS_ANY 0xffff
76291 #define HID_GROUP_ANY 0x0000
76292
76293 @@ -467,7 +467,7 @@ struct dmi_system_id {
76294 const char *ident;
76295 struct dmi_strmatch matches[4];
76296 void *driver_data;
76297 -};
76298 +} __do_const;
76299 /*
76300 * struct dmi_device_id appears during expansion of
76301 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
76302 diff --git a/include/linux/module.h b/include/linux/module.h
76303 index 05f2447..2aee07c 100644
76304 --- a/include/linux/module.h
76305 +++ b/include/linux/module.h
76306 @@ -17,9 +17,11 @@
76307 #include <linux/moduleparam.h>
76308 #include <linux/tracepoint.h>
76309 #include <linux/export.h>
76310 +#include <linux/fs.h>
76311
76312 #include <linux/percpu.h>
76313 #include <asm/module.h>
76314 +#include <asm/pgtable.h>
76315
76316 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
76317 #define MODULE_SIG_STRING "~Module signature appended~\n"
76318 @@ -55,12 +57,13 @@ struct module_attribute {
76319 int (*test)(struct module *);
76320 void (*free)(struct module *);
76321 };
76322 +typedef struct module_attribute __no_const module_attribute_no_const;
76323
76324 struct module_version_attribute {
76325 struct module_attribute mattr;
76326 const char *module_name;
76327 const char *version;
76328 -} __attribute__ ((__aligned__(sizeof(void *))));
76329 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
76330
76331 extern ssize_t __modver_version_show(struct module_attribute *,
76332 struct module_kobject *, char *);
76333 @@ -238,7 +241,7 @@ struct module
76334
76335 /* Sysfs stuff. */
76336 struct module_kobject mkobj;
76337 - struct module_attribute *modinfo_attrs;
76338 + module_attribute_no_const *modinfo_attrs;
76339 const char *version;
76340 const char *srcversion;
76341 struct kobject *holders_dir;
76342 @@ -287,19 +290,16 @@ struct module
76343 int (*init)(void);
76344
76345 /* If this is non-NULL, vfree after init() returns */
76346 - void *module_init;
76347 + void *module_init_rx, *module_init_rw;
76348
76349 /* Here is the actual code + data, vfree'd on unload. */
76350 - void *module_core;
76351 + void *module_core_rx, *module_core_rw;
76352
76353 /* Here are the sizes of the init and core sections */
76354 - unsigned int init_size, core_size;
76355 + unsigned int init_size_rw, core_size_rw;
76356
76357 /* The size of the executable code in each section. */
76358 - unsigned int init_text_size, core_text_size;
76359 -
76360 - /* Size of RO sections of the module (text+rodata) */
76361 - unsigned int init_ro_size, core_ro_size;
76362 + unsigned int init_size_rx, core_size_rx;
76363
76364 /* Arch-specific module values */
76365 struct mod_arch_specific arch;
76366 @@ -355,6 +355,10 @@ struct module
76367 #ifdef CONFIG_EVENT_TRACING
76368 struct ftrace_event_call **trace_events;
76369 unsigned int num_trace_events;
76370 + struct file_operations trace_id;
76371 + struct file_operations trace_enable;
76372 + struct file_operations trace_format;
76373 + struct file_operations trace_filter;
76374 #endif
76375 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
76376 unsigned int num_ftrace_callsites;
76377 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
76378 bool is_module_percpu_address(unsigned long addr);
76379 bool is_module_text_address(unsigned long addr);
76380
76381 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
76382 +{
76383 +
76384 +#ifdef CONFIG_PAX_KERNEXEC
76385 + if (ktla_ktva(addr) >= (unsigned long)start &&
76386 + ktla_ktva(addr) < (unsigned long)start + size)
76387 + return 1;
76388 +#endif
76389 +
76390 + return ((void *)addr >= start && (void *)addr < start + size);
76391 +}
76392 +
76393 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
76394 +{
76395 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
76396 +}
76397 +
76398 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
76399 +{
76400 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
76401 +}
76402 +
76403 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
76404 +{
76405 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
76406 +}
76407 +
76408 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
76409 +{
76410 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
76411 +}
76412 +
76413 static inline int within_module_core(unsigned long addr, const struct module *mod)
76414 {
76415 - return (unsigned long)mod->module_core <= addr &&
76416 - addr < (unsigned long)mod->module_core + mod->core_size;
76417 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
76418 }
76419
76420 static inline int within_module_init(unsigned long addr, const struct module *mod)
76421 {
76422 - return (unsigned long)mod->module_init <= addr &&
76423 - addr < (unsigned long)mod->module_init + mod->init_size;
76424 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
76425 }
76426
76427 /* Search for module by name: must hold module_mutex. */
76428 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
76429 index 560ca53..ef621ef 100644
76430 --- a/include/linux/moduleloader.h
76431 +++ b/include/linux/moduleloader.h
76432 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
76433 sections. Returns NULL on failure. */
76434 void *module_alloc(unsigned long size);
76435
76436 +#ifdef CONFIG_PAX_KERNEXEC
76437 +void *module_alloc_exec(unsigned long size);
76438 +#else
76439 +#define module_alloc_exec(x) module_alloc(x)
76440 +#endif
76441 +
76442 /* Free memory returned from module_alloc. */
76443 void module_free(struct module *mod, void *module_region);
76444
76445 +#ifdef CONFIG_PAX_KERNEXEC
76446 +void module_free_exec(struct module *mod, void *module_region);
76447 +#else
76448 +#define module_free_exec(x, y) module_free((x), (y))
76449 +#endif
76450 +
76451 /*
76452 * Apply the given relocation to the (simplified) ELF. Return -error
76453 * or 0.
76454 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
76455 unsigned int relsec,
76456 struct module *me)
76457 {
76458 +#ifdef CONFIG_MODULES
76459 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76460 +#endif
76461 return -ENOEXEC;
76462 }
76463 #endif
76464 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
76465 unsigned int relsec,
76466 struct module *me)
76467 {
76468 +#ifdef CONFIG_MODULES
76469 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76470 +#endif
76471 return -ENOEXEC;
76472 }
76473 #endif
76474 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
76475 index c3eb102..073c4a6 100644
76476 --- a/include/linux/moduleparam.h
76477 +++ b/include/linux/moduleparam.h
76478 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
76479 * @len is usually just sizeof(string).
76480 */
76481 #define module_param_string(name, string, len, perm) \
76482 - static const struct kparam_string __param_string_##name \
76483 + static const struct kparam_string __param_string_##name __used \
76484 = { len, string }; \
76485 __module_param_call(MODULE_PARAM_PREFIX, name, \
76486 &param_ops_string, \
76487 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
76488 */
76489 #define module_param_array_named(name, array, type, nump, perm) \
76490 param_check_##type(name, &(array)[0]); \
76491 - static const struct kparam_array __param_arr_##name \
76492 + static const struct kparam_array __param_arr_##name __used \
76493 = { .max = ARRAY_SIZE(array), .num = nump, \
76494 .ops = &param_ops_##type, \
76495 .elemsize = sizeof(array[0]), .elem = array }; \
76496 diff --git a/include/linux/namei.h b/include/linux/namei.h
76497 index 8e47bc7..c70fd73 100644
76498 --- a/include/linux/namei.h
76499 +++ b/include/linux/namei.h
76500 @@ -19,7 +19,7 @@ struct nameidata {
76501 unsigned seq;
76502 int last_type;
76503 unsigned depth;
76504 - char *saved_names[MAX_NESTED_LINKS + 1];
76505 + const char *saved_names[MAX_NESTED_LINKS + 1];
76506 };
76507
76508 /*
76509 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
76510
76511 extern void nd_jump_link(struct nameidata *nd, struct path *path);
76512
76513 -static inline void nd_set_link(struct nameidata *nd, char *path)
76514 +static inline void nd_set_link(struct nameidata *nd, const char *path)
76515 {
76516 nd->saved_names[nd->depth] = path;
76517 }
76518
76519 -static inline char *nd_get_link(struct nameidata *nd)
76520 +static inline const char *nd_get_link(const struct nameidata *nd)
76521 {
76522 return nd->saved_names[nd->depth];
76523 }
76524 diff --git a/include/linux/net.h b/include/linux/net.h
76525 index 4f27575..fc8a65f 100644
76526 --- a/include/linux/net.h
76527 +++ b/include/linux/net.h
76528 @@ -183,7 +183,7 @@ struct net_proto_family {
76529 int (*create)(struct net *net, struct socket *sock,
76530 int protocol, int kern);
76531 struct module *owner;
76532 -};
76533 +} __do_const;
76534
76535 struct iovec;
76536 struct kvec;
76537 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
76538 index 25f5d2d1..5cf2120 100644
76539 --- a/include/linux/netdevice.h
76540 +++ b/include/linux/netdevice.h
76541 @@ -1098,6 +1098,7 @@ struct net_device_ops {
76542 sa_family_t sa_family,
76543 __be16 port);
76544 };
76545 +typedef struct net_device_ops __no_const net_device_ops_no_const;
76546
76547 /*
76548 * The DEVICE structure.
76549 @@ -1169,7 +1170,7 @@ struct net_device {
76550 int iflink;
76551
76552 struct net_device_stats stats;
76553 - atomic_long_t rx_dropped; /* dropped packets by core network
76554 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
76555 * Do not use this in drivers.
76556 */
76557
76558 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
76559 index 708fe72ab9..77084a3 100644
76560 --- a/include/linux/netfilter.h
76561 +++ b/include/linux/netfilter.h
76562 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
76563 #endif
76564 /* Use the module struct to lock set/get code in place */
76565 struct module *owner;
76566 -};
76567 +} __do_const;
76568
76569 /* Function to register/unregister hook points. */
76570 int nf_register_hook(struct nf_hook_ops *reg);
76571 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
76572 index 9ac9fbd..f92edb4 100644
76573 --- a/include/linux/netfilter/ipset/ip_set.h
76574 +++ b/include/linux/netfilter/ipset/ip_set.h
76575 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
76576 /* Return true if "b" set is the same as "a"
76577 * according to the create set parameters */
76578 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
76579 -};
76580 +} __do_const;
76581
76582 /* The core set type structure */
76583 struct ip_set_type {
76584 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
76585 index cadb740..d7c37c0 100644
76586 --- a/include/linux/netfilter/nfnetlink.h
76587 +++ b/include/linux/netfilter/nfnetlink.h
76588 @@ -16,7 +16,7 @@ struct nfnl_callback {
76589 const struct nlattr * const cda[]);
76590 const struct nla_policy *policy; /* netlink attribute policy */
76591 const u_int16_t attr_count; /* number of nlattr's */
76592 -};
76593 +} __do_const;
76594
76595 struct nfnetlink_subsystem {
76596 const char *name;
76597 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
76598 new file mode 100644
76599 index 0000000..33f4af8
76600 --- /dev/null
76601 +++ b/include/linux/netfilter/xt_gradm.h
76602 @@ -0,0 +1,9 @@
76603 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
76604 +#define _LINUX_NETFILTER_XT_GRADM_H 1
76605 +
76606 +struct xt_gradm_mtinfo {
76607 + __u16 flags;
76608 + __u16 invflags;
76609 +};
76610 +
76611 +#endif
76612 diff --git a/include/linux/nls.h b/include/linux/nls.h
76613 index 5dc635f..35f5e11 100644
76614 --- a/include/linux/nls.h
76615 +++ b/include/linux/nls.h
76616 @@ -31,7 +31,7 @@ struct nls_table {
76617 const unsigned char *charset2upper;
76618 struct module *owner;
76619 struct nls_table *next;
76620 -};
76621 +} __do_const;
76622
76623 /* this value hold the maximum octet of charset */
76624 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
76625 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
76626 index d14a4c3..a078786 100644
76627 --- a/include/linux/notifier.h
76628 +++ b/include/linux/notifier.h
76629 @@ -54,7 +54,8 @@ struct notifier_block {
76630 notifier_fn_t notifier_call;
76631 struct notifier_block __rcu *next;
76632 int priority;
76633 -};
76634 +} __do_const;
76635 +typedef struct notifier_block __no_const notifier_block_no_const;
76636
76637 struct atomic_notifier_head {
76638 spinlock_t lock;
76639 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
76640 index b2a0f15..4d7da32 100644
76641 --- a/include/linux/oprofile.h
76642 +++ b/include/linux/oprofile.h
76643 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
76644 int oprofilefs_create_ro_ulong(struct dentry * root,
76645 char const * name, ulong * val);
76646
76647 -/** Create a file for read-only access to an atomic_t. */
76648 +/** Create a file for read-only access to an atomic_unchecked_t. */
76649 int oprofilefs_create_ro_atomic(struct dentry * root,
76650 - char const * name, atomic_t * val);
76651 + char const * name, atomic_unchecked_t * val);
76652
76653 /** create a directory */
76654 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
76655 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
76656 index 430dd96..544e26e 100644
76657 --- a/include/linux/pci_hotplug.h
76658 +++ b/include/linux/pci_hotplug.h
76659 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
76660 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
76661 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
76662 int (*reset_slot) (struct hotplug_slot *slot, int probe);
76663 -};
76664 +} __do_const;
76665 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
76666
76667 /**
76668 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
76669 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
76670 index c8ba627..24bdfa8 100644
76671 --- a/include/linux/perf_event.h
76672 +++ b/include/linux/perf_event.h
76673 @@ -327,8 +327,8 @@ struct perf_event {
76674
76675 enum perf_event_active_state state;
76676 unsigned int attach_state;
76677 - local64_t count;
76678 - atomic64_t child_count;
76679 + local64_t count; /* PaX: fix it one day */
76680 + atomic64_unchecked_t child_count;
76681
76682 /*
76683 * These are the total time in nanoseconds that the event
76684 @@ -379,8 +379,8 @@ struct perf_event {
76685 * These accumulate total time (in nanoseconds) that children
76686 * events have been enabled and running, respectively.
76687 */
76688 - atomic64_t child_total_time_enabled;
76689 - atomic64_t child_total_time_running;
76690 + atomic64_unchecked_t child_total_time_enabled;
76691 + atomic64_unchecked_t child_total_time_running;
76692
76693 /*
76694 * Protect attach/detach and child_list:
76695 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
76696 entry->ip[entry->nr++] = ip;
76697 }
76698
76699 -extern int sysctl_perf_event_paranoid;
76700 +extern int sysctl_perf_event_legitimately_concerned;
76701 extern int sysctl_perf_event_mlock;
76702 extern int sysctl_perf_event_sample_rate;
76703 extern int sysctl_perf_cpu_time_max_percent;
76704 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
76705 loff_t *ppos);
76706
76707
76708 +static inline bool perf_paranoid_any(void)
76709 +{
76710 + return sysctl_perf_event_legitimately_concerned > 2;
76711 +}
76712 +
76713 static inline bool perf_paranoid_tracepoint_raw(void)
76714 {
76715 - return sysctl_perf_event_paranoid > -1;
76716 + return sysctl_perf_event_legitimately_concerned > -1;
76717 }
76718
76719 static inline bool perf_paranoid_cpu(void)
76720 {
76721 - return sysctl_perf_event_paranoid > 0;
76722 + return sysctl_perf_event_legitimately_concerned > 0;
76723 }
76724
76725 static inline bool perf_paranoid_kernel(void)
76726 {
76727 - return sysctl_perf_event_paranoid > 1;
76728 + return sysctl_perf_event_legitimately_concerned > 1;
76729 }
76730
76731 extern void perf_event_init(void);
76732 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
76733 struct device_attribute attr;
76734 u64 id;
76735 const char *event_str;
76736 -};
76737 +} __do_const;
76738
76739 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
76740 static struct perf_pmu_events_attr _var = { \
76741 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
76742 index b8809fe..ae4ccd0 100644
76743 --- a/include/linux/pipe_fs_i.h
76744 +++ b/include/linux/pipe_fs_i.h
76745 @@ -47,10 +47,10 @@ struct pipe_inode_info {
76746 struct mutex mutex;
76747 wait_queue_head_t wait;
76748 unsigned int nrbufs, curbuf, buffers;
76749 - unsigned int readers;
76750 - unsigned int writers;
76751 - unsigned int files;
76752 - unsigned int waiting_writers;
76753 + atomic_t readers;
76754 + atomic_t writers;
76755 + atomic_t files;
76756 + atomic_t waiting_writers;
76757 unsigned int r_counter;
76758 unsigned int w_counter;
76759 struct page *tmp_page;
76760 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
76761 index 5f28cae..3d23723 100644
76762 --- a/include/linux/platform_data/usb-ehci-s5p.h
76763 +++ b/include/linux/platform_data/usb-ehci-s5p.h
76764 @@ -14,7 +14,7 @@
76765 struct s5p_ehci_platdata {
76766 int (*phy_init)(struct platform_device *pdev, int type);
76767 int (*phy_exit)(struct platform_device *pdev, int type);
76768 -};
76769 +} __no_const;
76770
76771 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
76772
76773 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
76774 index c256c59..8ea94c7 100644
76775 --- a/include/linux/platform_data/usb-ohci-exynos.h
76776 +++ b/include/linux/platform_data/usb-ohci-exynos.h
76777 @@ -14,7 +14,7 @@
76778 struct exynos4_ohci_platdata {
76779 int (*phy_init)(struct platform_device *pdev, int type);
76780 int (*phy_exit)(struct platform_device *pdev, int type);
76781 -};
76782 +} __no_const;
76783
76784 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
76785
76786 diff --git a/include/linux/pm.h b/include/linux/pm.h
76787 index a224c7f..92d8a97 100644
76788 --- a/include/linux/pm.h
76789 +++ b/include/linux/pm.h
76790 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
76791 struct dev_pm_domain {
76792 struct dev_pm_ops ops;
76793 };
76794 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
76795
76796 /*
76797 * The PM_EVENT_ messages are also used by drivers implementing the legacy
76798 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
76799 index 7c1d252..c5c773e 100644
76800 --- a/include/linux/pm_domain.h
76801 +++ b/include/linux/pm_domain.h
76802 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
76803
76804 struct gpd_cpu_data {
76805 unsigned int saved_exit_latency;
76806 - struct cpuidle_state *idle_state;
76807 + cpuidle_state_no_const *idle_state;
76808 };
76809
76810 struct generic_pm_domain {
76811 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
76812 index 6fa7cea..7bf6415 100644
76813 --- a/include/linux/pm_runtime.h
76814 +++ b/include/linux/pm_runtime.h
76815 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
76816
76817 static inline void pm_runtime_mark_last_busy(struct device *dev)
76818 {
76819 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
76820 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
76821 }
76822
76823 #else /* !CONFIG_PM_RUNTIME */
76824 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
76825 index 195aafc..49a7bc2 100644
76826 --- a/include/linux/pnp.h
76827 +++ b/include/linux/pnp.h
76828 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
76829 struct pnp_fixup {
76830 char id[7];
76831 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
76832 -};
76833 +} __do_const;
76834
76835 /* config parameters */
76836 #define PNP_CONFIG_NORMAL 0x0001
76837 diff --git a/include/linux/poison.h b/include/linux/poison.h
76838 index 2110a81..13a11bb 100644
76839 --- a/include/linux/poison.h
76840 +++ b/include/linux/poison.h
76841 @@ -19,8 +19,8 @@
76842 * under normal circumstances, used to verify that nobody uses
76843 * non-initialized list entries.
76844 */
76845 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
76846 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
76847 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
76848 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
76849
76850 /********** include/linux/timer.h **********/
76851 /*
76852 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
76853 index d8b187c3..9a9257a 100644
76854 --- a/include/linux/power/smartreflex.h
76855 +++ b/include/linux/power/smartreflex.h
76856 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
76857 int (*notify)(struct omap_sr *sr, u32 status);
76858 u8 notify_flags;
76859 u8 class_type;
76860 -};
76861 +} __do_const;
76862
76863 /**
76864 * struct omap_sr_nvalue_table - Smartreflex n-target value info
76865 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
76866 index 4ea1d37..80f4b33 100644
76867 --- a/include/linux/ppp-comp.h
76868 +++ b/include/linux/ppp-comp.h
76869 @@ -84,7 +84,7 @@ struct compressor {
76870 struct module *owner;
76871 /* Extra skb space needed by the compressor algorithm */
76872 unsigned int comp_extra;
76873 -};
76874 +} __do_const;
76875
76876 /*
76877 * The return value from decompress routine is the length of the
76878 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
76879 index f5d4723..a6ea2fa 100644
76880 --- a/include/linux/preempt.h
76881 +++ b/include/linux/preempt.h
76882 @@ -18,8 +18,13 @@
76883 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76884 #endif
76885
76886 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
76887 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76888 +
76889 #define inc_preempt_count() add_preempt_count(1)
76890 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
76891 #define dec_preempt_count() sub_preempt_count(1)
76892 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
76893
76894 #define preempt_count() (current_thread_info()->preempt_count)
76895
76896 @@ -64,6 +69,12 @@ do { \
76897 barrier(); \
76898 } while (0)
76899
76900 +#define raw_preempt_disable() \
76901 +do { \
76902 + raw_inc_preempt_count(); \
76903 + barrier(); \
76904 +} while (0)
76905 +
76906 #define sched_preempt_enable_no_resched() \
76907 do { \
76908 barrier(); \
76909 @@ -72,6 +83,12 @@ do { \
76910
76911 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
76912
76913 +#define raw_preempt_enable_no_resched() \
76914 +do { \
76915 + barrier(); \
76916 + raw_dec_preempt_count(); \
76917 +} while (0)
76918 +
76919 #define preempt_enable() \
76920 do { \
76921 preempt_enable_no_resched(); \
76922 @@ -116,8 +133,10 @@ do { \
76923 * region.
76924 */
76925 #define preempt_disable() barrier()
76926 +#define raw_preempt_disable() barrier()
76927 #define sched_preempt_enable_no_resched() barrier()
76928 #define preempt_enable_no_resched() barrier()
76929 +#define raw_preempt_enable_no_resched() barrier()
76930 #define preempt_enable() barrier()
76931
76932 #define preempt_disable_notrace() barrier()
76933 diff --git a/include/linux/printk.h b/include/linux/printk.h
76934 index e6131a78..8e9fb61 100644
76935 --- a/include/linux/printk.h
76936 +++ b/include/linux/printk.h
76937 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76938 void early_printk(const char *s, ...) { }
76939 #endif
76940
76941 +extern int kptr_restrict;
76942 +
76943 #ifdef CONFIG_PRINTK
76944 asmlinkage __printf(5, 0)
76945 int vprintk_emit(int facility, int level,
76946 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76947
76948 extern int printk_delay_msec;
76949 extern int dmesg_restrict;
76950 -extern int kptr_restrict;
76951
76952 extern void wake_up_klogd(void);
76953
76954 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76955 index 608e60a..c26f864 100644
76956 --- a/include/linux/proc_fs.h
76957 +++ b/include/linux/proc_fs.h
76958 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76959 return proc_create_data(name, mode, parent, proc_fops, NULL);
76960 }
76961
76962 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76963 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76964 +{
76965 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76966 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76967 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76968 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76969 +#else
76970 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76971 +#endif
76972 +}
76973 +
76974 +
76975 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76976 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76977 extern void *PDE_DATA(const struct inode *);
76978 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76979 index 34a1e10..03a6d03 100644
76980 --- a/include/linux/proc_ns.h
76981 +++ b/include/linux/proc_ns.h
76982 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76983 void (*put)(void *ns);
76984 int (*install)(struct nsproxy *nsproxy, void *ns);
76985 unsigned int (*inum)(void *ns);
76986 -};
76987 +} __do_const;
76988
76989 struct proc_ns {
76990 void *ns;
76991 diff --git a/include/linux/quota.h b/include/linux/quota.h
76992 index cc7494a..1e27036 100644
76993 --- a/include/linux/quota.h
76994 +++ b/include/linux/quota.h
76995 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
76996
76997 extern bool qid_eq(struct kqid left, struct kqid right);
76998 extern bool qid_lt(struct kqid left, struct kqid right);
76999 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
77000 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
77001 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
77002 extern bool qid_valid(struct kqid qid);
77003
77004 diff --git a/include/linux/random.h b/include/linux/random.h
77005 index 6312dd9..2561947 100644
77006 --- a/include/linux/random.h
77007 +++ b/include/linux/random.h
77008 @@ -10,9 +10,19 @@
77009
77010
77011 extern void add_device_randomness(const void *, unsigned int);
77012 +
77013 +static inline void add_latent_entropy(void)
77014 +{
77015 +
77016 +#ifdef LATENT_ENTROPY_PLUGIN
77017 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77018 +#endif
77019 +
77020 +}
77021 +
77022 extern void add_input_randomness(unsigned int type, unsigned int code,
77023 - unsigned int value);
77024 -extern void add_interrupt_randomness(int irq, int irq_flags);
77025 + unsigned int value) __latent_entropy;
77026 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
77027
77028 extern void get_random_bytes(void *buf, int nbytes);
77029 extern void get_random_bytes_arch(void *buf, int nbytes);
77030 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
77031 u32 prandom_u32_state(struct rnd_state *);
77032 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77033
77034 +static inline unsigned long pax_get_random_long(void)
77035 +{
77036 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77037 +}
77038 +
77039 /*
77040 * Handle minimum values for seeds
77041 */
77042 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77043 index 4106721..132d42c 100644
77044 --- a/include/linux/rculist.h
77045 +++ b/include/linux/rculist.h
77046 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77047 struct list_head *prev, struct list_head *next);
77048 #endif
77049
77050 +extern void __pax_list_add_rcu(struct list_head *new,
77051 + struct list_head *prev, struct list_head *next);
77052 +
77053 /**
77054 * list_add_rcu - add a new entry to rcu-protected list
77055 * @new: new entry to be added
77056 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77057 __list_add_rcu(new, head, head->next);
77058 }
77059
77060 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77061 +{
77062 + __pax_list_add_rcu(new, head, head->next);
77063 +}
77064 +
77065 /**
77066 * list_add_tail_rcu - add a new entry to rcu-protected list
77067 * @new: new entry to be added
77068 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77069 __list_add_rcu(new, head->prev, head);
77070 }
77071
77072 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77073 + struct list_head *head)
77074 +{
77075 + __pax_list_add_rcu(new, head->prev, head);
77076 +}
77077 +
77078 /**
77079 * list_del_rcu - deletes entry from list without re-initialization
77080 * @entry: the element to delete from the list.
77081 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77082 entry->prev = LIST_POISON2;
77083 }
77084
77085 +extern void pax_list_del_rcu(struct list_head *entry);
77086 +
77087 /**
77088 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77089 * @n: the element to delete from the hash list.
77090 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77091 index 8e00f9f..9449b55 100644
77092 --- a/include/linux/reboot.h
77093 +++ b/include/linux/reboot.h
77094 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77095 * Architecture-specific implementations of sys_reboot commands.
77096 */
77097
77098 -extern void machine_restart(char *cmd);
77099 -extern void machine_halt(void);
77100 -extern void machine_power_off(void);
77101 +extern void machine_restart(char *cmd) __noreturn;
77102 +extern void machine_halt(void) __noreturn;
77103 +extern void machine_power_off(void) __noreturn;
77104
77105 extern void machine_shutdown(void);
77106 struct pt_regs;
77107 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77108 */
77109
77110 extern void kernel_restart_prepare(char *cmd);
77111 -extern void kernel_restart(char *cmd);
77112 -extern void kernel_halt(void);
77113 -extern void kernel_power_off(void);
77114 +extern void kernel_restart(char *cmd) __noreturn;
77115 +extern void kernel_halt(void) __noreturn;
77116 +extern void kernel_power_off(void) __noreturn;
77117
77118 extern int C_A_D; /* for sysctl */
77119 void ctrl_alt_del(void);
77120 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
77121 * Emergency restart, callable from an interrupt handler.
77122 */
77123
77124 -extern void emergency_restart(void);
77125 +extern void emergency_restart(void) __noreturn;
77126 #include <asm/emergency-restart.h>
77127
77128 #endif /* _LINUX_REBOOT_H */
77129 diff --git a/include/linux/regset.h b/include/linux/regset.h
77130 index 8e0c9fe..ac4d221 100644
77131 --- a/include/linux/regset.h
77132 +++ b/include/linux/regset.h
77133 @@ -161,7 +161,8 @@ struct user_regset {
77134 unsigned int align;
77135 unsigned int bias;
77136 unsigned int core_note_type;
77137 -};
77138 +} __do_const;
77139 +typedef struct user_regset __no_const user_regset_no_const;
77140
77141 /**
77142 * struct user_regset_view - available regsets
77143 diff --git a/include/linux/relay.h b/include/linux/relay.h
77144 index d7c8359..818daf5 100644
77145 --- a/include/linux/relay.h
77146 +++ b/include/linux/relay.h
77147 @@ -157,7 +157,7 @@ struct rchan_callbacks
77148 * The callback should return 0 if successful, negative if not.
77149 */
77150 int (*remove_buf_file)(struct dentry *dentry);
77151 -};
77152 +} __no_const;
77153
77154 /*
77155 * CONFIG_RELAY kernel API, kernel/relay.c
77156 diff --git a/include/linux/rio.h b/include/linux/rio.h
77157 index b71d573..2f940bd 100644
77158 --- a/include/linux/rio.h
77159 +++ b/include/linux/rio.h
77160 @@ -355,7 +355,7 @@ struct rio_ops {
77161 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77162 u64 rstart, u32 size, u32 flags);
77163 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77164 -};
77165 +} __no_const;
77166
77167 #define RIO_RESOURCE_MEM 0x00000100
77168 #define RIO_RESOURCE_DOORBELL 0x00000200
77169 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77170 index 6dacb93..6174423 100644
77171 --- a/include/linux/rmap.h
77172 +++ b/include/linux/rmap.h
77173 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77174 void anon_vma_init(void); /* create anon_vma_cachep */
77175 int anon_vma_prepare(struct vm_area_struct *);
77176 void unlink_anon_vmas(struct vm_area_struct *);
77177 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77178 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77179 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77180 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77181
77182 static inline void anon_vma_merge(struct vm_area_struct *vma,
77183 struct vm_area_struct *next)
77184 diff --git a/include/linux/sched.h b/include/linux/sched.h
77185 index b1e963e..114b8fd 100644
77186 --- a/include/linux/sched.h
77187 +++ b/include/linux/sched.h
77188 @@ -62,6 +62,7 @@ struct bio_list;
77189 struct fs_struct;
77190 struct perf_event_context;
77191 struct blk_plug;
77192 +struct linux_binprm;
77193
77194 /*
77195 * List of flags we want to share for kernel threads,
77196 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
77197 extern int in_sched_functions(unsigned long addr);
77198
77199 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77200 -extern signed long schedule_timeout(signed long timeout);
77201 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77202 extern signed long schedule_timeout_interruptible(signed long timeout);
77203 extern signed long schedule_timeout_killable(signed long timeout);
77204 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77205 @@ -306,6 +307,19 @@ struct nsproxy;
77206 struct user_namespace;
77207
77208 #ifdef CONFIG_MMU
77209 +
77210 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77211 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77212 +#else
77213 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77214 +{
77215 + return 0;
77216 +}
77217 +#endif
77218 +
77219 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77220 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77221 +
77222 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77223 extern unsigned long
77224 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77225 @@ -585,6 +599,17 @@ struct signal_struct {
77226 #ifdef CONFIG_TASKSTATS
77227 struct taskstats *stats;
77228 #endif
77229 +
77230 +#ifdef CONFIG_GRKERNSEC
77231 + u32 curr_ip;
77232 + u32 saved_ip;
77233 + u32 gr_saddr;
77234 + u32 gr_daddr;
77235 + u16 gr_sport;
77236 + u16 gr_dport;
77237 + u8 used_accept:1;
77238 +#endif
77239 +
77240 #ifdef CONFIG_AUDIT
77241 unsigned audit_tty;
77242 unsigned audit_tty_log_passwd;
77243 @@ -665,6 +690,14 @@ struct user_struct {
77244 struct key *session_keyring; /* UID's default session keyring */
77245 #endif
77246
77247 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
77248 + unsigned char kernel_banned;
77249 +#endif
77250 +#ifdef CONFIG_GRKERNSEC_BRUTE
77251 + unsigned char suid_banned;
77252 + unsigned long suid_ban_expires;
77253 +#endif
77254 +
77255 /* Hash table maintenance information */
77256 struct hlist_node uidhash_node;
77257 kuid_t uid;
77258 @@ -1150,8 +1183,8 @@ struct task_struct {
77259 struct list_head thread_group;
77260
77261 struct completion *vfork_done; /* for vfork() */
77262 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
77263 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77264 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
77265 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77266
77267 cputime_t utime, stime, utimescaled, stimescaled;
77268 cputime_t gtime;
77269 @@ -1176,11 +1209,6 @@ struct task_struct {
77270 struct task_cputime cputime_expires;
77271 struct list_head cpu_timers[3];
77272
77273 -/* process credentials */
77274 - const struct cred __rcu *real_cred; /* objective and real subjective task
77275 - * credentials (COW) */
77276 - const struct cred __rcu *cred; /* effective (overridable) subjective task
77277 - * credentials (COW) */
77278 char comm[TASK_COMM_LEN]; /* executable name excluding path
77279 - access with [gs]et_task_comm (which lock
77280 it with task_lock())
77281 @@ -1197,6 +1225,10 @@ struct task_struct {
77282 #endif
77283 /* CPU-specific state of this task */
77284 struct thread_struct thread;
77285 +/* thread_info moved to task_struct */
77286 +#ifdef CONFIG_X86
77287 + struct thread_info tinfo;
77288 +#endif
77289 /* filesystem information */
77290 struct fs_struct *fs;
77291 /* open file information */
77292 @@ -1270,6 +1302,10 @@ struct task_struct {
77293 gfp_t lockdep_reclaim_gfp;
77294 #endif
77295
77296 +/* process credentials */
77297 + const struct cred __rcu *real_cred; /* objective and real subjective task
77298 + * credentials (COW) */
77299 +
77300 /* journalling filesystem info */
77301 void *journal_info;
77302
77303 @@ -1308,6 +1344,10 @@ struct task_struct {
77304 /* cg_list protected by css_set_lock and tsk->alloc_lock */
77305 struct list_head cg_list;
77306 #endif
77307 +
77308 + const struct cred __rcu *cred; /* effective (overridable) subjective task
77309 + * credentials (COW) */
77310 +
77311 #ifdef CONFIG_FUTEX
77312 struct robust_list_head __user *robust_list;
77313 #ifdef CONFIG_COMPAT
77314 @@ -1411,8 +1451,78 @@ struct task_struct {
77315 unsigned int sequential_io;
77316 unsigned int sequential_io_avg;
77317 #endif
77318 +
77319 +#ifdef CONFIG_GRKERNSEC
77320 + /* grsecurity */
77321 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77322 + u64 exec_id;
77323 +#endif
77324 +#ifdef CONFIG_GRKERNSEC_SETXID
77325 + const struct cred *delayed_cred;
77326 +#endif
77327 + struct dentry *gr_chroot_dentry;
77328 + struct acl_subject_label *acl;
77329 + struct acl_subject_label *tmpacl;
77330 + struct acl_role_label *role;
77331 + struct file *exec_file;
77332 + unsigned long brute_expires;
77333 + u16 acl_role_id;
77334 + u8 inherited;
77335 + /* is this the task that authenticated to the special role */
77336 + u8 acl_sp_role;
77337 + u8 is_writable;
77338 + u8 brute;
77339 + u8 gr_is_chrooted;
77340 +#endif
77341 +
77342 };
77343
77344 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
77345 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
77346 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
77347 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
77348 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
77349 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
77350 +
77351 +#ifdef CONFIG_PAX_SOFTMODE
77352 +extern int pax_softmode;
77353 +#endif
77354 +
77355 +extern int pax_check_flags(unsigned long *);
77356 +
77357 +/* if tsk != current then task_lock must be held on it */
77358 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77359 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
77360 +{
77361 + if (likely(tsk->mm))
77362 + return tsk->mm->pax_flags;
77363 + else
77364 + return 0UL;
77365 +}
77366 +
77367 +/* if tsk != current then task_lock must be held on it */
77368 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
77369 +{
77370 + if (likely(tsk->mm)) {
77371 + tsk->mm->pax_flags = flags;
77372 + return 0;
77373 + }
77374 + return -EINVAL;
77375 +}
77376 +#endif
77377 +
77378 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
77379 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
77380 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
77381 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
77382 +#endif
77383 +
77384 +struct path;
77385 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
77386 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
77387 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
77388 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
77389 +
77390 /* Future-safe accessor for struct task_struct's cpus_allowed. */
77391 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
77392
77393 @@ -1471,7 +1581,7 @@ struct pid_namespace;
77394 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
77395 struct pid_namespace *ns);
77396
77397 -static inline pid_t task_pid_nr(struct task_struct *tsk)
77398 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
77399 {
77400 return tsk->pid;
77401 }
77402 @@ -1921,7 +2031,9 @@ void yield(void);
77403 extern struct exec_domain default_exec_domain;
77404
77405 union thread_union {
77406 +#ifndef CONFIG_X86
77407 struct thread_info thread_info;
77408 +#endif
77409 unsigned long stack[THREAD_SIZE/sizeof(long)];
77410 };
77411
77412 @@ -1954,6 +2066,7 @@ extern struct pid_namespace init_pid_ns;
77413 */
77414
77415 extern struct task_struct *find_task_by_vpid(pid_t nr);
77416 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
77417 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
77418 struct pid_namespace *ns);
77419
77420 @@ -2118,7 +2231,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
77421 extern void exit_itimers(struct signal_struct *);
77422 extern void flush_itimer_signals(void);
77423
77424 -extern void do_group_exit(int);
77425 +extern __noreturn void do_group_exit(int);
77426
77427 extern int allow_signal(int);
77428 extern int disallow_signal(int);
77429 @@ -2309,9 +2422,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
77430
77431 #endif
77432
77433 -static inline int object_is_on_stack(void *obj)
77434 +static inline int object_starts_on_stack(void *obj)
77435 {
77436 - void *stack = task_stack_page(current);
77437 + const void *stack = task_stack_page(current);
77438
77439 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
77440 }
77441 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
77442 index bf8086b..962b035 100644
77443 --- a/include/linux/sched/sysctl.h
77444 +++ b/include/linux/sched/sysctl.h
77445 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
77446 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
77447
77448 extern int sysctl_max_map_count;
77449 +extern unsigned long sysctl_heap_stack_gap;
77450
77451 extern unsigned int sysctl_sched_latency;
77452 extern unsigned int sysctl_sched_min_granularity;
77453 diff --git a/include/linux/security.h b/include/linux/security.h
77454 index 9d37e2b..43368e4 100644
77455 --- a/include/linux/security.h
77456 +++ b/include/linux/security.h
77457 @@ -27,6 +27,7 @@
77458 #include <linux/slab.h>
77459 #include <linux/err.h>
77460 #include <linux/string.h>
77461 +#include <linux/grsecurity.h>
77462
77463 struct linux_binprm;
77464 struct cred;
77465 @@ -116,8 +117,6 @@ struct seq_file;
77466
77467 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
77468
77469 -void reset_security_ops(void);
77470 -
77471 #ifdef CONFIG_MMU
77472 extern unsigned long mmap_min_addr;
77473 extern unsigned long dac_mmap_min_addr;
77474 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
77475 index dc368b8..e895209 100644
77476 --- a/include/linux/semaphore.h
77477 +++ b/include/linux/semaphore.h
77478 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
77479 }
77480
77481 extern void down(struct semaphore *sem);
77482 -extern int __must_check down_interruptible(struct semaphore *sem);
77483 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
77484 extern int __must_check down_killable(struct semaphore *sem);
77485 extern int __must_check down_trylock(struct semaphore *sem);
77486 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
77487 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
77488 index 4e32edc..f8f2d18 100644
77489 --- a/include/linux/seq_file.h
77490 +++ b/include/linux/seq_file.h
77491 @@ -26,6 +26,9 @@ struct seq_file {
77492 struct mutex lock;
77493 const struct seq_operations *op;
77494 int poll_event;
77495 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77496 + u64 exec_id;
77497 +#endif
77498 #ifdef CONFIG_USER_NS
77499 struct user_namespace *user_ns;
77500 #endif
77501 @@ -38,6 +41,7 @@ struct seq_operations {
77502 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
77503 int (*show) (struct seq_file *m, void *v);
77504 };
77505 +typedef struct seq_operations __no_const seq_operations_no_const;
77506
77507 #define SEQ_SKIP 1
77508
77509 diff --git a/include/linux/shm.h b/include/linux/shm.h
77510 index 429c199..4d42e38 100644
77511 --- a/include/linux/shm.h
77512 +++ b/include/linux/shm.h
77513 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
77514
77515 /* The task created the shm object. NULL if the task is dead. */
77516 struct task_struct *shm_creator;
77517 +#ifdef CONFIG_GRKERNSEC
77518 + time_t shm_createtime;
77519 + pid_t shm_lapid;
77520 +#endif
77521 };
77522
77523 /* shm_mode upper byte flags */
77524 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
77525 index c2d8933..b2b4ed6 100644
77526 --- a/include/linux/skbuff.h
77527 +++ b/include/linux/skbuff.h
77528 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
77529 extern struct sk_buff *__alloc_skb(unsigned int size,
77530 gfp_t priority, int flags, int node);
77531 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
77532 -static inline struct sk_buff *alloc_skb(unsigned int size,
77533 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
77534 gfp_t priority)
77535 {
77536 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
77537 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
77538 */
77539 static inline int skb_queue_empty(const struct sk_buff_head *list)
77540 {
77541 - return list->next == (struct sk_buff *)list;
77542 + return list->next == (const struct sk_buff *)list;
77543 }
77544
77545 /**
77546 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
77547 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77548 const struct sk_buff *skb)
77549 {
77550 - return skb->next == (struct sk_buff *)list;
77551 + return skb->next == (const struct sk_buff *)list;
77552 }
77553
77554 /**
77555 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77556 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
77557 const struct sk_buff *skb)
77558 {
77559 - return skb->prev == (struct sk_buff *)list;
77560 + return skb->prev == (const struct sk_buff *)list;
77561 }
77562
77563 /**
77564 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
77565 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
77566 */
77567 #ifndef NET_SKB_PAD
77568 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
77569 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
77570 #endif
77571
77572 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
77573 @@ -2348,7 +2348,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
77574 int noblock, int *err);
77575 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
77576 struct poll_table_struct *wait);
77577 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
77578 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
77579 int offset, struct iovec *to,
77580 int size);
77581 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
77582 @@ -2643,6 +2643,9 @@ static inline void nf_reset(struct sk_buff *skb)
77583 nf_bridge_put(skb->nf_bridge);
77584 skb->nf_bridge = NULL;
77585 #endif
77586 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
77587 + skb->nf_trace = 0;
77588 +#endif
77589 }
77590
77591 static inline void nf_reset_trace(struct sk_buff *skb)
77592 diff --git a/include/linux/slab.h b/include/linux/slab.h
77593 index 74f1058..914b7da 100644
77594 --- a/include/linux/slab.h
77595 +++ b/include/linux/slab.h
77596 @@ -14,15 +14,29 @@
77597 #include <linux/gfp.h>
77598 #include <linux/types.h>
77599 #include <linux/workqueue.h>
77600 -
77601 +#include <linux/err.h>
77602
77603 /*
77604 * Flags to pass to kmem_cache_create().
77605 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
77606 */
77607 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
77608 +
77609 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77610 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
77611 +#else
77612 +#define SLAB_USERCOPY 0x00000000UL
77613 +#endif
77614 +
77615 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
77616 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
77617 +
77618 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77619 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
77620 +#else
77621 +#define SLAB_NO_SANITIZE 0x00000000UL
77622 +#endif
77623 +
77624 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
77625 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
77626 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
77627 @@ -91,10 +105,13 @@
77628 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
77629 * Both make kfree a no-op.
77630 */
77631 -#define ZERO_SIZE_PTR ((void *)16)
77632 +#define ZERO_SIZE_PTR \
77633 +({ \
77634 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
77635 + (void *)(-MAX_ERRNO-1L); \
77636 +})
77637
77638 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
77639 - (unsigned long)ZERO_SIZE_PTR)
77640 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
77641
77642 #include <linux/kmemleak.h>
77643
77644 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
77645 void kfree(const void *);
77646 void kzfree(const void *);
77647 size_t ksize(const void *);
77648 +const char *check_heap_object(const void *ptr, unsigned long n);
77649 +bool is_usercopy_object(const void *ptr);
77650
77651 /*
77652 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
77653 @@ -167,7 +186,7 @@ struct kmem_cache {
77654 unsigned int align; /* Alignment as calculated */
77655 unsigned long flags; /* Active flags on the slab */
77656 const char *name; /* Slab name for sysfs */
77657 - int refcount; /* Use counter */
77658 + atomic_t refcount; /* Use counter */
77659 void (*ctor)(void *); /* Called on object slot creation */
77660 struct list_head list; /* List of all slab caches on the system */
77661 };
77662 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
77663 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77664 #endif
77665
77666 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77667 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
77668 +#endif
77669 +
77670 /*
77671 * Figure out which kmalloc slab an allocation of a certain size
77672 * belongs to.
77673 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77674 * 2 = 120 .. 192 bytes
77675 * n = 2^(n-1) .. 2^n -1
77676 */
77677 -static __always_inline int kmalloc_index(size_t size)
77678 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
77679 {
77680 if (!size)
77681 return 0;
77682 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
77683 }
77684 #endif /* !CONFIG_SLOB */
77685
77686 -void *__kmalloc(size_t size, gfp_t flags);
77687 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
77688 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
77689
77690 #ifdef CONFIG_NUMA
77691 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
77692 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
77693 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77694 #else
77695 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
77696 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
77697 index e9346b4..1494959 100644
77698 --- a/include/linux/slab_def.h
77699 +++ b/include/linux/slab_def.h
77700 @@ -36,7 +36,7 @@ struct kmem_cache {
77701 /* 4) cache creation/removal */
77702 const char *name;
77703 struct list_head list;
77704 - int refcount;
77705 + atomic_t refcount;
77706 int object_size;
77707 int align;
77708
77709 @@ -52,10 +52,14 @@ struct kmem_cache {
77710 unsigned long node_allocs;
77711 unsigned long node_frees;
77712 unsigned long node_overflow;
77713 - atomic_t allochit;
77714 - atomic_t allocmiss;
77715 - atomic_t freehit;
77716 - atomic_t freemiss;
77717 + atomic_unchecked_t allochit;
77718 + atomic_unchecked_t allocmiss;
77719 + atomic_unchecked_t freehit;
77720 + atomic_unchecked_t freemiss;
77721 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77722 + atomic_unchecked_t sanitized;
77723 + atomic_unchecked_t not_sanitized;
77724 +#endif
77725
77726 /*
77727 * If debugging is enabled, then the allocator can add additional
77728 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
77729 index cc0b67e..a0329b1 100644
77730 --- a/include/linux/slub_def.h
77731 +++ b/include/linux/slub_def.h
77732 @@ -74,7 +74,7 @@ struct kmem_cache {
77733 struct kmem_cache_order_objects max;
77734 struct kmem_cache_order_objects min;
77735 gfp_t allocflags; /* gfp flags to use on each alloc */
77736 - int refcount; /* Refcount for slab cache destroy */
77737 + atomic_t refcount; /* Refcount for slab cache destroy */
77738 void (*ctor)(void *);
77739 int inuse; /* Offset to metadata */
77740 int align; /* Alignment */
77741 diff --git a/include/linux/smp.h b/include/linux/smp.h
77742 index 731f523..3340268 100644
77743 --- a/include/linux/smp.h
77744 +++ b/include/linux/smp.h
77745 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
77746 #endif
77747
77748 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
77749 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
77750 #define put_cpu() preempt_enable()
77751 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
77752
77753 /*
77754 * Callback to arch code if there's nosmp or maxcpus=0 on the
77755 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
77756 index 54f91d3..be2c379 100644
77757 --- a/include/linux/sock_diag.h
77758 +++ b/include/linux/sock_diag.h
77759 @@ -11,7 +11,7 @@ struct sock;
77760 struct sock_diag_handler {
77761 __u8 family;
77762 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
77763 -};
77764 +} __do_const;
77765
77766 int sock_diag_register(const struct sock_diag_handler *h);
77767 void sock_diag_unregister(const struct sock_diag_handler *h);
77768 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
77769 index 680f9a3..f13aeb0 100644
77770 --- a/include/linux/sonet.h
77771 +++ b/include/linux/sonet.h
77772 @@ -7,7 +7,7 @@
77773 #include <uapi/linux/sonet.h>
77774
77775 struct k_sonet_stats {
77776 -#define __HANDLE_ITEM(i) atomic_t i
77777 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77778 __SONET_ITEMS
77779 #undef __HANDLE_ITEM
77780 };
77781 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
77782 index 07d8e53..dc934c9 100644
77783 --- a/include/linux/sunrpc/addr.h
77784 +++ b/include/linux/sunrpc/addr.h
77785 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
77786 {
77787 switch (sap->sa_family) {
77788 case AF_INET:
77789 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
77790 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
77791 case AF_INET6:
77792 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
77793 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
77794 }
77795 return 0;
77796 }
77797 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
77798 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
77799 const struct sockaddr *src)
77800 {
77801 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
77802 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
77803 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
77804
77805 dsin->sin_family = ssin->sin_family;
77806 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
77807 if (sa->sa_family != AF_INET6)
77808 return 0;
77809
77810 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
77811 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
77812 }
77813
77814 #endif /* _LINUX_SUNRPC_ADDR_H */
77815 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
77816 index 6740801..c535f27 100644
77817 --- a/include/linux/sunrpc/clnt.h
77818 +++ b/include/linux/sunrpc/clnt.h
77819 @@ -96,7 +96,7 @@ struct rpc_procinfo {
77820 unsigned int p_timer; /* Which RTT timer to use */
77821 u32 p_statidx; /* Which procedure to account */
77822 const char * p_name; /* name of procedure */
77823 -};
77824 +} __do_const;
77825
77826 #ifdef __KERNEL__
77827
77828 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
77829 index 6eecfc2..7ada79d 100644
77830 --- a/include/linux/sunrpc/svc.h
77831 +++ b/include/linux/sunrpc/svc.h
77832 @@ -410,7 +410,7 @@ struct svc_procedure {
77833 unsigned int pc_count; /* call count */
77834 unsigned int pc_cachetype; /* cache info (NFS) */
77835 unsigned int pc_xdrressize; /* maximum size of XDR reply */
77836 -};
77837 +} __do_const;
77838
77839 /*
77840 * Function prototypes.
77841 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
77842 index 0b8e3e6..33e0a01 100644
77843 --- a/include/linux/sunrpc/svc_rdma.h
77844 +++ b/include/linux/sunrpc/svc_rdma.h
77845 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
77846 extern unsigned int svcrdma_max_requests;
77847 extern unsigned int svcrdma_max_req_size;
77848
77849 -extern atomic_t rdma_stat_recv;
77850 -extern atomic_t rdma_stat_read;
77851 -extern atomic_t rdma_stat_write;
77852 -extern atomic_t rdma_stat_sq_starve;
77853 -extern atomic_t rdma_stat_rq_starve;
77854 -extern atomic_t rdma_stat_rq_poll;
77855 -extern atomic_t rdma_stat_rq_prod;
77856 -extern atomic_t rdma_stat_sq_poll;
77857 -extern atomic_t rdma_stat_sq_prod;
77858 +extern atomic_unchecked_t rdma_stat_recv;
77859 +extern atomic_unchecked_t rdma_stat_read;
77860 +extern atomic_unchecked_t rdma_stat_write;
77861 +extern atomic_unchecked_t rdma_stat_sq_starve;
77862 +extern atomic_unchecked_t rdma_stat_rq_starve;
77863 +extern atomic_unchecked_t rdma_stat_rq_poll;
77864 +extern atomic_unchecked_t rdma_stat_rq_prod;
77865 +extern atomic_unchecked_t rdma_stat_sq_poll;
77866 +extern atomic_unchecked_t rdma_stat_sq_prod;
77867
77868 #define RPCRDMA_VERSION 1
77869
77870 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77871 index 8d71d65..f79586e 100644
77872 --- a/include/linux/sunrpc/svcauth.h
77873 +++ b/include/linux/sunrpc/svcauth.h
77874 @@ -120,7 +120,7 @@ struct auth_ops {
77875 int (*release)(struct svc_rqst *rq);
77876 void (*domain_release)(struct auth_domain *);
77877 int (*set_client)(struct svc_rqst *rq);
77878 -};
77879 +} __do_const;
77880
77881 #define SVC_GARBAGE 1
77882 #define SVC_SYSERR 2
77883 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77884 index a5ffd32..0935dea 100644
77885 --- a/include/linux/swiotlb.h
77886 +++ b/include/linux/swiotlb.h
77887 @@ -60,7 +60,8 @@ extern void
77888
77889 extern void
77890 swiotlb_free_coherent(struct device *hwdev, size_t size,
77891 - void *vaddr, dma_addr_t dma_handle);
77892 + void *vaddr, dma_addr_t dma_handle,
77893 + struct dma_attrs *attrs);
77894
77895 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77896 unsigned long offset, size_t size,
77897 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77898 index 7fac04e..de57300 100644
77899 --- a/include/linux/syscalls.h
77900 +++ b/include/linux/syscalls.h
77901 @@ -97,8 +97,14 @@ struct sigaltstack;
77902 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77903
77904 #define __SC_DECL(t, a) t a
77905 +#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))
77906 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77907 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77908 +#define __SC_LONG(t, a) __typeof( \
77909 + __builtin_choose_expr( \
77910 + sizeof(t) > sizeof(int), \
77911 + (t) 0, \
77912 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77913 + )) a
77914 #define __SC_CAST(t, a) (t) a
77915 #define __SC_ARGS(t, a) a
77916 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77917 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
77918 asmlinkage long sys_fsync(unsigned int fd);
77919 asmlinkage long sys_fdatasync(unsigned int fd);
77920 asmlinkage long sys_bdflush(int func, long data);
77921 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77922 - char __user *type, unsigned long flags,
77923 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77924 + const char __user *type, unsigned long flags,
77925 void __user *data);
77926 -asmlinkage long sys_umount(char __user *name, int flags);
77927 -asmlinkage long sys_oldumount(char __user *name);
77928 +asmlinkage long sys_umount(const char __user *name, int flags);
77929 +asmlinkage long sys_oldumount(const char __user *name);
77930 asmlinkage long sys_truncate(const char __user *path, long length);
77931 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77932 asmlinkage long sys_stat(const char __user *filename,
77933 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77934 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77935 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77936 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77937 - struct sockaddr __user *, int);
77938 + struct sockaddr __user *, int) __intentional_overflow(0);
77939 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77940 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77941 unsigned int vlen, unsigned flags);
77942 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77943 index 27b3b0b..e093dd9 100644
77944 --- a/include/linux/syscore_ops.h
77945 +++ b/include/linux/syscore_ops.h
77946 @@ -16,7 +16,7 @@ struct syscore_ops {
77947 int (*suspend)(void);
77948 void (*resume)(void);
77949 void (*shutdown)(void);
77950 -};
77951 +} __do_const;
77952
77953 extern void register_syscore_ops(struct syscore_ops *ops);
77954 extern void unregister_syscore_ops(struct syscore_ops *ops);
77955 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77956 index 14a8ff2..af52bad 100644
77957 --- a/include/linux/sysctl.h
77958 +++ b/include/linux/sysctl.h
77959 @@ -34,13 +34,13 @@ struct ctl_table_root;
77960 struct ctl_table_header;
77961 struct ctl_dir;
77962
77963 -typedef struct ctl_table ctl_table;
77964 -
77965 typedef int proc_handler (struct ctl_table *ctl, int write,
77966 void __user *buffer, size_t *lenp, loff_t *ppos);
77967
77968 extern int proc_dostring(struct ctl_table *, int,
77969 void __user *, size_t *, loff_t *);
77970 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77971 + void __user *, size_t *, loff_t *);
77972 extern int proc_dointvec(struct ctl_table *, int,
77973 void __user *, size_t *, loff_t *);
77974 extern int proc_dointvec_minmax(struct ctl_table *, int,
77975 @@ -115,7 +115,9 @@ struct ctl_table
77976 struct ctl_table_poll *poll;
77977 void *extra1;
77978 void *extra2;
77979 -};
77980 +} __do_const;
77981 +typedef struct ctl_table __no_const ctl_table_no_const;
77982 +typedef struct ctl_table ctl_table;
77983
77984 struct ctl_node {
77985 struct rb_node node;
77986 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77987 index 11baec7..706f99f 100644
77988 --- a/include/linux/sysfs.h
77989 +++ b/include/linux/sysfs.h
77990 @@ -33,7 +33,8 @@ struct attribute {
77991 struct lock_class_key *key;
77992 struct lock_class_key skey;
77993 #endif
77994 -};
77995 +} __do_const;
77996 +typedef struct attribute __no_const attribute_no_const;
77997
77998 /**
77999 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78000 @@ -62,7 +63,8 @@ struct attribute_group {
78001 struct attribute *, int);
78002 struct attribute **attrs;
78003 struct bin_attribute **bin_attrs;
78004 -};
78005 +} __do_const;
78006 +typedef struct attribute_group __no_const attribute_group_no_const;
78007
78008 /**
78009 * Use these macros to make defining attributes easier. See include/linux/device.h
78010 @@ -126,7 +128,8 @@ struct bin_attribute {
78011 char *, loff_t, size_t);
78012 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78013 struct vm_area_struct *vma);
78014 -};
78015 +} __do_const;
78016 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78017
78018 /**
78019 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78020 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78021 index 7faf933..9b85a0c 100644
78022 --- a/include/linux/sysrq.h
78023 +++ b/include/linux/sysrq.h
78024 @@ -16,6 +16,7 @@
78025
78026 #include <linux/errno.h>
78027 #include <linux/types.h>
78028 +#include <linux/compiler.h>
78029
78030 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78031 #define SYSRQ_DEFAULT_ENABLE 1
78032 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78033 char *help_msg;
78034 char *action_msg;
78035 int enable_mask;
78036 -};
78037 +} __do_const;
78038
78039 #ifdef CONFIG_MAGIC_SYSRQ
78040
78041 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78042 index 4ae6f32..425d3e1 100644
78043 --- a/include/linux/thread_info.h
78044 +++ b/include/linux/thread_info.h
78045 @@ -150,6 +150,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78046 #error "no set_restore_sigmask() provided and default one won't work"
78047 #endif
78048
78049 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78050 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78051 +{
78052 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78053 + if (!__builtin_constant_p(n))
78054 +#endif
78055 + __check_object_size(ptr, n, to_user);
78056 +}
78057 +
78058 #endif /* __KERNEL__ */
78059
78060 #endif /* _LINUX_THREAD_INFO_H */
78061 diff --git a/include/linux/tty.h b/include/linux/tty.h
78062 index 64f8646..1515fc7 100644
78063 --- a/include/linux/tty.h
78064 +++ b/include/linux/tty.h
78065 @@ -197,7 +197,7 @@ struct tty_port {
78066 const struct tty_port_operations *ops; /* Port operations */
78067 spinlock_t lock; /* Lock protecting tty field */
78068 int blocked_open; /* Waiting to open */
78069 - int count; /* Usage count */
78070 + atomic_t count; /* Usage count */
78071 wait_queue_head_t open_wait; /* Open waiters */
78072 wait_queue_head_t close_wait; /* Close waiters */
78073 wait_queue_head_t delta_msr_wait; /* Modem status change */
78074 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
78075 struct tty_struct *tty, struct file *filp);
78076 static inline int tty_port_users(struct tty_port *port)
78077 {
78078 - return port->count + port->blocked_open;
78079 + return atomic_read(&port->count) + port->blocked_open;
78080 }
78081
78082 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78083 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78084 index 756a609..b302dd6 100644
78085 --- a/include/linux/tty_driver.h
78086 +++ b/include/linux/tty_driver.h
78087 @@ -285,7 +285,7 @@ struct tty_operations {
78088 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78089 #endif
78090 const struct file_operations *proc_fops;
78091 -};
78092 +} __do_const;
78093
78094 struct tty_driver {
78095 int magic; /* magic number for this structure */
78096 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78097 index f15c898..207b7d1 100644
78098 --- a/include/linux/tty_ldisc.h
78099 +++ b/include/linux/tty_ldisc.h
78100 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
78101
78102 struct module *owner;
78103
78104 - int refcount;
78105 + atomic_t refcount;
78106 };
78107
78108 struct tty_ldisc {
78109 diff --git a/include/linux/types.h b/include/linux/types.h
78110 index 4d118ba..c3ee9bf 100644
78111 --- a/include/linux/types.h
78112 +++ b/include/linux/types.h
78113 @@ -176,10 +176,26 @@ typedef struct {
78114 int counter;
78115 } atomic_t;
78116
78117 +#ifdef CONFIG_PAX_REFCOUNT
78118 +typedef struct {
78119 + int counter;
78120 +} atomic_unchecked_t;
78121 +#else
78122 +typedef atomic_t atomic_unchecked_t;
78123 +#endif
78124 +
78125 #ifdef CONFIG_64BIT
78126 typedef struct {
78127 long counter;
78128 } atomic64_t;
78129 +
78130 +#ifdef CONFIG_PAX_REFCOUNT
78131 +typedef struct {
78132 + long counter;
78133 +} atomic64_unchecked_t;
78134 +#else
78135 +typedef atomic64_t atomic64_unchecked_t;
78136 +#endif
78137 #endif
78138
78139 struct list_head {
78140 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78141 index 5ca0951..ab496a5 100644
78142 --- a/include/linux/uaccess.h
78143 +++ b/include/linux/uaccess.h
78144 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78145 long ret; \
78146 mm_segment_t old_fs = get_fs(); \
78147 \
78148 - set_fs(KERNEL_DS); \
78149 pagefault_disable(); \
78150 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78151 - pagefault_enable(); \
78152 + set_fs(KERNEL_DS); \
78153 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78154 set_fs(old_fs); \
78155 + pagefault_enable(); \
78156 ret; \
78157 })
78158
78159 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78160 index 8e522cbc..aa8572d 100644
78161 --- a/include/linux/uidgid.h
78162 +++ b/include/linux/uidgid.h
78163 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78164
78165 #endif /* CONFIG_USER_NS */
78166
78167 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78168 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78169 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78170 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78171 +
78172 #endif /* _LINUX_UIDGID_H */
78173 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78174 index 99c1b4d..562e6f3 100644
78175 --- a/include/linux/unaligned/access_ok.h
78176 +++ b/include/linux/unaligned/access_ok.h
78177 @@ -4,34 +4,34 @@
78178 #include <linux/kernel.h>
78179 #include <asm/byteorder.h>
78180
78181 -static inline u16 get_unaligned_le16(const void *p)
78182 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78183 {
78184 - return le16_to_cpup((__le16 *)p);
78185 + return le16_to_cpup((const __le16 *)p);
78186 }
78187
78188 -static inline u32 get_unaligned_le32(const void *p)
78189 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78190 {
78191 - return le32_to_cpup((__le32 *)p);
78192 + return le32_to_cpup((const __le32 *)p);
78193 }
78194
78195 -static inline u64 get_unaligned_le64(const void *p)
78196 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78197 {
78198 - return le64_to_cpup((__le64 *)p);
78199 + return le64_to_cpup((const __le64 *)p);
78200 }
78201
78202 -static inline u16 get_unaligned_be16(const void *p)
78203 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78204 {
78205 - return be16_to_cpup((__be16 *)p);
78206 + return be16_to_cpup((const __be16 *)p);
78207 }
78208
78209 -static inline u32 get_unaligned_be32(const void *p)
78210 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78211 {
78212 - return be32_to_cpup((__be32 *)p);
78213 + return be32_to_cpup((const __be32 *)p);
78214 }
78215
78216 -static inline u64 get_unaligned_be64(const void *p)
78217 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78218 {
78219 - return be64_to_cpup((__be64 *)p);
78220 + return be64_to_cpup((const __be64 *)p);
78221 }
78222
78223 static inline void put_unaligned_le16(u16 val, void *p)
78224 diff --git a/include/linux/usb.h b/include/linux/usb.h
78225 index 39cfa0a..d45fa38 100644
78226 --- a/include/linux/usb.h
78227 +++ b/include/linux/usb.h
78228 @@ -563,7 +563,7 @@ struct usb_device {
78229 int maxchild;
78230
78231 u32 quirks;
78232 - atomic_t urbnum;
78233 + atomic_unchecked_t urbnum;
78234
78235 unsigned long active_duration;
78236
78237 @@ -1637,7 +1637,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78238
78239 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78240 __u8 request, __u8 requesttype, __u16 value, __u16 index,
78241 - void *data, __u16 size, int timeout);
78242 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
78243 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
78244 void *data, int len, int *actual_length, int timeout);
78245 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
78246 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
78247 index e452ba6..78f8e80 100644
78248 --- a/include/linux/usb/renesas_usbhs.h
78249 +++ b/include/linux/usb/renesas_usbhs.h
78250 @@ -39,7 +39,7 @@ enum {
78251 */
78252 struct renesas_usbhs_driver_callback {
78253 int (*notify_hotplug)(struct platform_device *pdev);
78254 -};
78255 +} __no_const;
78256
78257 /*
78258 * callback functions for platform
78259 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
78260 index 6f8fbcf..8259001 100644
78261 --- a/include/linux/vermagic.h
78262 +++ b/include/linux/vermagic.h
78263 @@ -25,9 +25,35 @@
78264 #define MODULE_ARCH_VERMAGIC ""
78265 #endif
78266
78267 +#ifdef CONFIG_PAX_REFCOUNT
78268 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
78269 +#else
78270 +#define MODULE_PAX_REFCOUNT ""
78271 +#endif
78272 +
78273 +#ifdef CONSTIFY_PLUGIN
78274 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
78275 +#else
78276 +#define MODULE_CONSTIFY_PLUGIN ""
78277 +#endif
78278 +
78279 +#ifdef STACKLEAK_PLUGIN
78280 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
78281 +#else
78282 +#define MODULE_STACKLEAK_PLUGIN ""
78283 +#endif
78284 +
78285 +#ifdef CONFIG_GRKERNSEC
78286 +#define MODULE_GRSEC "GRSEC "
78287 +#else
78288 +#define MODULE_GRSEC ""
78289 +#endif
78290 +
78291 #define VERMAGIC_STRING \
78292 UTS_RELEASE " " \
78293 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
78294 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
78295 - MODULE_ARCH_VERMAGIC
78296 + MODULE_ARCH_VERMAGIC \
78297 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
78298 + MODULE_GRSEC
78299
78300 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
78301 index 502073a..a7de024 100644
78302 --- a/include/linux/vga_switcheroo.h
78303 +++ b/include/linux/vga_switcheroo.h
78304 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
78305
78306 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
78307
78308 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
78309 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
78310 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
78311 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
78312 #else
78313
78314 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
78315 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
78316
78317 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
78318
78319 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78320 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78321 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78322 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78323
78324 #endif
78325 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
78326 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
78327 index 4b8a891..cc929b4 100644
78328 --- a/include/linux/vmalloc.h
78329 +++ b/include/linux/vmalloc.h
78330 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
78331 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
78332 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
78333 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
78334 +
78335 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
78336 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
78337 +#endif
78338 +
78339 /* bits [20..32] reserved for arch specific ioremap internals */
78340
78341 /*
78342 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
78343 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
78344 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
78345 unsigned long start, unsigned long end, gfp_t gfp_mask,
78346 - pgprot_t prot, int node, const void *caller);
78347 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
78348 extern void vfree(const void *addr);
78349
78350 extern void *vmap(struct page **pages, unsigned int count,
78351 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
78352
78353 /* for /dev/kmem */
78354 extern long vread(char *buf, char *addr, unsigned long count);
78355 -extern long vwrite(char *buf, char *addr, unsigned long count);
78356 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
78357
78358 /*
78359 * Internals. Dont't use..
78360 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
78361 index e4b9480..b96d5ab 100644
78362 --- a/include/linux/vmstat.h
78363 +++ b/include/linux/vmstat.h
78364 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
78365 /*
78366 * Zone based page accounting with per cpu differentials.
78367 */
78368 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78369 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78370
78371 static inline void zone_page_state_add(long x, struct zone *zone,
78372 enum zone_stat_item item)
78373 {
78374 - atomic_long_add(x, &zone->vm_stat[item]);
78375 - atomic_long_add(x, &vm_stat[item]);
78376 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
78377 + atomic_long_add_unchecked(x, &vm_stat[item]);
78378 }
78379
78380 static inline unsigned long global_page_state(enum zone_stat_item item)
78381 {
78382 - long x = atomic_long_read(&vm_stat[item]);
78383 + long x = atomic_long_read_unchecked(&vm_stat[item]);
78384 #ifdef CONFIG_SMP
78385 if (x < 0)
78386 x = 0;
78387 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
78388 static inline unsigned long zone_page_state(struct zone *zone,
78389 enum zone_stat_item item)
78390 {
78391 - long x = atomic_long_read(&zone->vm_stat[item]);
78392 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78393 #ifdef CONFIG_SMP
78394 if (x < 0)
78395 x = 0;
78396 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
78397 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
78398 enum zone_stat_item item)
78399 {
78400 - long x = atomic_long_read(&zone->vm_stat[item]);
78401 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78402
78403 #ifdef CONFIG_SMP
78404 int cpu;
78405 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
78406
78407 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
78408 {
78409 - atomic_long_inc(&zone->vm_stat[item]);
78410 - atomic_long_inc(&vm_stat[item]);
78411 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
78412 + atomic_long_inc_unchecked(&vm_stat[item]);
78413 }
78414
78415 static inline void __inc_zone_page_state(struct page *page,
78416 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
78417
78418 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
78419 {
78420 - atomic_long_dec(&zone->vm_stat[item]);
78421 - atomic_long_dec(&vm_stat[item]);
78422 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
78423 + atomic_long_dec_unchecked(&vm_stat[item]);
78424 }
78425
78426 static inline void __dec_zone_page_state(struct page *page,
78427 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
78428 index 91b0a68..0e9adf6 100644
78429 --- a/include/linux/xattr.h
78430 +++ b/include/linux/xattr.h
78431 @@ -28,7 +28,7 @@ struct xattr_handler {
78432 size_t size, int handler_flags);
78433 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
78434 size_t size, int flags, int handler_flags);
78435 -};
78436 +} __do_const;
78437
78438 struct xattr {
78439 const char *name;
78440 @@ -37,6 +37,9 @@ struct xattr {
78441 };
78442
78443 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
78444 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
78445 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
78446 +#endif
78447 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
78448 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
78449 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
78450 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
78451 index 9c5a6b4..09c9438 100644
78452 --- a/include/linux/zlib.h
78453 +++ b/include/linux/zlib.h
78454 @@ -31,6 +31,7 @@
78455 #define _ZLIB_H
78456
78457 #include <linux/zconf.h>
78458 +#include <linux/compiler.h>
78459
78460 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
78461 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
78462 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
78463
78464 /* basic functions */
78465
78466 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
78467 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
78468 /*
78469 Returns the number of bytes that needs to be allocated for a per-
78470 stream workspace with the specified parameters. A pointer to this
78471 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
78472 index c768c9f..bdcaa5a 100644
78473 --- a/include/media/v4l2-dev.h
78474 +++ b/include/media/v4l2-dev.h
78475 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
78476 int (*mmap) (struct file *, struct vm_area_struct *);
78477 int (*open) (struct file *);
78478 int (*release) (struct file *);
78479 -};
78480 +} __do_const;
78481
78482 /*
78483 * Newer version of video_device, handled by videodev2.c
78484 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
78485 index c9b1593..a572459 100644
78486 --- a/include/media/v4l2-device.h
78487 +++ b/include/media/v4l2-device.h
78488 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
78489 this function returns 0. If the name ends with a digit (e.g. cx18),
78490 then the name will be set to cx18-0 since cx180 looks really odd. */
78491 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
78492 - atomic_t *instance);
78493 + atomic_unchecked_t *instance);
78494
78495 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
78496 Since the parent disappears this ensures that v4l2_dev doesn't have an
78497 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
78498 index 9a36d92..0aafe2a 100644
78499 --- a/include/net/9p/transport.h
78500 +++ b/include/net/9p/transport.h
78501 @@ -60,7 +60,7 @@ struct p9_trans_module {
78502 int (*cancel) (struct p9_client *, struct p9_req_t *req);
78503 int (*zc_request)(struct p9_client *, struct p9_req_t *,
78504 char *, char *, int , int, int, int);
78505 -};
78506 +} __do_const;
78507
78508 void v9fs_register_trans(struct p9_trans_module *m);
78509 void v9fs_unregister_trans(struct p9_trans_module *m);
78510 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
78511 index 1a966af..2767cf6 100644
78512 --- a/include/net/bluetooth/l2cap.h
78513 +++ b/include/net/bluetooth/l2cap.h
78514 @@ -551,7 +551,7 @@ struct l2cap_ops {
78515 void (*defer) (struct l2cap_chan *chan);
78516 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
78517 unsigned long len, int nb);
78518 -};
78519 +} __do_const;
78520
78521 struct l2cap_conn {
78522 struct hci_conn *hcon;
78523 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
78524 index f2ae33d..c457cf0 100644
78525 --- a/include/net/caif/cfctrl.h
78526 +++ b/include/net/caif/cfctrl.h
78527 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
78528 void (*radioset_rsp)(void);
78529 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
78530 struct cflayer *client_layer);
78531 -};
78532 +} __no_const;
78533
78534 /* Link Setup Parameters for CAIF-Links. */
78535 struct cfctrl_link_param {
78536 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
78537 struct cfctrl {
78538 struct cfsrvl serv;
78539 struct cfctrl_rsp res;
78540 - atomic_t req_seq_no;
78541 - atomic_t rsp_seq_no;
78542 + atomic_unchecked_t req_seq_no;
78543 + atomic_unchecked_t rsp_seq_no;
78544 struct list_head list;
78545 /* Protects from simultaneous access to first_req list */
78546 spinlock_t info_list_lock;
78547 diff --git a/include/net/flow.h b/include/net/flow.h
78548 index 628e11b..4c475df 100644
78549 --- a/include/net/flow.h
78550 +++ b/include/net/flow.h
78551 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
78552
78553 extern void flow_cache_flush(void);
78554 extern void flow_cache_flush_deferred(void);
78555 -extern atomic_t flow_cache_genid;
78556 +extern atomic_unchecked_t flow_cache_genid;
78557
78558 #endif
78559 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
78560 index 8e0b6c8..73cf605 100644
78561 --- a/include/net/genetlink.h
78562 +++ b/include/net/genetlink.h
78563 @@ -120,7 +120,7 @@ struct genl_ops {
78564 struct netlink_callback *cb);
78565 int (*done)(struct netlink_callback *cb);
78566 struct list_head ops_list;
78567 -};
78568 +} __do_const;
78569
78570 extern int __genl_register_family(struct genl_family *family);
78571
78572 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
78573 index 734d9b5..48a9a4b 100644
78574 --- a/include/net/gro_cells.h
78575 +++ b/include/net/gro_cells.h
78576 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
78577 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
78578
78579 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
78580 - atomic_long_inc(&dev->rx_dropped);
78581 + atomic_long_inc_unchecked(&dev->rx_dropped);
78582 kfree_skb(skb);
78583 return;
78584 }
78585 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
78586 index de2c785..0588a6b 100644
78587 --- a/include/net/inet_connection_sock.h
78588 +++ b/include/net/inet_connection_sock.h
78589 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
78590 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
78591 int (*bind_conflict)(const struct sock *sk,
78592 const struct inet_bind_bucket *tb, bool relax);
78593 -};
78594 +} __do_const;
78595
78596 /** inet_connection_sock - INET connection oriented sock
78597 *
78598 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
78599 index 53f464d..0bd0b49 100644
78600 --- a/include/net/inetpeer.h
78601 +++ b/include/net/inetpeer.h
78602 @@ -47,8 +47,8 @@ struct inet_peer {
78603 */
78604 union {
78605 struct {
78606 - atomic_t rid; /* Frag reception counter */
78607 - atomic_t ip_id_count; /* IP ID for the next packet */
78608 + atomic_unchecked_t rid; /* Frag reception counter */
78609 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
78610 };
78611 struct rcu_head rcu;
78612 struct inet_peer *gc_next;
78613 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
78614 /* can be called with or without local BH being disabled */
78615 static inline int inet_getid(struct inet_peer *p, int more)
78616 {
78617 - int old, new;
78618 + int id;
78619 more++;
78620 inet_peer_refcheck(p);
78621 - do {
78622 - old = atomic_read(&p->ip_id_count);
78623 - new = old + more;
78624 - if (!new)
78625 - new = 1;
78626 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
78627 - return new;
78628 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
78629 + if (!id)
78630 + id = atomic_inc_return_unchecked(&p->ip_id_count);
78631 + return id;
78632 }
78633
78634 #endif /* _NET_INETPEER_H */
78635 diff --git a/include/net/ip.h b/include/net/ip.h
78636 index 5e52688..f181e95 100644
78637 --- a/include/net/ip.h
78638 +++ b/include/net/ip.h
78639 @@ -212,7 +212,7 @@ extern struct local_ports {
78640 } sysctl_local_ports;
78641 extern void inet_get_local_port_range(int *low, int *high);
78642
78643 -extern unsigned long *sysctl_local_reserved_ports;
78644 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
78645 static inline int inet_is_reserved_local_port(int port)
78646 {
78647 return test_bit(port, sysctl_local_reserved_ports);
78648 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
78649 index cbf2be3..3683f6d 100644
78650 --- a/include/net/ip_fib.h
78651 +++ b/include/net/ip_fib.h
78652 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
78653
78654 #define FIB_RES_SADDR(net, res) \
78655 ((FIB_RES_NH(res).nh_saddr_genid == \
78656 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
78657 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
78658 FIB_RES_NH(res).nh_saddr : \
78659 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
78660 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
78661 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
78662 index 9c4d37e..eed6d41 100644
78663 --- a/include/net/ip_vs.h
78664 +++ b/include/net/ip_vs.h
78665 @@ -588,7 +588,7 @@ struct ip_vs_conn {
78666 struct ip_vs_conn *control; /* Master control connection */
78667 atomic_t n_control; /* Number of controlled ones */
78668 struct ip_vs_dest *dest; /* real server */
78669 - atomic_t in_pkts; /* incoming packet counter */
78670 + atomic_unchecked_t in_pkts; /* incoming packet counter */
78671
78672 /* packet transmitter for different forwarding methods. If it
78673 mangles the packet, it must return NF_DROP or better NF_STOLEN,
78674 @@ -735,7 +735,7 @@ struct ip_vs_dest {
78675 __be16 port; /* port number of the server */
78676 union nf_inet_addr addr; /* IP address of the server */
78677 volatile unsigned int flags; /* dest status flags */
78678 - atomic_t conn_flags; /* flags to copy to conn */
78679 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
78680 atomic_t weight; /* server weight */
78681
78682 atomic_t refcnt; /* reference counter */
78683 @@ -990,11 +990,11 @@ struct netns_ipvs {
78684 /* ip_vs_lblc */
78685 int sysctl_lblc_expiration;
78686 struct ctl_table_header *lblc_ctl_header;
78687 - struct ctl_table *lblc_ctl_table;
78688 + ctl_table_no_const *lblc_ctl_table;
78689 /* ip_vs_lblcr */
78690 int sysctl_lblcr_expiration;
78691 struct ctl_table_header *lblcr_ctl_header;
78692 - struct ctl_table *lblcr_ctl_table;
78693 + ctl_table_no_const *lblcr_ctl_table;
78694 /* ip_vs_est */
78695 struct list_head est_list; /* estimator list */
78696 spinlock_t est_lock;
78697 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
78698 index 80ffde3..968b0f4 100644
78699 --- a/include/net/irda/ircomm_tty.h
78700 +++ b/include/net/irda/ircomm_tty.h
78701 @@ -35,6 +35,7 @@
78702 #include <linux/termios.h>
78703 #include <linux/timer.h>
78704 #include <linux/tty.h> /* struct tty_struct */
78705 +#include <asm/local.h>
78706
78707 #include <net/irda/irias_object.h>
78708 #include <net/irda/ircomm_core.h>
78709 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
78710 index 714cc9a..ea05f3e 100644
78711 --- a/include/net/iucv/af_iucv.h
78712 +++ b/include/net/iucv/af_iucv.h
78713 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
78714 struct iucv_sock_list {
78715 struct hlist_head head;
78716 rwlock_t lock;
78717 - atomic_t autobind_name;
78718 + atomic_unchecked_t autobind_name;
78719 };
78720
78721 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
78722 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
78723 index df83f69..9b640b8 100644
78724 --- a/include/net/llc_c_ac.h
78725 +++ b/include/net/llc_c_ac.h
78726 @@ -87,7 +87,7 @@
78727 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
78728 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
78729
78730 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78731 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78732
78733 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
78734 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
78735 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
78736 index 6ca3113..f8026dd 100644
78737 --- a/include/net/llc_c_ev.h
78738 +++ b/include/net/llc_c_ev.h
78739 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
78740 return (struct llc_conn_state_ev *)skb->cb;
78741 }
78742
78743 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78744 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78745 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78746 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78747
78748 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
78749 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
78750 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
78751 index 0e79cfb..f46db31 100644
78752 --- a/include/net/llc_c_st.h
78753 +++ b/include/net/llc_c_st.h
78754 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
78755 u8 next_state;
78756 llc_conn_ev_qfyr_t *ev_qualifiers;
78757 llc_conn_action_t *ev_actions;
78758 -};
78759 +} __do_const;
78760
78761 struct llc_conn_state {
78762 u8 current_state;
78763 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
78764 index 37a3bbd..55a4241 100644
78765 --- a/include/net/llc_s_ac.h
78766 +++ b/include/net/llc_s_ac.h
78767 @@ -23,7 +23,7 @@
78768 #define SAP_ACT_TEST_IND 9
78769
78770 /* All action functions must look like this */
78771 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78772 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78773
78774 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
78775 struct sk_buff *skb);
78776 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
78777 index 567c681..cd73ac0 100644
78778 --- a/include/net/llc_s_st.h
78779 +++ b/include/net/llc_s_st.h
78780 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
78781 llc_sap_ev_t ev;
78782 u8 next_state;
78783 llc_sap_action_t *ev_actions;
78784 -};
78785 +} __do_const;
78786
78787 struct llc_sap_state {
78788 u8 curr_state;
78789 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
78790 index cc6035f..a8406fc 100644
78791 --- a/include/net/mac80211.h
78792 +++ b/include/net/mac80211.h
78793 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
78794 void (*add_sta_debugfs)(void *priv, void *priv_sta,
78795 struct dentry *dir);
78796 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
78797 -};
78798 +} __do_const;
78799
78800 static inline int rate_supported(struct ieee80211_sta *sta,
78801 enum ieee80211_band band,
78802 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
78803 index 536501a..7c6193c 100644
78804 --- a/include/net/neighbour.h
78805 +++ b/include/net/neighbour.h
78806 @@ -123,7 +123,7 @@ struct neigh_ops {
78807 void (*error_report)(struct neighbour *, struct sk_buff *);
78808 int (*output)(struct neighbour *, struct sk_buff *);
78809 int (*connected_output)(struct neighbour *, struct sk_buff *);
78810 -};
78811 +} __do_const;
78812
78813 struct pneigh_entry {
78814 struct pneigh_entry *next;
78815 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
78816 index 9d22f08..980fbf8 100644
78817 --- a/include/net/net_namespace.h
78818 +++ b/include/net/net_namespace.h
78819 @@ -120,7 +120,7 @@ struct net {
78820 struct netns_ipvs *ipvs;
78821 #endif
78822 struct sock *diag_nlsk;
78823 - atomic_t fnhe_genid;
78824 + atomic_unchecked_t fnhe_genid;
78825 };
78826
78827 /*
78828 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
78829 #define __net_init __init
78830 #define __net_exit __exit_refok
78831 #define __net_initdata __initdata
78832 +#ifdef CONSTIFY_PLUGIN
78833 #define __net_initconst __initconst
78834 +#else
78835 +#define __net_initconst __initdata
78836 +#endif
78837 #endif
78838
78839 struct pernet_operations {
78840 @@ -287,7 +291,7 @@ struct pernet_operations {
78841 void (*exit_batch)(struct list_head *net_exit_list);
78842 int *id;
78843 size_t size;
78844 -};
78845 +} __do_const;
78846
78847 /*
78848 * Use these carefully. If you implement a network device and it
78849 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
78850
78851 static inline int rt_genid_ipv4(struct net *net)
78852 {
78853 - return atomic_read(&net->ipv4.rt_genid);
78854 + return atomic_read_unchecked(&net->ipv4.rt_genid);
78855 }
78856
78857 static inline void rt_genid_bump_ipv4(struct net *net)
78858 {
78859 - atomic_inc(&net->ipv4.rt_genid);
78860 + atomic_inc_unchecked(&net->ipv4.rt_genid);
78861 }
78862
78863 #if IS_ENABLED(CONFIG_IPV6)
78864 static inline int rt_genid_ipv6(struct net *net)
78865 {
78866 - return atomic_read(&net->ipv6.rt_genid);
78867 + return atomic_read_unchecked(&net->ipv6.rt_genid);
78868 }
78869
78870 static inline void rt_genid_bump_ipv6(struct net *net)
78871 {
78872 - atomic_inc(&net->ipv6.rt_genid);
78873 + atomic_inc_unchecked(&net->ipv6.rt_genid);
78874 }
78875 #else
78876 static inline int rt_genid_ipv6(struct net *net)
78877 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
78878
78879 static inline int fnhe_genid(struct net *net)
78880 {
78881 - return atomic_read(&net->fnhe_genid);
78882 + return atomic_read_unchecked(&net->fnhe_genid);
78883 }
78884
78885 static inline void fnhe_genid_bump(struct net *net)
78886 {
78887 - atomic_inc(&net->fnhe_genid);
78888 + atomic_inc_unchecked(&net->fnhe_genid);
78889 }
78890
78891 #endif /* __NET_NET_NAMESPACE_H */
78892 diff --git a/include/net/netdma.h b/include/net/netdma.h
78893 index 8ba8ce2..99b7fff 100644
78894 --- a/include/net/netdma.h
78895 +++ b/include/net/netdma.h
78896 @@ -24,7 +24,7 @@
78897 #include <linux/dmaengine.h>
78898 #include <linux/skbuff.h>
78899
78900 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78901 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78902 struct sk_buff *skb, int offset, struct iovec *to,
78903 size_t len, struct dma_pinned_list *pinned_list);
78904
78905 diff --git a/include/net/netlink.h b/include/net/netlink.h
78906 index 9690b0f..87aded7 100644
78907 --- a/include/net/netlink.h
78908 +++ b/include/net/netlink.h
78909 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78910 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78911 {
78912 if (mark)
78913 - skb_trim(skb, (unsigned char *) mark - skb->data);
78914 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78915 }
78916
78917 /**
78918 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78919 index c9c0c53..53f24c3 100644
78920 --- a/include/net/netns/conntrack.h
78921 +++ b/include/net/netns/conntrack.h
78922 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78923 struct nf_proto_net {
78924 #ifdef CONFIG_SYSCTL
78925 struct ctl_table_header *ctl_table_header;
78926 - struct ctl_table *ctl_table;
78927 + ctl_table_no_const *ctl_table;
78928 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78929 struct ctl_table_header *ctl_compat_header;
78930 - struct ctl_table *ctl_compat_table;
78931 + ctl_table_no_const *ctl_compat_table;
78932 #endif
78933 #endif
78934 unsigned int users;
78935 @@ -58,7 +58,7 @@ struct nf_ip_net {
78936 struct nf_icmp_net icmpv6;
78937 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78938 struct ctl_table_header *ctl_table_header;
78939 - struct ctl_table *ctl_table;
78940 + ctl_table_no_const *ctl_table;
78941 #endif
78942 };
78943
78944 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78945 index bf2ec22..5e7f9d9 100644
78946 --- a/include/net/netns/ipv4.h
78947 +++ b/include/net/netns/ipv4.h
78948 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78949 kgid_t sysctl_ping_group_range[2];
78950 long sysctl_tcp_mem[3];
78951
78952 - atomic_t dev_addr_genid;
78953 + atomic_unchecked_t dev_addr_genid;
78954
78955 #ifdef CONFIG_IP_MROUTE
78956 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78957 @@ -77,6 +77,6 @@ struct netns_ipv4 {
78958 struct fib_rules_ops *mr_rules_ops;
78959 #endif
78960 #endif
78961 - atomic_t rt_genid;
78962 + atomic_unchecked_t rt_genid;
78963 };
78964 #endif
78965 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78966 index 0fb2401..477d81c 100644
78967 --- a/include/net/netns/ipv6.h
78968 +++ b/include/net/netns/ipv6.h
78969 @@ -71,8 +71,8 @@ struct netns_ipv6 {
78970 struct fib_rules_ops *mr6_rules_ops;
78971 #endif
78972 #endif
78973 - atomic_t dev_addr_genid;
78974 - atomic_t rt_genid;
78975 + atomic_unchecked_t dev_addr_genid;
78976 + atomic_unchecked_t rt_genid;
78977 };
78978
78979 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78980 diff --git a/include/net/ping.h b/include/net/ping.h
78981 index 5db0224..0d65365 100644
78982 --- a/include/net/ping.h
78983 +++ b/include/net/ping.h
78984 @@ -55,7 +55,7 @@ struct ping_iter_state {
78985 extern struct proto ping_prot;
78986 extern struct ping_table ping_table;
78987 #if IS_ENABLED(CONFIG_IPV6)
78988 -extern struct pingv6_ops pingv6_ops;
78989 +extern struct pingv6_ops *pingv6_ops;
78990 #endif
78991
78992 struct pingfakehdr {
78993 diff --git a/include/net/protocol.h b/include/net/protocol.h
78994 index 047c047..b9dad15 100644
78995 --- a/include/net/protocol.h
78996 +++ b/include/net/protocol.h
78997 @@ -44,7 +44,7 @@ struct net_protocol {
78998 void (*err_handler)(struct sk_buff *skb, u32 info);
78999 unsigned int no_policy:1,
79000 netns_ok:1;
79001 -};
79002 +} __do_const;
79003
79004 #if IS_ENABLED(CONFIG_IPV6)
79005 struct inet6_protocol {
79006 @@ -57,7 +57,7 @@ struct inet6_protocol {
79007 u8 type, u8 code, int offset,
79008 __be32 info);
79009 unsigned int flags; /* INET6_PROTO_xxx */
79010 -};
79011 +} __do_const;
79012
79013 #define INET6_PROTO_NOPOLICY 0x1
79014 #define INET6_PROTO_FINAL 0x2
79015 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79016 index 7026648..584cc8c 100644
79017 --- a/include/net/rtnetlink.h
79018 +++ b/include/net/rtnetlink.h
79019 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79020 const struct net_device *dev);
79021 unsigned int (*get_num_tx_queues)(void);
79022 unsigned int (*get_num_rx_queues)(void);
79023 -};
79024 +} __do_const;
79025
79026 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79027 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79028 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79029 index 4ef75af..5aa073a 100644
79030 --- a/include/net/sctp/sm.h
79031 +++ b/include/net/sctp/sm.h
79032 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79033 typedef struct {
79034 sctp_state_fn_t *fn;
79035 const char *name;
79036 -} sctp_sm_table_entry_t;
79037 +} __do_const sctp_sm_table_entry_t;
79038
79039 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79040 * currently in use.
79041 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79042 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79043
79044 /* Extern declarations for major data structures. */
79045 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79046 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79047
79048
79049 /* Get the size of a DATA chunk payload. */
79050 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79051 index 2174d8d..71d5257 100644
79052 --- a/include/net/sctp/structs.h
79053 +++ b/include/net/sctp/structs.h
79054 @@ -508,7 +508,7 @@ struct sctp_pf {
79055 struct sctp_association *asoc);
79056 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79057 struct sctp_af *af;
79058 -};
79059 +} __do_const;
79060
79061
79062 /* Structure to track chunk fragments that have been acked, but peer
79063 diff --git a/include/net/sock.h b/include/net/sock.h
79064 index 808cbc2..f6f6ac3 100644
79065 --- a/include/net/sock.h
79066 +++ b/include/net/sock.h
79067 @@ -332,7 +332,7 @@ struct sock {
79068 unsigned int sk_napi_id;
79069 unsigned int sk_ll_usec;
79070 #endif
79071 - atomic_t sk_drops;
79072 + atomic_unchecked_t sk_drops;
79073 int sk_rcvbuf;
79074
79075 struct sk_filter __rcu *sk_filter;
79076 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79077 }
79078
79079 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79080 - char __user *from, char *to,
79081 + char __user *from, unsigned char *to,
79082 int copy, int offset)
79083 {
79084 if (skb->ip_summed == CHECKSUM_NONE) {
79085 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79086 }
79087 }
79088
79089 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79090 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79091
79092 /**
79093 * sk_page_frag - return an appropriate page_frag
79094 diff --git a/include/net/tcp.h b/include/net/tcp.h
79095 index b1aa324..b8530ea 100644
79096 --- a/include/net/tcp.h
79097 +++ b/include/net/tcp.h
79098 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79099 extern void tcp_xmit_retransmit_queue(struct sock *);
79100 extern void tcp_simple_retransmit(struct sock *);
79101 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79102 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79103 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79104
79105 extern void tcp_send_probe0(struct sock *);
79106 extern void tcp_send_partial(struct sock *);
79107 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
79108 struct inet6_skb_parm h6;
79109 #endif
79110 } header; /* For incoming frames */
79111 - __u32 seq; /* Starting sequence number */
79112 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79113 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79114 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79115 __u32 when; /* used to compute rtt's */
79116 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79117
79118 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
79119
79120 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79121 /* 1 byte hole */
79122 - __u32 ack_seq; /* Sequence number ACK'd */
79123 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79124 };
79125
79126 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79127 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79128 index e253bf0..2278b4b 100644
79129 --- a/include/net/xfrm.h
79130 +++ b/include/net/xfrm.h
79131 @@ -287,7 +287,6 @@ struct xfrm_dst;
79132 struct xfrm_policy_afinfo {
79133 unsigned short family;
79134 struct dst_ops *dst_ops;
79135 - void (*garbage_collect)(struct net *net);
79136 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
79137 const xfrm_address_t *saddr,
79138 const xfrm_address_t *daddr);
79139 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
79140 struct net_device *dev,
79141 const struct flowi *fl);
79142 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79143 -};
79144 +} __do_const;
79145
79146 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79147 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79148 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
79149 int (*transport_finish)(struct sk_buff *skb,
79150 int async);
79151 void (*local_error)(struct sk_buff *skb, u32 mtu);
79152 -};
79153 +} __do_const;
79154
79155 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79156 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79157 @@ -427,7 +426,7 @@ struct xfrm_mode {
79158 struct module *owner;
79159 unsigned int encap;
79160 int flags;
79161 -};
79162 +} __do_const;
79163
79164 /* Flags for xfrm_mode. */
79165 enum {
79166 @@ -524,7 +523,7 @@ struct xfrm_policy {
79167 struct timer_list timer;
79168
79169 struct flow_cache_object flo;
79170 - atomic_t genid;
79171 + atomic_unchecked_t genid;
79172 u32 priority;
79173 u32 index;
79174 struct xfrm_mark mark;
79175 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
79176 }
79177
79178 extern void xfrm_garbage_collect(struct net *net);
79179 +extern void xfrm_garbage_collect_deferred(struct net *net);
79180
79181 #else
79182
79183 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
79184 static inline void xfrm_garbage_collect(struct net *net)
79185 {
79186 }
79187 +static inline void xfrm_garbage_collect_deferred(struct net *net)
79188 +{
79189 +}
79190 #endif
79191
79192 static __inline__
79193 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79194 index 1017e0b..227aa4d 100644
79195 --- a/include/rdma/iw_cm.h
79196 +++ b/include/rdma/iw_cm.h
79197 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79198 int backlog);
79199
79200 int (*destroy_listen)(struct iw_cm_id *cm_id);
79201 -};
79202 +} __no_const;
79203
79204 /**
79205 * iw_create_cm_id - Create an IW CM identifier.
79206 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79207 index e1379b4..67eafbe 100644
79208 --- a/include/scsi/libfc.h
79209 +++ b/include/scsi/libfc.h
79210 @@ -762,6 +762,7 @@ struct libfc_function_template {
79211 */
79212 void (*disc_stop_final) (struct fc_lport *);
79213 };
79214 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79215
79216 /**
79217 * struct fc_disc - Discovery context
79218 @@ -866,7 +867,7 @@ struct fc_lport {
79219 struct fc_vport *vport;
79220
79221 /* Operational Information */
79222 - struct libfc_function_template tt;
79223 + libfc_function_template_no_const tt;
79224 u8 link_up;
79225 u8 qfull;
79226 enum fc_lport_state state;
79227 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79228 index d65fbec..f80fef2 100644
79229 --- a/include/scsi/scsi_device.h
79230 +++ b/include/scsi/scsi_device.h
79231 @@ -180,9 +180,9 @@ struct scsi_device {
79232 unsigned int max_device_blocked; /* what device_blocked counts down from */
79233 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79234
79235 - atomic_t iorequest_cnt;
79236 - atomic_t iodone_cnt;
79237 - atomic_t ioerr_cnt;
79238 + atomic_unchecked_t iorequest_cnt;
79239 + atomic_unchecked_t iodone_cnt;
79240 + atomic_unchecked_t ioerr_cnt;
79241
79242 struct device sdev_gendev,
79243 sdev_dev;
79244 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
79245 index b797e8f..8e2c3aa 100644
79246 --- a/include/scsi/scsi_transport_fc.h
79247 +++ b/include/scsi/scsi_transport_fc.h
79248 @@ -751,7 +751,8 @@ struct fc_function_template {
79249 unsigned long show_host_system_hostname:1;
79250
79251 unsigned long disable_target_scan:1;
79252 -};
79253 +} __do_const;
79254 +typedef struct fc_function_template __no_const fc_function_template_no_const;
79255
79256
79257 /**
79258 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
79259 index ae6c3b8..fd748ac 100644
79260 --- a/include/sound/compress_driver.h
79261 +++ b/include/sound/compress_driver.h
79262 @@ -128,7 +128,7 @@ struct snd_compr_ops {
79263 struct snd_compr_caps *caps);
79264 int (*get_codec_caps) (struct snd_compr_stream *stream,
79265 struct snd_compr_codec_caps *codec);
79266 -};
79267 +} __no_const;
79268
79269 /**
79270 * struct snd_compr: Compressed device
79271 diff --git a/include/sound/soc.h b/include/sound/soc.h
79272 index d22cb0a..c6ba150 100644
79273 --- a/include/sound/soc.h
79274 +++ b/include/sound/soc.h
79275 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
79276 /* probe ordering - for components with runtime dependencies */
79277 int probe_order;
79278 int remove_order;
79279 -};
79280 +} __do_const;
79281
79282 /* SoC platform interface */
79283 struct snd_soc_platform_driver {
79284 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
79285 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
79286 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
79287 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
79288 -};
79289 +} __do_const;
79290
79291 struct snd_soc_platform {
79292 const char *name;
79293 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
79294 index 5bdb8b7..bb1096c 100644
79295 --- a/include/target/target_core_base.h
79296 +++ b/include/target/target_core_base.h
79297 @@ -663,7 +663,7 @@ struct se_device {
79298 spinlock_t stats_lock;
79299 /* Active commands on this virtual SE device */
79300 atomic_t simple_cmds;
79301 - atomic_t dev_ordered_id;
79302 + atomic_unchecked_t dev_ordered_id;
79303 atomic_t dev_ordered_sync;
79304 atomic_t dev_qf_count;
79305 int export_count;
79306 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
79307 new file mode 100644
79308 index 0000000..fb634b7
79309 --- /dev/null
79310 +++ b/include/trace/events/fs.h
79311 @@ -0,0 +1,53 @@
79312 +#undef TRACE_SYSTEM
79313 +#define TRACE_SYSTEM fs
79314 +
79315 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
79316 +#define _TRACE_FS_H
79317 +
79318 +#include <linux/fs.h>
79319 +#include <linux/tracepoint.h>
79320 +
79321 +TRACE_EVENT(do_sys_open,
79322 +
79323 + TP_PROTO(const char *filename, int flags, int mode),
79324 +
79325 + TP_ARGS(filename, flags, mode),
79326 +
79327 + TP_STRUCT__entry(
79328 + __string( filename, filename )
79329 + __field( int, flags )
79330 + __field( int, mode )
79331 + ),
79332 +
79333 + TP_fast_assign(
79334 + __assign_str(filename, filename);
79335 + __entry->flags = flags;
79336 + __entry->mode = mode;
79337 + ),
79338 +
79339 + TP_printk("\"%s\" %x %o",
79340 + __get_str(filename), __entry->flags, __entry->mode)
79341 +);
79342 +
79343 +TRACE_EVENT(open_exec,
79344 +
79345 + TP_PROTO(const char *filename),
79346 +
79347 + TP_ARGS(filename),
79348 +
79349 + TP_STRUCT__entry(
79350 + __string( filename, filename )
79351 + ),
79352 +
79353 + TP_fast_assign(
79354 + __assign_str(filename, filename);
79355 + ),
79356 +
79357 + TP_printk("\"%s\"",
79358 + __get_str(filename))
79359 +);
79360 +
79361 +#endif /* _TRACE_FS_H */
79362 +
79363 +/* This part must be outside protection */
79364 +#include <trace/define_trace.h>
79365 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
79366 index 1c09820..7f5ec79 100644
79367 --- a/include/trace/events/irq.h
79368 +++ b/include/trace/events/irq.h
79369 @@ -36,7 +36,7 @@ struct softirq_action;
79370 */
79371 TRACE_EVENT(irq_handler_entry,
79372
79373 - TP_PROTO(int irq, struct irqaction *action),
79374 + TP_PROTO(int irq, const struct irqaction *action),
79375
79376 TP_ARGS(irq, action),
79377
79378 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
79379 */
79380 TRACE_EVENT(irq_handler_exit,
79381
79382 - TP_PROTO(int irq, struct irqaction *action, int ret),
79383 + TP_PROTO(int irq, const struct irqaction *action, int ret),
79384
79385 TP_ARGS(irq, action, ret),
79386
79387 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
79388 index 7caf44c..23c6f27 100644
79389 --- a/include/uapi/linux/a.out.h
79390 +++ b/include/uapi/linux/a.out.h
79391 @@ -39,6 +39,14 @@ enum machine_type {
79392 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
79393 };
79394
79395 +/* Constants for the N_FLAGS field */
79396 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79397 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
79398 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
79399 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
79400 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79401 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79402 +
79403 #if !defined (N_MAGIC)
79404 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
79405 #endif
79406 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
79407 index d876736..ccce5c0 100644
79408 --- a/include/uapi/linux/byteorder/little_endian.h
79409 +++ b/include/uapi/linux/byteorder/little_endian.h
79410 @@ -42,51 +42,51 @@
79411
79412 static inline __le64 __cpu_to_le64p(const __u64 *p)
79413 {
79414 - return (__force __le64)*p;
79415 + return (__force const __le64)*p;
79416 }
79417 -static inline __u64 __le64_to_cpup(const __le64 *p)
79418 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
79419 {
79420 - return (__force __u64)*p;
79421 + return (__force const __u64)*p;
79422 }
79423 static inline __le32 __cpu_to_le32p(const __u32 *p)
79424 {
79425 - return (__force __le32)*p;
79426 + return (__force const __le32)*p;
79427 }
79428 static inline __u32 __le32_to_cpup(const __le32 *p)
79429 {
79430 - return (__force __u32)*p;
79431 + return (__force const __u32)*p;
79432 }
79433 static inline __le16 __cpu_to_le16p(const __u16 *p)
79434 {
79435 - return (__force __le16)*p;
79436 + return (__force const __le16)*p;
79437 }
79438 static inline __u16 __le16_to_cpup(const __le16 *p)
79439 {
79440 - return (__force __u16)*p;
79441 + return (__force const __u16)*p;
79442 }
79443 static inline __be64 __cpu_to_be64p(const __u64 *p)
79444 {
79445 - return (__force __be64)__swab64p(p);
79446 + return (__force const __be64)__swab64p(p);
79447 }
79448 static inline __u64 __be64_to_cpup(const __be64 *p)
79449 {
79450 - return __swab64p((__u64 *)p);
79451 + return __swab64p((const __u64 *)p);
79452 }
79453 static inline __be32 __cpu_to_be32p(const __u32 *p)
79454 {
79455 - return (__force __be32)__swab32p(p);
79456 + return (__force const __be32)__swab32p(p);
79457 }
79458 -static inline __u32 __be32_to_cpup(const __be32 *p)
79459 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
79460 {
79461 - return __swab32p((__u32 *)p);
79462 + return __swab32p((const __u32 *)p);
79463 }
79464 static inline __be16 __cpu_to_be16p(const __u16 *p)
79465 {
79466 - return (__force __be16)__swab16p(p);
79467 + return (__force const __be16)__swab16p(p);
79468 }
79469 static inline __u16 __be16_to_cpup(const __be16 *p)
79470 {
79471 - return __swab16p((__u16 *)p);
79472 + return __swab16p((const __u16 *)p);
79473 }
79474 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
79475 #define __le64_to_cpus(x) do { (void)(x); } while (0)
79476 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
79477 index ef6103b..d4e65dd 100644
79478 --- a/include/uapi/linux/elf.h
79479 +++ b/include/uapi/linux/elf.h
79480 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
79481 #define PT_GNU_EH_FRAME 0x6474e550
79482
79483 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
79484 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
79485 +
79486 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
79487 +
79488 +/* Constants for the e_flags field */
79489 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79490 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
79491 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
79492 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
79493 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79494 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79495
79496 /*
79497 * Extended Numbering
79498 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
79499 #define DT_DEBUG 21
79500 #define DT_TEXTREL 22
79501 #define DT_JMPREL 23
79502 +#define DT_FLAGS 30
79503 + #define DF_TEXTREL 0x00000004
79504 #define DT_ENCODING 32
79505 #define OLD_DT_LOOS 0x60000000
79506 #define DT_LOOS 0x6000000d
79507 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
79508 #define PF_W 0x2
79509 #define PF_X 0x1
79510
79511 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
79512 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
79513 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
79514 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
79515 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
79516 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
79517 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
79518 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
79519 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
79520 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
79521 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
79522 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
79523 +
79524 typedef struct elf32_phdr{
79525 Elf32_Word p_type;
79526 Elf32_Off p_offset;
79527 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
79528 #define EI_OSABI 7
79529 #define EI_PAD 8
79530
79531 +#define EI_PAX 14
79532 +
79533 #define ELFMAG0 0x7f /* EI_MAG */
79534 #define ELFMAG1 'E'
79535 #define ELFMAG2 'L'
79536 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
79537 index aa169c4..6a2771d 100644
79538 --- a/include/uapi/linux/personality.h
79539 +++ b/include/uapi/linux/personality.h
79540 @@ -30,6 +30,7 @@ enum {
79541 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
79542 ADDR_NO_RANDOMIZE | \
79543 ADDR_COMPAT_LAYOUT | \
79544 + ADDR_LIMIT_3GB | \
79545 MMAP_PAGE_ZERO)
79546
79547 /*
79548 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
79549 index 7530e74..e714828 100644
79550 --- a/include/uapi/linux/screen_info.h
79551 +++ b/include/uapi/linux/screen_info.h
79552 @@ -43,7 +43,8 @@ struct screen_info {
79553 __u16 pages; /* 0x32 */
79554 __u16 vesa_attributes; /* 0x34 */
79555 __u32 capabilities; /* 0x36 */
79556 - __u8 _reserved[6]; /* 0x3a */
79557 + __u16 vesapm_size; /* 0x3a */
79558 + __u8 _reserved[4]; /* 0x3c */
79559 } __attribute__((packed));
79560
79561 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
79562 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
79563 index 0e011eb..82681b1 100644
79564 --- a/include/uapi/linux/swab.h
79565 +++ b/include/uapi/linux/swab.h
79566 @@ -43,7 +43,7 @@
79567 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
79568 */
79569
79570 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
79571 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
79572 {
79573 #ifdef __HAVE_BUILTIN_BSWAP16__
79574 return __builtin_bswap16(val);
79575 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
79576 #endif
79577 }
79578
79579 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
79580 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
79581 {
79582 #ifdef __HAVE_BUILTIN_BSWAP32__
79583 return __builtin_bswap32(val);
79584 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
79585 #endif
79586 }
79587
79588 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
79589 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
79590 {
79591 #ifdef __HAVE_BUILTIN_BSWAP64__
79592 return __builtin_bswap64(val);
79593 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
79594 index 6d67213..8dab561 100644
79595 --- a/include/uapi/linux/sysctl.h
79596 +++ b/include/uapi/linux/sysctl.h
79597 @@ -155,7 +155,11 @@ enum
79598 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
79599 };
79600
79601 -
79602 +#ifdef CONFIG_PAX_SOFTMODE
79603 +enum {
79604 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79605 +};
79606 +#endif
79607
79608 /* CTL_VM names: */
79609 enum
79610 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
79611 index e4629b9..6958086 100644
79612 --- a/include/uapi/linux/xattr.h
79613 +++ b/include/uapi/linux/xattr.h
79614 @@ -63,5 +63,9 @@
79615 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
79616 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
79617
79618 +/* User namespace */
79619 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
79620 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
79621 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
79622
79623 #endif /* _UAPI_LINUX_XATTR_H */
79624 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
79625 index f9466fa..f4e2b81 100644
79626 --- a/include/video/udlfb.h
79627 +++ b/include/video/udlfb.h
79628 @@ -53,10 +53,10 @@ struct dlfb_data {
79629 u32 pseudo_palette[256];
79630 int blank_mode; /*one of FB_BLANK_ */
79631 /* blit-only rendering path metrics, exposed through sysfs */
79632 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79633 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
79634 - atomic_t bytes_sent; /* to usb, after compression including overhead */
79635 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
79636 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79637 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
79638 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
79639 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
79640 };
79641
79642 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
79643 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
79644 index 30f5362..8ed8ac9 100644
79645 --- a/include/video/uvesafb.h
79646 +++ b/include/video/uvesafb.h
79647 @@ -122,6 +122,7 @@ struct uvesafb_par {
79648 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
79649 u8 pmi_setpal; /* PMI for palette changes */
79650 u16 *pmi_base; /* protected mode interface location */
79651 + u8 *pmi_code; /* protected mode code location */
79652 void *pmi_start;
79653 void *pmi_pal;
79654 u8 *vbe_state_orig; /*
79655 diff --git a/init/Kconfig b/init/Kconfig
79656 index 3ecd8a1..627843f 100644
79657 --- a/init/Kconfig
79658 +++ b/init/Kconfig
79659 @@ -1086,6 +1086,7 @@ endif # CGROUPS
79660
79661 config CHECKPOINT_RESTORE
79662 bool "Checkpoint/restore support" if EXPERT
79663 + depends on !GRKERNSEC
79664 default n
79665 help
79666 Enables additional kernel features in a sake of checkpoint/restore.
79667 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
79668
79669 config COMPAT_BRK
79670 bool "Disable heap randomization"
79671 - default y
79672 + default n
79673 help
79674 Randomizing heap placement makes heap exploits harder, but it
79675 also breaks ancient binaries (including anything libc5 based).
79676 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
79677 config STOP_MACHINE
79678 bool
79679 default y
79680 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
79681 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
79682 help
79683 Need stop_machine() primitive.
79684
79685 diff --git a/init/Makefile b/init/Makefile
79686 index 7bc47ee..6da2dc7 100644
79687 --- a/init/Makefile
79688 +++ b/init/Makefile
79689 @@ -2,6 +2,9 @@
79690 # Makefile for the linux kernel.
79691 #
79692
79693 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
79694 +asflags-y := $(GCC_PLUGINS_AFLAGS)
79695 +
79696 obj-y := main.o version.o mounts.o
79697 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
79698 obj-y += noinitramfs.o
79699 diff --git a/init/do_mounts.c b/init/do_mounts.c
79700 index a51cddc..25c2768 100644
79701 --- a/init/do_mounts.c
79702 +++ b/init/do_mounts.c
79703 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
79704 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
79705 {
79706 struct super_block *s;
79707 - int err = sys_mount(name, "/root", fs, flags, data);
79708 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
79709 if (err)
79710 return err;
79711
79712 - sys_chdir("/root");
79713 + sys_chdir((const char __force_user *)"/root");
79714 s = current->fs->pwd.dentry->d_sb;
79715 ROOT_DEV = s->s_dev;
79716 printk(KERN_INFO
79717 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
79718 va_start(args, fmt);
79719 vsprintf(buf, fmt, args);
79720 va_end(args);
79721 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
79722 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
79723 if (fd >= 0) {
79724 sys_ioctl(fd, FDEJECT, 0);
79725 sys_close(fd);
79726 }
79727 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
79728 - fd = sys_open("/dev/console", O_RDWR, 0);
79729 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
79730 if (fd >= 0) {
79731 sys_ioctl(fd, TCGETS, (long)&termios);
79732 termios.c_lflag &= ~ICANON;
79733 sys_ioctl(fd, TCSETSF, (long)&termios);
79734 - sys_read(fd, &c, 1);
79735 + sys_read(fd, (char __user *)&c, 1);
79736 termios.c_lflag |= ICANON;
79737 sys_ioctl(fd, TCSETSF, (long)&termios);
79738 sys_close(fd);
79739 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
79740 mount_root();
79741 out:
79742 devtmpfs_mount("dev");
79743 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79744 - sys_chroot(".");
79745 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79746 + sys_chroot((const char __force_user *)".");
79747 }
79748
79749 static bool is_tmpfs;
79750 diff --git a/init/do_mounts.h b/init/do_mounts.h
79751 index f5b978a..69dbfe8 100644
79752 --- a/init/do_mounts.h
79753 +++ b/init/do_mounts.h
79754 @@ -15,15 +15,15 @@ extern int root_mountflags;
79755
79756 static inline int create_dev(char *name, dev_t dev)
79757 {
79758 - sys_unlink(name);
79759 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
79760 + sys_unlink((char __force_user *)name);
79761 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
79762 }
79763
79764 #if BITS_PER_LONG == 32
79765 static inline u32 bstat(char *name)
79766 {
79767 struct stat64 stat;
79768 - if (sys_stat64(name, &stat) != 0)
79769 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
79770 return 0;
79771 if (!S_ISBLK(stat.st_mode))
79772 return 0;
79773 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
79774 static inline u32 bstat(char *name)
79775 {
79776 struct stat stat;
79777 - if (sys_newstat(name, &stat) != 0)
79778 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
79779 return 0;
79780 if (!S_ISBLK(stat.st_mode))
79781 return 0;
79782 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
79783 index 3e0878e..8a9d7a0 100644
79784 --- a/init/do_mounts_initrd.c
79785 +++ b/init/do_mounts_initrd.c
79786 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
79787 {
79788 sys_unshare(CLONE_FS | CLONE_FILES);
79789 /* stdin/stdout/stderr for /linuxrc */
79790 - sys_open("/dev/console", O_RDWR, 0);
79791 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
79792 sys_dup(0);
79793 sys_dup(0);
79794 /* move initrd over / and chdir/chroot in initrd root */
79795 - sys_chdir("/root");
79796 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79797 - sys_chroot(".");
79798 + sys_chdir((const char __force_user *)"/root");
79799 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79800 + sys_chroot((const char __force_user *)".");
79801 sys_setsid();
79802 return 0;
79803 }
79804 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
79805 create_dev("/dev/root.old", Root_RAM0);
79806 /* mount initrd on rootfs' /root */
79807 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
79808 - sys_mkdir("/old", 0700);
79809 - sys_chdir("/old");
79810 + sys_mkdir((const char __force_user *)"/old", 0700);
79811 + sys_chdir((const char __force_user *)"/old");
79812
79813 /* try loading default modules from initrd */
79814 load_default_modules();
79815 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
79816 current->flags &= ~PF_FREEZER_SKIP;
79817
79818 /* move initrd to rootfs' /old */
79819 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
79820 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
79821 /* switch root and cwd back to / of rootfs */
79822 - sys_chroot("..");
79823 + sys_chroot((const char __force_user *)"..");
79824
79825 if (new_decode_dev(real_root_dev) == Root_RAM0) {
79826 - sys_chdir("/old");
79827 + sys_chdir((const char __force_user *)"/old");
79828 return;
79829 }
79830
79831 - sys_chdir("/");
79832 + sys_chdir((const char __force_user *)"/");
79833 ROOT_DEV = new_decode_dev(real_root_dev);
79834 mount_root();
79835
79836 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
79837 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
79838 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
79839 if (!error)
79840 printk("okay\n");
79841 else {
79842 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
79843 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
79844 if (error == -ENOENT)
79845 printk("/initrd does not exist. Ignored.\n");
79846 else
79847 printk("failed\n");
79848 printk(KERN_NOTICE "Unmounting old root\n");
79849 - sys_umount("/old", MNT_DETACH);
79850 + sys_umount((char __force_user *)"/old", MNT_DETACH);
79851 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
79852 if (fd < 0) {
79853 error = fd;
79854 @@ -127,11 +127,11 @@ int __init initrd_load(void)
79855 * mounted in the normal path.
79856 */
79857 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
79858 - sys_unlink("/initrd.image");
79859 + sys_unlink((const char __force_user *)"/initrd.image");
79860 handle_initrd();
79861 return 1;
79862 }
79863 }
79864 - sys_unlink("/initrd.image");
79865 + sys_unlink((const char __force_user *)"/initrd.image");
79866 return 0;
79867 }
79868 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
79869 index 8cb6db5..d729f50 100644
79870 --- a/init/do_mounts_md.c
79871 +++ b/init/do_mounts_md.c
79872 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
79873 partitioned ? "_d" : "", minor,
79874 md_setup_args[ent].device_names);
79875
79876 - fd = sys_open(name, 0, 0);
79877 + fd = sys_open((char __force_user *)name, 0, 0);
79878 if (fd < 0) {
79879 printk(KERN_ERR "md: open failed - cannot start "
79880 "array %s\n", name);
79881 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
79882 * array without it
79883 */
79884 sys_close(fd);
79885 - fd = sys_open(name, 0, 0);
79886 + fd = sys_open((char __force_user *)name, 0, 0);
79887 sys_ioctl(fd, BLKRRPART, 0);
79888 }
79889 sys_close(fd);
79890 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
79891
79892 wait_for_device_probe();
79893
79894 - fd = sys_open("/dev/md0", 0, 0);
79895 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
79896 if (fd >= 0) {
79897 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
79898 sys_close(fd);
79899 diff --git a/init/init_task.c b/init/init_task.c
79900 index ba0a7f36..2bcf1d5 100644
79901 --- a/init/init_task.c
79902 +++ b/init/init_task.c
79903 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79904 * Initial thread structure. Alignment of this is handled by a special
79905 * linker map entry.
79906 */
79907 +#ifdef CONFIG_X86
79908 +union thread_union init_thread_union __init_task_data;
79909 +#else
79910 union thread_union init_thread_union __init_task_data =
79911 { INIT_THREAD_INFO(init_task) };
79912 +#endif
79913 diff --git a/init/initramfs.c b/init/initramfs.c
79914 index a67ef9d..2d17ed9 100644
79915 --- a/init/initramfs.c
79916 +++ b/init/initramfs.c
79917 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79918 }
79919 }
79920
79921 -static long __init do_utime(char *filename, time_t mtime)
79922 +static long __init do_utime(char __force_user *filename, time_t mtime)
79923 {
79924 struct timespec t[2];
79925
79926 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79927 struct dir_entry *de, *tmp;
79928 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79929 list_del(&de->list);
79930 - do_utime(de->name, de->mtime);
79931 + do_utime((char __force_user *)de->name, de->mtime);
79932 kfree(de->name);
79933 kfree(de);
79934 }
79935 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79936 if (nlink >= 2) {
79937 char *old = find_link(major, minor, ino, mode, collected);
79938 if (old)
79939 - return (sys_link(old, collected) < 0) ? -1 : 1;
79940 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79941 }
79942 return 0;
79943 }
79944 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79945 {
79946 struct stat st;
79947
79948 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79949 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79950 if (S_ISDIR(st.st_mode))
79951 - sys_rmdir(path);
79952 + sys_rmdir((char __force_user *)path);
79953 else
79954 - sys_unlink(path);
79955 + sys_unlink((char __force_user *)path);
79956 }
79957 }
79958
79959 @@ -315,7 +315,7 @@ static int __init do_name(void)
79960 int openflags = O_WRONLY|O_CREAT;
79961 if (ml != 1)
79962 openflags |= O_TRUNC;
79963 - wfd = sys_open(collected, openflags, mode);
79964 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79965
79966 if (wfd >= 0) {
79967 sys_fchown(wfd, uid, gid);
79968 @@ -327,17 +327,17 @@ static int __init do_name(void)
79969 }
79970 }
79971 } else if (S_ISDIR(mode)) {
79972 - sys_mkdir(collected, mode);
79973 - sys_chown(collected, uid, gid);
79974 - sys_chmod(collected, mode);
79975 + sys_mkdir((char __force_user *)collected, mode);
79976 + sys_chown((char __force_user *)collected, uid, gid);
79977 + sys_chmod((char __force_user *)collected, mode);
79978 dir_add(collected, mtime);
79979 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79980 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79981 if (maybe_link() == 0) {
79982 - sys_mknod(collected, mode, rdev);
79983 - sys_chown(collected, uid, gid);
79984 - sys_chmod(collected, mode);
79985 - do_utime(collected, mtime);
79986 + sys_mknod((char __force_user *)collected, mode, rdev);
79987 + sys_chown((char __force_user *)collected, uid, gid);
79988 + sys_chmod((char __force_user *)collected, mode);
79989 + do_utime((char __force_user *)collected, mtime);
79990 }
79991 }
79992 return 0;
79993 @@ -346,15 +346,15 @@ static int __init do_name(void)
79994 static int __init do_copy(void)
79995 {
79996 if (count >= body_len) {
79997 - sys_write(wfd, victim, body_len);
79998 + sys_write(wfd, (char __force_user *)victim, body_len);
79999 sys_close(wfd);
80000 - do_utime(vcollected, mtime);
80001 + do_utime((char __force_user *)vcollected, mtime);
80002 kfree(vcollected);
80003 eat(body_len);
80004 state = SkipIt;
80005 return 0;
80006 } else {
80007 - sys_write(wfd, victim, count);
80008 + sys_write(wfd, (char __force_user *)victim, count);
80009 body_len -= count;
80010 eat(count);
80011 return 1;
80012 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80013 {
80014 collected[N_ALIGN(name_len) + body_len] = '\0';
80015 clean_path(collected, 0);
80016 - sys_symlink(collected + N_ALIGN(name_len), collected);
80017 - sys_lchown(collected, uid, gid);
80018 - do_utime(collected, mtime);
80019 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80020 + sys_lchown((char __force_user *)collected, uid, gid);
80021 + do_utime((char __force_user *)collected, mtime);
80022 state = SkipIt;
80023 next_state = Reset;
80024 return 0;
80025 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80026 {
80027 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80028 if (err)
80029 - panic(err); /* Failed to decompress INTERNAL initramfs */
80030 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80031 if (initrd_start) {
80032 #ifdef CONFIG_BLK_DEV_RAM
80033 int fd;
80034 diff --git a/init/main.c b/init/main.c
80035 index 63d3e8f..291fa8a 100644
80036 --- a/init/main.c
80037 +++ b/init/main.c
80038 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
80039 extern void tc_init(void);
80040 #endif
80041
80042 +extern void grsecurity_init(void);
80043 +
80044 /*
80045 * Debug helper: via this flag we know that we are in 'early bootup code'
80046 * where only the boot processor is running with IRQ disabled. This means
80047 @@ -156,6 +158,74 @@ static int __init set_reset_devices(char *str)
80048
80049 __setup("reset_devices", set_reset_devices);
80050
80051 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80052 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80053 +static int __init setup_grsec_proc_gid(char *str)
80054 +{
80055 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80056 + return 1;
80057 +}
80058 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80059 +#endif
80060 +
80061 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80062 +unsigned long pax_user_shadow_base __read_only;
80063 +EXPORT_SYMBOL(pax_user_shadow_base);
80064 +extern char pax_enter_kernel_user[];
80065 +extern char pax_exit_kernel_user[];
80066 +#endif
80067 +
80068 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80069 +static int __init setup_pax_nouderef(char *str)
80070 +{
80071 +#ifdef CONFIG_X86_32
80072 + unsigned int cpu;
80073 + struct desc_struct *gdt;
80074 +
80075 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80076 + gdt = get_cpu_gdt_table(cpu);
80077 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80078 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80079 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80080 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80081 + }
80082 + loadsegment(ds, __KERNEL_DS);
80083 + loadsegment(es, __KERNEL_DS);
80084 + loadsegment(ss, __KERNEL_DS);
80085 +#else
80086 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80087 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80088 + clone_pgd_mask = ~(pgdval_t)0UL;
80089 + pax_user_shadow_base = 0UL;
80090 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80091 +#endif
80092 +
80093 + return 0;
80094 +}
80095 +early_param("pax_nouderef", setup_pax_nouderef);
80096 +
80097 +#ifdef CONFIG_X86_64
80098 +static int __init setup_pax_weakuderef(char *str)
80099 +{
80100 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80101 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80102 + return 1;
80103 +}
80104 +__setup("pax_weakuderef", setup_pax_weakuderef);
80105 +#endif
80106 +#endif
80107 +
80108 +#ifdef CONFIG_PAX_SOFTMODE
80109 +int pax_softmode;
80110 +
80111 +static int __init setup_pax_softmode(char *str)
80112 +{
80113 + get_option(&str, &pax_softmode);
80114 + return 1;
80115 +}
80116 +__setup("pax_softmode=", setup_pax_softmode);
80117 +#endif
80118 +
80119 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80120 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80121 static const char *panic_later, *panic_param;
80122 @@ -682,25 +752,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
80123 {
80124 int count = preempt_count();
80125 int ret;
80126 - char msgbuf[64];
80127 + const char *msg1 = "", *msg2 = "";
80128
80129 if (initcall_debug)
80130 ret = do_one_initcall_debug(fn);
80131 else
80132 ret = fn();
80133
80134 - msgbuf[0] = 0;
80135 -
80136 if (preempt_count() != count) {
80137 - sprintf(msgbuf, "preemption imbalance ");
80138 + msg1 = " preemption imbalance";
80139 preempt_count() = count;
80140 }
80141 if (irqs_disabled()) {
80142 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80143 + msg2 = " disabled interrupts";
80144 local_irq_enable();
80145 }
80146 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80147 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80148
80149 + add_latent_entropy();
80150 return ret;
80151 }
80152
80153 @@ -807,10 +876,14 @@ static int run_init_process(const char *init_filename)
80154 {
80155 argv_init[0] = init_filename;
80156 return do_execve(init_filename,
80157 - (const char __user *const __user *)argv_init,
80158 - (const char __user *const __user *)envp_init);
80159 + (const char __user *const __force_user *)argv_init,
80160 + (const char __user *const __force_user *)envp_init);
80161 }
80162
80163 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80164 +extern int gr_init_ran;
80165 +#endif
80166 +
80167 static noinline void __init kernel_init_freeable(void);
80168
80169 static int __ref kernel_init(void *unused)
80170 @@ -831,6 +904,11 @@ static int __ref kernel_init(void *unused)
80171 pr_err("Failed to execute %s\n", ramdisk_execute_command);
80172 }
80173
80174 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80175 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
80176 + gr_init_ran = 1;
80177 +#endif
80178 +
80179 /*
80180 * We try each of these until one succeeds.
80181 *
80182 @@ -885,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
80183 do_basic_setup();
80184
80185 /* Open the /dev/console on the rootfs, this should never fail */
80186 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80187 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80188 pr_err("Warning: unable to open an initial console.\n");
80189
80190 (void) sys_dup(0);
80191 @@ -898,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
80192 if (!ramdisk_execute_command)
80193 ramdisk_execute_command = "/init";
80194
80195 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80196 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80197 ramdisk_execute_command = NULL;
80198 prepare_namespace();
80199 }
80200
80201 + grsecurity_init();
80202 +
80203 /*
80204 * Ok, we have completed the initial bootup, and
80205 * we're essentially up and running. Get rid of the
80206 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80207 index b0e99de..09f385c 100644
80208 --- a/ipc/ipc_sysctl.c
80209 +++ b/ipc/ipc_sysctl.c
80210 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80211 static int proc_ipc_dointvec(ctl_table *table, int write,
80212 void __user *buffer, size_t *lenp, loff_t *ppos)
80213 {
80214 - struct ctl_table ipc_table;
80215 + ctl_table_no_const ipc_table;
80216
80217 memcpy(&ipc_table, table, sizeof(ipc_table));
80218 ipc_table.data = get_ipc(table);
80219 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80220 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80221 void __user *buffer, size_t *lenp, loff_t *ppos)
80222 {
80223 - struct ctl_table ipc_table;
80224 + ctl_table_no_const ipc_table;
80225
80226 memcpy(&ipc_table, table, sizeof(ipc_table));
80227 ipc_table.data = get_ipc(table);
80228 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80229 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80230 void __user *buffer, size_t *lenp, loff_t *ppos)
80231 {
80232 - struct ctl_table ipc_table;
80233 + ctl_table_no_const ipc_table;
80234 size_t lenp_bef = *lenp;
80235 int rc;
80236
80237 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80238 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
80239 void __user *buffer, size_t *lenp, loff_t *ppos)
80240 {
80241 - struct ctl_table ipc_table;
80242 + ctl_table_no_const ipc_table;
80243 memcpy(&ipc_table, table, sizeof(ipc_table));
80244 ipc_table.data = get_ipc(table);
80245
80246 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
80247 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
80248 void __user *buffer, size_t *lenp, loff_t *ppos)
80249 {
80250 - struct ctl_table ipc_table;
80251 + ctl_table_no_const ipc_table;
80252 size_t lenp_bef = *lenp;
80253 int oldval;
80254 int rc;
80255 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
80256 index 383d638..943fdbb 100644
80257 --- a/ipc/mq_sysctl.c
80258 +++ b/ipc/mq_sysctl.c
80259 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
80260 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
80261 void __user *buffer, size_t *lenp, loff_t *ppos)
80262 {
80263 - struct ctl_table mq_table;
80264 + ctl_table_no_const mq_table;
80265 memcpy(&mq_table, table, sizeof(mq_table));
80266 mq_table.data = get_mq(table);
80267
80268 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
80269 index ae1996d..a35f2cc 100644
80270 --- a/ipc/mqueue.c
80271 +++ b/ipc/mqueue.c
80272 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
80273 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
80274 info->attr.mq_msgsize);
80275
80276 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
80277 spin_lock(&mq_lock);
80278 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
80279 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
80280 diff --git a/ipc/msg.c b/ipc/msg.c
80281 index 558aa91..359e718 100644
80282 --- a/ipc/msg.c
80283 +++ b/ipc/msg.c
80284 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
80285 return security_msg_queue_associate(msq, msgflg);
80286 }
80287
80288 +static struct ipc_ops msg_ops = {
80289 + .getnew = newque,
80290 + .associate = msg_security,
80291 + .more_checks = NULL
80292 +};
80293 +
80294 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
80295 {
80296 struct ipc_namespace *ns;
80297 - struct ipc_ops msg_ops;
80298 struct ipc_params msg_params;
80299
80300 ns = current->nsproxy->ipc_ns;
80301
80302 - msg_ops.getnew = newque;
80303 - msg_ops.associate = msg_security;
80304 - msg_ops.more_checks = NULL;
80305 -
80306 msg_params.key = key;
80307 msg_params.flg = msgflg;
80308
80309 diff --git a/ipc/sem.c b/ipc/sem.c
80310 index db9d241..bc8427c 100644
80311 --- a/ipc/sem.c
80312 +++ b/ipc/sem.c
80313 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
80314 return 0;
80315 }
80316
80317 +static struct ipc_ops sem_ops = {
80318 + .getnew = newary,
80319 + .associate = sem_security,
80320 + .more_checks = sem_more_checks
80321 +};
80322 +
80323 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80324 {
80325 struct ipc_namespace *ns;
80326 - struct ipc_ops sem_ops;
80327 struct ipc_params sem_params;
80328
80329 ns = current->nsproxy->ipc_ns;
80330 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80331 if (nsems < 0 || nsems > ns->sc_semmsl)
80332 return -EINVAL;
80333
80334 - sem_ops.getnew = newary;
80335 - sem_ops.associate = sem_security;
80336 - sem_ops.more_checks = sem_more_checks;
80337 -
80338 sem_params.key = key;
80339 sem_params.flg = semflg;
80340 sem_params.u.nsems = nsems;
80341 diff --git a/ipc/shm.c b/ipc/shm.c
80342 index 7a51443..3a257d8 100644
80343 --- a/ipc/shm.c
80344 +++ b/ipc/shm.c
80345 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
80346 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
80347 #endif
80348
80349 +#ifdef CONFIG_GRKERNSEC
80350 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80351 + const time_t shm_createtime, const kuid_t cuid,
80352 + const int shmid);
80353 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80354 + const time_t shm_createtime);
80355 +#endif
80356 +
80357 void shm_init_ns(struct ipc_namespace *ns)
80358 {
80359 ns->shm_ctlmax = SHMMAX;
80360 @@ -554,6 +562,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
80361 shp->shm_lprid = 0;
80362 shp->shm_atim = shp->shm_dtim = 0;
80363 shp->shm_ctim = get_seconds();
80364 +#ifdef CONFIG_GRKERNSEC
80365 + {
80366 + struct timespec timeval;
80367 + do_posix_clock_monotonic_gettime(&timeval);
80368 +
80369 + shp->shm_createtime = timeval.tv_sec;
80370 + }
80371 +#endif
80372 shp->shm_segsz = size;
80373 shp->shm_nattch = 0;
80374 shp->shm_file = file;
80375 @@ -607,18 +623,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
80376 return 0;
80377 }
80378
80379 +static struct ipc_ops shm_ops = {
80380 + .getnew = newseg,
80381 + .associate = shm_security,
80382 + .more_checks = shm_more_checks
80383 +};
80384 +
80385 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
80386 {
80387 struct ipc_namespace *ns;
80388 - struct ipc_ops shm_ops;
80389 struct ipc_params shm_params;
80390
80391 ns = current->nsproxy->ipc_ns;
80392
80393 - shm_ops.getnew = newseg;
80394 - shm_ops.associate = shm_security;
80395 - shm_ops.more_checks = shm_more_checks;
80396 -
80397 shm_params.key = key;
80398 shm_params.flg = shmflg;
80399 shm_params.u.size = size;
80400 @@ -1089,6 +1106,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80401 f_mode = FMODE_READ | FMODE_WRITE;
80402 }
80403 if (shmflg & SHM_EXEC) {
80404 +
80405 +#ifdef CONFIG_PAX_MPROTECT
80406 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
80407 + goto out;
80408 +#endif
80409 +
80410 prot |= PROT_EXEC;
80411 acc_mode |= S_IXUGO;
80412 }
80413 @@ -1113,6 +1136,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80414 if (err)
80415 goto out_unlock;
80416
80417 +#ifdef CONFIG_GRKERNSEC
80418 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
80419 + shp->shm_perm.cuid, shmid) ||
80420 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
80421 + err = -EACCES;
80422 + goto out_unlock;
80423 + }
80424 +#endif
80425 +
80426 ipc_lock_object(&shp->shm_perm);
80427
80428 /* check if shm_destroy() is tearing down shp */
80429 @@ -1125,6 +1157,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80430 path = shp->shm_file->f_path;
80431 path_get(&path);
80432 shp->shm_nattch++;
80433 +#ifdef CONFIG_GRKERNSEC
80434 + shp->shm_lapid = current->pid;
80435 +#endif
80436 size = i_size_read(path.dentry->d_inode);
80437 ipc_unlock_object(&shp->shm_perm);
80438 rcu_read_unlock();
80439 diff --git a/ipc/util.c b/ipc/util.c
80440 index 7684f41..f7da711 100644
80441 --- a/ipc/util.c
80442 +++ b/ipc/util.c
80443 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
80444 int (*show)(struct seq_file *, void *);
80445 };
80446
80447 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
80448 +
80449 static void ipc_memory_notifier(struct work_struct *work)
80450 {
80451 ipcns_notify(IPCNS_MEMCHANGED);
80452 @@ -560,6 +562,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
80453 granted_mode >>= 6;
80454 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
80455 granted_mode >>= 3;
80456 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
80457 + return -1;
80458 +
80459 /* is there some bit set in requested_mode but not in granted_mode? */
80460 if ((requested_mode & ~granted_mode & 0007) &&
80461 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
80462 diff --git a/kernel/acct.c b/kernel/acct.c
80463 index 8d6e145..33e0b1e 100644
80464 --- a/kernel/acct.c
80465 +++ b/kernel/acct.c
80466 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
80467 */
80468 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
80469 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
80470 - file->f_op->write(file, (char *)&ac,
80471 + file->f_op->write(file, (char __force_user *)&ac,
80472 sizeof(acct_t), &file->f_pos);
80473 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
80474 set_fs(fs);
80475 diff --git a/kernel/audit.c b/kernel/audit.c
80476 index 7b0e23a..f4d172f 100644
80477 --- a/kernel/audit.c
80478 +++ b/kernel/audit.c
80479 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
80480 3) suppressed due to audit_rate_limit
80481 4) suppressed due to audit_backlog_limit
80482 */
80483 -static atomic_t audit_lost = ATOMIC_INIT(0);
80484 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
80485
80486 /* The netlink socket. */
80487 static struct sock *audit_sock;
80488 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
80489 unsigned long now;
80490 int print;
80491
80492 - atomic_inc(&audit_lost);
80493 + atomic_inc_unchecked(&audit_lost);
80494
80495 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
80496
80497 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
80498 printk(KERN_WARNING
80499 "audit: audit_lost=%d audit_rate_limit=%d "
80500 "audit_backlog_limit=%d\n",
80501 - atomic_read(&audit_lost),
80502 + atomic_read_unchecked(&audit_lost),
80503 audit_rate_limit,
80504 audit_backlog_limit);
80505 audit_panic(message);
80506 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80507
80508 switch (msg_type) {
80509 case AUDIT_GET:
80510 + status_set.mask = 0;
80511 status_set.enabled = audit_enabled;
80512 status_set.failure = audit_failure;
80513 status_set.pid = audit_pid;
80514 status_set.rate_limit = audit_rate_limit;
80515 status_set.backlog_limit = audit_backlog_limit;
80516 - status_set.lost = atomic_read(&audit_lost);
80517 + status_set.lost = atomic_read_unchecked(&audit_lost);
80518 status_set.backlog = skb_queue_len(&audit_skb_queue);
80519 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
80520 &status_set, sizeof(status_set));
80521 break;
80522 case AUDIT_SET:
80523 - if (nlh->nlmsg_len < sizeof(struct audit_status))
80524 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
80525 return -EINVAL;
80526 status_get = (struct audit_status *)data;
80527 if (status_get->mask & AUDIT_STATUS_ENABLED) {
80528 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80529
80530 memset(&s, 0, sizeof(s));
80531 /* guard against past and future API changes */
80532 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
80533 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
80534 if ((s.enabled != 0 && s.enabled != 1) ||
80535 (s.log_passwd != 0 && s.log_passwd != 1))
80536 return -EINVAL;
80537 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
80538 int i, avail, new_len;
80539 unsigned char *ptr;
80540 struct sk_buff *skb;
80541 - static const unsigned char *hex = "0123456789ABCDEF";
80542 + static const unsigned char hex[] = "0123456789ABCDEF";
80543
80544 if (!ab)
80545 return;
80546 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
80547 index 9845cb3..3ec9369 100644
80548 --- a/kernel/auditsc.c
80549 +++ b/kernel/auditsc.c
80550 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
80551 }
80552
80553 /* global counter which is incremented every time something logs in */
80554 -static atomic_t session_id = ATOMIC_INIT(0);
80555 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
80556
80557 /**
80558 * audit_set_loginuid - set current task's audit_context loginuid
80559 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
80560 return -EPERM;
80561 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
80562
80563 - sessionid = atomic_inc_return(&session_id);
80564 + sessionid = atomic_inc_return_unchecked(&session_id);
80565 if (context && context->in_syscall) {
80566 struct audit_buffer *ab;
80567
80568 diff --git a/kernel/capability.c b/kernel/capability.c
80569 index 4e66bf9..cdccecf 100644
80570 --- a/kernel/capability.c
80571 +++ b/kernel/capability.c
80572 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
80573 * before modification is attempted and the application
80574 * fails.
80575 */
80576 + if (tocopy > ARRAY_SIZE(kdata))
80577 + return -EFAULT;
80578 +
80579 if (copy_to_user(dataptr, kdata, tocopy
80580 * sizeof(struct __user_cap_data_struct))) {
80581 return -EFAULT;
80582 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
80583 int ret;
80584
80585 rcu_read_lock();
80586 - ret = security_capable(__task_cred(t), ns, cap);
80587 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
80588 + gr_task_is_capable(t, __task_cred(t), cap);
80589 rcu_read_unlock();
80590
80591 - return (ret == 0);
80592 + return ret;
80593 }
80594
80595 /**
80596 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
80597 int ret;
80598
80599 rcu_read_lock();
80600 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
80601 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
80602 rcu_read_unlock();
80603
80604 - return (ret == 0);
80605 + return ret;
80606 }
80607
80608 /**
80609 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80610 BUG();
80611 }
80612
80613 - if (security_capable(current_cred(), ns, cap) == 0) {
80614 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80615 current->flags |= PF_SUPERPRIV;
80616 return true;
80617 }
80618 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80619 }
80620 EXPORT_SYMBOL(ns_capable);
80621
80622 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80623 +{
80624 + if (unlikely(!cap_valid(cap))) {
80625 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80626 + BUG();
80627 + }
80628 +
80629 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80630 + current->flags |= PF_SUPERPRIV;
80631 + return true;
80632 + }
80633 + return false;
80634 +}
80635 +EXPORT_SYMBOL(ns_capable_nolog);
80636 +
80637 /**
80638 * file_ns_capable - Determine if the file's opener had a capability in effect
80639 * @file: The file we want to check
80640 @@ -432,6 +451,12 @@ bool capable(int cap)
80641 }
80642 EXPORT_SYMBOL(capable);
80643
80644 +bool capable_nolog(int cap)
80645 +{
80646 + return ns_capable_nolog(&init_user_ns, cap);
80647 +}
80648 +EXPORT_SYMBOL(capable_nolog);
80649 +
80650 /**
80651 * inode_capable - Check superior capability over inode
80652 * @inode: The inode in question
80653 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
80654 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80655 }
80656 EXPORT_SYMBOL(inode_capable);
80657 +
80658 +bool inode_capable_nolog(const struct inode *inode, int cap)
80659 +{
80660 + struct user_namespace *ns = current_user_ns();
80661 +
80662 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80663 +}
80664 +EXPORT_SYMBOL(inode_capable_nolog);
80665 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
80666 index 8bd9cfd..9faf120 100644
80667 --- a/kernel/cgroup.c
80668 +++ b/kernel/cgroup.c
80669 @@ -5817,7 +5817,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
80670 struct css_set *cset = link->cset;
80671 struct task_struct *task;
80672 int count = 0;
80673 - seq_printf(seq, "css_set %p\n", cset);
80674 + seq_printf(seq, "css_set %pK\n", cset);
80675 list_for_each_entry(task, &cset->tasks, cg_list) {
80676 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
80677 seq_puts(seq, " ...\n");
80678 diff --git a/kernel/compat.c b/kernel/compat.c
80679 index 0a09e48..f44f3f0 100644
80680 --- a/kernel/compat.c
80681 +++ b/kernel/compat.c
80682 @@ -13,6 +13,7 @@
80683
80684 #include <linux/linkage.h>
80685 #include <linux/compat.h>
80686 +#include <linux/module.h>
80687 #include <linux/errno.h>
80688 #include <linux/time.h>
80689 #include <linux/signal.h>
80690 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
80691 mm_segment_t oldfs;
80692 long ret;
80693
80694 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
80695 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
80696 oldfs = get_fs();
80697 set_fs(KERNEL_DS);
80698 ret = hrtimer_nanosleep_restart(restart);
80699 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
80700 oldfs = get_fs();
80701 set_fs(KERNEL_DS);
80702 ret = hrtimer_nanosleep(&tu,
80703 - rmtp ? (struct timespec __user *)&rmt : NULL,
80704 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
80705 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
80706 set_fs(oldfs);
80707
80708 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
80709 mm_segment_t old_fs = get_fs();
80710
80711 set_fs(KERNEL_DS);
80712 - ret = sys_sigpending((old_sigset_t __user *) &s);
80713 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
80714 set_fs(old_fs);
80715 if (ret == 0)
80716 ret = put_user(s, set);
80717 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
80718 mm_segment_t old_fs = get_fs();
80719
80720 set_fs(KERNEL_DS);
80721 - ret = sys_old_getrlimit(resource, &r);
80722 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
80723 set_fs(old_fs);
80724
80725 if (!ret) {
80726 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
80727 set_fs (KERNEL_DS);
80728 ret = sys_wait4(pid,
80729 (stat_addr ?
80730 - (unsigned int __user *) &status : NULL),
80731 - options, (struct rusage __user *) &r);
80732 + (unsigned int __force_user *) &status : NULL),
80733 + options, (struct rusage __force_user *) &r);
80734 set_fs (old_fs);
80735
80736 if (ret > 0) {
80737 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
80738 memset(&info, 0, sizeof(info));
80739
80740 set_fs(KERNEL_DS);
80741 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
80742 - uru ? (struct rusage __user *)&ru : NULL);
80743 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
80744 + uru ? (struct rusage __force_user *)&ru : NULL);
80745 set_fs(old_fs);
80746
80747 if ((ret < 0) || (info.si_signo == 0))
80748 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
80749 oldfs = get_fs();
80750 set_fs(KERNEL_DS);
80751 err = sys_timer_settime(timer_id, flags,
80752 - (struct itimerspec __user *) &newts,
80753 - (struct itimerspec __user *) &oldts);
80754 + (struct itimerspec __force_user *) &newts,
80755 + (struct itimerspec __force_user *) &oldts);
80756 set_fs(oldfs);
80757 if (!err && old && put_compat_itimerspec(old, &oldts))
80758 return -EFAULT;
80759 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
80760 oldfs = get_fs();
80761 set_fs(KERNEL_DS);
80762 err = sys_timer_gettime(timer_id,
80763 - (struct itimerspec __user *) &ts);
80764 + (struct itimerspec __force_user *) &ts);
80765 set_fs(oldfs);
80766 if (!err && put_compat_itimerspec(setting, &ts))
80767 return -EFAULT;
80768 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
80769 oldfs = get_fs();
80770 set_fs(KERNEL_DS);
80771 err = sys_clock_settime(which_clock,
80772 - (struct timespec __user *) &ts);
80773 + (struct timespec __force_user *) &ts);
80774 set_fs(oldfs);
80775 return err;
80776 }
80777 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
80778 oldfs = get_fs();
80779 set_fs(KERNEL_DS);
80780 err = sys_clock_gettime(which_clock,
80781 - (struct timespec __user *) &ts);
80782 + (struct timespec __force_user *) &ts);
80783 set_fs(oldfs);
80784 if (!err && put_compat_timespec(&ts, tp))
80785 return -EFAULT;
80786 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
80787
80788 oldfs = get_fs();
80789 set_fs(KERNEL_DS);
80790 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
80791 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
80792 set_fs(oldfs);
80793
80794 err = compat_put_timex(utp, &txc);
80795 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
80796 oldfs = get_fs();
80797 set_fs(KERNEL_DS);
80798 err = sys_clock_getres(which_clock,
80799 - (struct timespec __user *) &ts);
80800 + (struct timespec __force_user *) &ts);
80801 set_fs(oldfs);
80802 if (!err && tp && put_compat_timespec(&ts, tp))
80803 return -EFAULT;
80804 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
80805 long err;
80806 mm_segment_t oldfs;
80807 struct timespec tu;
80808 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
80809 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
80810
80811 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
80812 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
80813 oldfs = get_fs();
80814 set_fs(KERNEL_DS);
80815 err = clock_nanosleep_restart(restart);
80816 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
80817 oldfs = get_fs();
80818 set_fs(KERNEL_DS);
80819 err = sys_clock_nanosleep(which_clock, flags,
80820 - (struct timespec __user *) &in,
80821 - (struct timespec __user *) &out);
80822 + (struct timespec __force_user *) &in,
80823 + (struct timespec __force_user *) &out);
80824 set_fs(oldfs);
80825
80826 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
80827 diff --git a/kernel/configs.c b/kernel/configs.c
80828 index c18b1f1..b9a0132 100644
80829 --- a/kernel/configs.c
80830 +++ b/kernel/configs.c
80831 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
80832 struct proc_dir_entry *entry;
80833
80834 /* create the current config file */
80835 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
80836 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
80837 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
80838 + &ikconfig_file_ops);
80839 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80840 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
80841 + &ikconfig_file_ops);
80842 +#endif
80843 +#else
80844 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
80845 &ikconfig_file_ops);
80846 +#endif
80847 +
80848 if (!entry)
80849 return -ENOMEM;
80850
80851 diff --git a/kernel/cred.c b/kernel/cred.c
80852 index e0573a4..3874e41 100644
80853 --- a/kernel/cred.c
80854 +++ b/kernel/cred.c
80855 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
80856 validate_creds(cred);
80857 alter_cred_subscribers(cred, -1);
80858 put_cred(cred);
80859 +
80860 +#ifdef CONFIG_GRKERNSEC_SETXID
80861 + cred = (struct cred *) tsk->delayed_cred;
80862 + if (cred != NULL) {
80863 + tsk->delayed_cred = NULL;
80864 + validate_creds(cred);
80865 + alter_cred_subscribers(cred, -1);
80866 + put_cred(cred);
80867 + }
80868 +#endif
80869 }
80870
80871 /**
80872 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
80873 * Always returns 0 thus allowing this function to be tail-called at the end
80874 * of, say, sys_setgid().
80875 */
80876 -int commit_creds(struct cred *new)
80877 +static int __commit_creds(struct cred *new)
80878 {
80879 struct task_struct *task = current;
80880 const struct cred *old = task->real_cred;
80881 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
80882
80883 get_cred(new); /* we will require a ref for the subj creds too */
80884
80885 + gr_set_role_label(task, new->uid, new->gid);
80886 +
80887 /* dumpability changes */
80888 if (!uid_eq(old->euid, new->euid) ||
80889 !gid_eq(old->egid, new->egid) ||
80890 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
80891 put_cred(old);
80892 return 0;
80893 }
80894 +#ifdef CONFIG_GRKERNSEC_SETXID
80895 +extern int set_user(struct cred *new);
80896 +
80897 +void gr_delayed_cred_worker(void)
80898 +{
80899 + const struct cred *new = current->delayed_cred;
80900 + struct cred *ncred;
80901 +
80902 + current->delayed_cred = NULL;
80903 +
80904 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
80905 + // from doing get_cred on it when queueing this
80906 + put_cred(new);
80907 + return;
80908 + } else if (new == NULL)
80909 + return;
80910 +
80911 + ncred = prepare_creds();
80912 + if (!ncred)
80913 + goto die;
80914 + // uids
80915 + ncred->uid = new->uid;
80916 + ncred->euid = new->euid;
80917 + ncred->suid = new->suid;
80918 + ncred->fsuid = new->fsuid;
80919 + // gids
80920 + ncred->gid = new->gid;
80921 + ncred->egid = new->egid;
80922 + ncred->sgid = new->sgid;
80923 + ncred->fsgid = new->fsgid;
80924 + // groups
80925 + if (set_groups(ncred, new->group_info) < 0) {
80926 + abort_creds(ncred);
80927 + goto die;
80928 + }
80929 + // caps
80930 + ncred->securebits = new->securebits;
80931 + ncred->cap_inheritable = new->cap_inheritable;
80932 + ncred->cap_permitted = new->cap_permitted;
80933 + ncred->cap_effective = new->cap_effective;
80934 + ncred->cap_bset = new->cap_bset;
80935 +
80936 + if (set_user(ncred)) {
80937 + abort_creds(ncred);
80938 + goto die;
80939 + }
80940 +
80941 + // from doing get_cred on it when queueing this
80942 + put_cred(new);
80943 +
80944 + __commit_creds(ncred);
80945 + return;
80946 +die:
80947 + // from doing get_cred on it when queueing this
80948 + put_cred(new);
80949 + do_group_exit(SIGKILL);
80950 +}
80951 +#endif
80952 +
80953 +int commit_creds(struct cred *new)
80954 +{
80955 +#ifdef CONFIG_GRKERNSEC_SETXID
80956 + int ret;
80957 + int schedule_it = 0;
80958 + struct task_struct *t;
80959 +
80960 + /* we won't get called with tasklist_lock held for writing
80961 + and interrupts disabled as the cred struct in that case is
80962 + init_cred
80963 + */
80964 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80965 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80966 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80967 + schedule_it = 1;
80968 + }
80969 + ret = __commit_creds(new);
80970 + if (schedule_it) {
80971 + rcu_read_lock();
80972 + read_lock(&tasklist_lock);
80973 + for (t = next_thread(current); t != current;
80974 + t = next_thread(t)) {
80975 + if (t->delayed_cred == NULL) {
80976 + t->delayed_cred = get_cred(new);
80977 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80978 + set_tsk_need_resched(t);
80979 + }
80980 + }
80981 + read_unlock(&tasklist_lock);
80982 + rcu_read_unlock();
80983 + }
80984 + return ret;
80985 +#else
80986 + return __commit_creds(new);
80987 +#endif
80988 +}
80989 +
80990 EXPORT_SYMBOL(commit_creds);
80991
80992 /**
80993 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80994 index 0506d44..2c20034 100644
80995 --- a/kernel/debug/debug_core.c
80996 +++ b/kernel/debug/debug_core.c
80997 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80998 */
80999 static atomic_t masters_in_kgdb;
81000 static atomic_t slaves_in_kgdb;
81001 -static atomic_t kgdb_break_tasklet_var;
81002 +static atomic_unchecked_t kgdb_break_tasklet_var;
81003 atomic_t kgdb_setting_breakpoint;
81004
81005 struct task_struct *kgdb_usethread;
81006 @@ -133,7 +133,7 @@ int kgdb_single_step;
81007 static pid_t kgdb_sstep_pid;
81008
81009 /* to keep track of the CPU which is doing the single stepping*/
81010 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81011 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81012
81013 /*
81014 * If you are debugging a problem where roundup (the collection of
81015 @@ -541,7 +541,7 @@ return_normal:
81016 * kernel will only try for the value of sstep_tries before
81017 * giving up and continuing on.
81018 */
81019 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81020 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81021 (kgdb_info[cpu].task &&
81022 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81023 atomic_set(&kgdb_active, -1);
81024 @@ -635,8 +635,8 @@ cpu_master_loop:
81025 }
81026
81027 kgdb_restore:
81028 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81029 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81030 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81031 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81032 if (kgdb_info[sstep_cpu].task)
81033 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81034 else
81035 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81036 static void kgdb_tasklet_bpt(unsigned long ing)
81037 {
81038 kgdb_breakpoint();
81039 - atomic_set(&kgdb_break_tasklet_var, 0);
81040 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81041 }
81042
81043 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81044
81045 void kgdb_schedule_breakpoint(void)
81046 {
81047 - if (atomic_read(&kgdb_break_tasklet_var) ||
81048 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81049 atomic_read(&kgdb_active) != -1 ||
81050 atomic_read(&kgdb_setting_breakpoint))
81051 return;
81052 - atomic_inc(&kgdb_break_tasklet_var);
81053 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81054 tasklet_schedule(&kgdb_tasklet_breakpoint);
81055 }
81056 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81057 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81058 index 00eb8f7..d7e3244 100644
81059 --- a/kernel/debug/kdb/kdb_main.c
81060 +++ b/kernel/debug/kdb/kdb_main.c
81061 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81062 continue;
81063
81064 kdb_printf("%-20s%8u 0x%p ", mod->name,
81065 - mod->core_size, (void *)mod);
81066 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81067 #ifdef CONFIG_MODULE_UNLOAD
81068 kdb_printf("%4ld ", module_refcount(mod));
81069 #endif
81070 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81071 kdb_printf(" (Loading)");
81072 else
81073 kdb_printf(" (Live)");
81074 - kdb_printf(" 0x%p", mod->module_core);
81075 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81076
81077 #ifdef CONFIG_MODULE_UNLOAD
81078 {
81079 diff --git a/kernel/events/core.c b/kernel/events/core.c
81080 index 953c143..5646bb1 100644
81081 --- a/kernel/events/core.c
81082 +++ b/kernel/events/core.c
81083 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
81084 * 0 - disallow raw tracepoint access for unpriv
81085 * 1 - disallow cpu events for unpriv
81086 * 2 - disallow kernel profiling for unpriv
81087 + * 3 - disallow all unpriv perf event use
81088 */
81089 -int sysctl_perf_event_paranoid __read_mostly = 1;
81090 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81091 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81092 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81093 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81094 +#else
81095 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81096 +#endif
81097
81098 /* Minimum for 512 kiB + 1 user control page */
81099 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81100 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
81101 update_perf_cpu_limits();
81102 }
81103
81104 -static atomic64_t perf_event_id;
81105 +static atomic64_unchecked_t perf_event_id;
81106
81107 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81108 enum event_type_t event_type);
81109 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
81110
81111 static inline u64 perf_event_count(struct perf_event *event)
81112 {
81113 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81114 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81115 }
81116
81117 static u64 perf_event_read(struct perf_event *event)
81118 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81119 mutex_lock(&event->child_mutex);
81120 total += perf_event_read(event);
81121 *enabled += event->total_time_enabled +
81122 - atomic64_read(&event->child_total_time_enabled);
81123 + atomic64_read_unchecked(&event->child_total_time_enabled);
81124 *running += event->total_time_running +
81125 - atomic64_read(&event->child_total_time_running);
81126 + atomic64_read_unchecked(&event->child_total_time_running);
81127
81128 list_for_each_entry(child, &event->child_list, child_list) {
81129 total += perf_event_read(child);
81130 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
81131 userpg->offset -= local64_read(&event->hw.prev_count);
81132
81133 userpg->time_enabled = enabled +
81134 - atomic64_read(&event->child_total_time_enabled);
81135 + atomic64_read_unchecked(&event->child_total_time_enabled);
81136
81137 userpg->time_running = running +
81138 - atomic64_read(&event->child_total_time_running);
81139 + atomic64_read_unchecked(&event->child_total_time_running);
81140
81141 arch_perf_update_userpage(userpg, now);
81142
81143 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81144
81145 /* Data. */
81146 sp = perf_user_stack_pointer(regs);
81147 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81148 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81149 dyn_size = dump_size - rem;
81150
81151 perf_output_skip(handle, rem);
81152 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81153 values[n++] = perf_event_count(event);
81154 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81155 values[n++] = enabled +
81156 - atomic64_read(&event->child_total_time_enabled);
81157 + atomic64_read_unchecked(&event->child_total_time_enabled);
81158 }
81159 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81160 values[n++] = running +
81161 - atomic64_read(&event->child_total_time_running);
81162 + atomic64_read_unchecked(&event->child_total_time_running);
81163 }
81164 if (read_format & PERF_FORMAT_ID)
81165 values[n++] = primary_event_id(event);
81166 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81167 * need to add enough zero bytes after the string to handle
81168 * the 64bit alignment we do later.
81169 */
81170 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81171 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81172 if (!buf) {
81173 name = strncpy(tmp, "//enomem", sizeof(tmp));
81174 goto got_name;
81175 }
81176 - name = d_path(&file->f_path, buf, PATH_MAX);
81177 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81178 if (IS_ERR(name)) {
81179 name = strncpy(tmp, "//toolong", sizeof(tmp));
81180 goto got_name;
81181 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81182 event->parent = parent_event;
81183
81184 event->ns = get_pid_ns(task_active_pid_ns(current));
81185 - event->id = atomic64_inc_return(&perf_event_id);
81186 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81187
81188 event->state = PERF_EVENT_STATE_INACTIVE;
81189
81190 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
81191 if (flags & ~PERF_FLAG_ALL)
81192 return -EINVAL;
81193
81194 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81195 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81196 + return -EACCES;
81197 +#endif
81198 +
81199 err = perf_copy_attr(attr_uptr, &attr);
81200 if (err)
81201 return err;
81202 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
81203 /*
81204 * Add back the child's count to the parent's count:
81205 */
81206 - atomic64_add(child_val, &parent_event->child_count);
81207 - atomic64_add(child_event->total_time_enabled,
81208 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81209 + atomic64_add_unchecked(child_event->total_time_enabled,
81210 &parent_event->child_total_time_enabled);
81211 - atomic64_add(child_event->total_time_running,
81212 + atomic64_add_unchecked(child_event->total_time_running,
81213 &parent_event->child_total_time_running);
81214
81215 /*
81216 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81217 index ca65997..60df03d 100644
81218 --- a/kernel/events/internal.h
81219 +++ b/kernel/events/internal.h
81220 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81221 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81222 }
81223
81224 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81225 -static inline unsigned int \
81226 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81227 +static inline unsigned long \
81228 func_name(struct perf_output_handle *handle, \
81229 - const void *buf, unsigned int len) \
81230 + const void user *buf, unsigned long len) \
81231 { \
81232 unsigned long size, written; \
81233 \
81234 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81235 return n;
81236 }
81237
81238 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81239 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81240
81241 #define MEMCPY_SKIP(dst, src, n) (n)
81242
81243 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81244 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81245
81246 #ifndef arch_perf_out_copy_user
81247 #define arch_perf_out_copy_user __copy_from_user_inatomic
81248 #endif
81249
81250 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81251 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81252
81253 /* Callchain handling */
81254 extern struct perf_callchain_entry *
81255 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81256 index ad8e1bd..fed7ba9 100644
81257 --- a/kernel/events/uprobes.c
81258 +++ b/kernel/events/uprobes.c
81259 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
81260 {
81261 struct page *page;
81262 uprobe_opcode_t opcode;
81263 - int result;
81264 + long result;
81265
81266 pagefault_disable();
81267 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
81268 diff --git a/kernel/exit.c b/kernel/exit.c
81269 index a949819..a5f127d 100644
81270 --- a/kernel/exit.c
81271 +++ b/kernel/exit.c
81272 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
81273 struct task_struct *leader;
81274 int zap_leader;
81275 repeat:
81276 +#ifdef CONFIG_NET
81277 + gr_del_task_from_ip_table(p);
81278 +#endif
81279 +
81280 /* don't need to get the RCU readlock here - the process is dead and
81281 * can't be modifying its own credentials. But shut RCU-lockdep up */
81282 rcu_read_lock();
81283 @@ -329,7 +333,7 @@ int allow_signal(int sig)
81284 * know it'll be handled, so that they don't get converted to
81285 * SIGKILL or just silently dropped.
81286 */
81287 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
81288 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
81289 recalc_sigpending();
81290 spin_unlock_irq(&current->sighand->siglock);
81291 return 0;
81292 @@ -698,6 +702,8 @@ void do_exit(long code)
81293 struct task_struct *tsk = current;
81294 int group_dead;
81295
81296 + set_fs(USER_DS);
81297 +
81298 profile_task_exit(tsk);
81299
81300 WARN_ON(blk_needs_flush_plug(tsk));
81301 @@ -714,7 +720,6 @@ void do_exit(long code)
81302 * mm_release()->clear_child_tid() from writing to a user-controlled
81303 * kernel address.
81304 */
81305 - set_fs(USER_DS);
81306
81307 ptrace_event(PTRACE_EVENT_EXIT, code);
81308
81309 @@ -773,6 +778,9 @@ void do_exit(long code)
81310 tsk->exit_code = code;
81311 taskstats_exit(tsk, group_dead);
81312
81313 + gr_acl_handle_psacct(tsk, code);
81314 + gr_acl_handle_exit();
81315 +
81316 exit_mm(tsk);
81317
81318 if (group_dead)
81319 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
81320 * Take down every thread in the group. This is called by fatal signals
81321 * as well as by sys_exit_group (below).
81322 */
81323 -void
81324 +__noreturn void
81325 do_group_exit(int exit_code)
81326 {
81327 struct signal_struct *sig = current->signal;
81328 diff --git a/kernel/fork.c b/kernel/fork.c
81329 index 086fe73..72c1122 100644
81330 --- a/kernel/fork.c
81331 +++ b/kernel/fork.c
81332 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
81333 *stackend = STACK_END_MAGIC; /* for overflow detection */
81334
81335 #ifdef CONFIG_CC_STACKPROTECTOR
81336 - tsk->stack_canary = get_random_int();
81337 + tsk->stack_canary = pax_get_random_long();
81338 #endif
81339
81340 /*
81341 @@ -345,12 +345,80 @@ free_tsk:
81342 }
81343
81344 #ifdef CONFIG_MMU
81345 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81346 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
81347 +{
81348 + struct vm_area_struct *tmp;
81349 + unsigned long charge;
81350 + struct file *file;
81351 + int retval;
81352 +
81353 + charge = 0;
81354 + if (mpnt->vm_flags & VM_ACCOUNT) {
81355 + unsigned long len = vma_pages(mpnt);
81356 +
81357 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81358 + goto fail_nomem;
81359 + charge = len;
81360 + }
81361 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81362 + if (!tmp)
81363 + goto fail_nomem;
81364 + *tmp = *mpnt;
81365 + tmp->vm_mm = mm;
81366 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
81367 + retval = vma_dup_policy(mpnt, tmp);
81368 + if (retval)
81369 + goto fail_nomem_policy;
81370 + if (anon_vma_fork(tmp, mpnt))
81371 + goto fail_nomem_anon_vma_fork;
81372 + tmp->vm_flags &= ~VM_LOCKED;
81373 + tmp->vm_next = tmp->vm_prev = NULL;
81374 + tmp->vm_mirror = NULL;
81375 + file = tmp->vm_file;
81376 + if (file) {
81377 + struct inode *inode = file_inode(file);
81378 + struct address_space *mapping = file->f_mapping;
81379 +
81380 + get_file(file);
81381 + if (tmp->vm_flags & VM_DENYWRITE)
81382 + atomic_dec(&inode->i_writecount);
81383 + mutex_lock(&mapping->i_mmap_mutex);
81384 + if (tmp->vm_flags & VM_SHARED)
81385 + mapping->i_mmap_writable++;
81386 + flush_dcache_mmap_lock(mapping);
81387 + /* insert tmp into the share list, just after mpnt */
81388 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81389 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
81390 + else
81391 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
81392 + flush_dcache_mmap_unlock(mapping);
81393 + mutex_unlock(&mapping->i_mmap_mutex);
81394 + }
81395 +
81396 + /*
81397 + * Clear hugetlb-related page reserves for children. This only
81398 + * affects MAP_PRIVATE mappings. Faults generated by the child
81399 + * are not guaranteed to succeed, even if read-only
81400 + */
81401 + if (is_vm_hugetlb_page(tmp))
81402 + reset_vma_resv_huge_pages(tmp);
81403 +
81404 + return tmp;
81405 +
81406 +fail_nomem_anon_vma_fork:
81407 + mpol_put(vma_policy(tmp));
81408 +fail_nomem_policy:
81409 + kmem_cache_free(vm_area_cachep, tmp);
81410 +fail_nomem:
81411 + vm_unacct_memory(charge);
81412 + return NULL;
81413 +}
81414 +
81415 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81416 {
81417 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
81418 struct rb_node **rb_link, *rb_parent;
81419 int retval;
81420 - unsigned long charge;
81421
81422 uprobe_start_dup_mmap();
81423 down_write(&oldmm->mmap_sem);
81424 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81425
81426 prev = NULL;
81427 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
81428 - struct file *file;
81429 -
81430 if (mpnt->vm_flags & VM_DONTCOPY) {
81431 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
81432 -vma_pages(mpnt));
81433 continue;
81434 }
81435 - charge = 0;
81436 - if (mpnt->vm_flags & VM_ACCOUNT) {
81437 - unsigned long len = vma_pages(mpnt);
81438 -
81439 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81440 - goto fail_nomem;
81441 - charge = len;
81442 - }
81443 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81444 - if (!tmp)
81445 - goto fail_nomem;
81446 - *tmp = *mpnt;
81447 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
81448 - retval = vma_dup_policy(mpnt, tmp);
81449 - if (retval)
81450 - goto fail_nomem_policy;
81451 - tmp->vm_mm = mm;
81452 - if (anon_vma_fork(tmp, mpnt))
81453 - goto fail_nomem_anon_vma_fork;
81454 - tmp->vm_flags &= ~VM_LOCKED;
81455 - tmp->vm_next = tmp->vm_prev = NULL;
81456 - file = tmp->vm_file;
81457 - if (file) {
81458 - struct inode *inode = file_inode(file);
81459 - struct address_space *mapping = file->f_mapping;
81460 -
81461 - get_file(file);
81462 - if (tmp->vm_flags & VM_DENYWRITE)
81463 - atomic_dec(&inode->i_writecount);
81464 - mutex_lock(&mapping->i_mmap_mutex);
81465 - if (tmp->vm_flags & VM_SHARED)
81466 - mapping->i_mmap_writable++;
81467 - flush_dcache_mmap_lock(mapping);
81468 - /* insert tmp into the share list, just after mpnt */
81469 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81470 - vma_nonlinear_insert(tmp,
81471 - &mapping->i_mmap_nonlinear);
81472 - else
81473 - vma_interval_tree_insert_after(tmp, mpnt,
81474 - &mapping->i_mmap);
81475 - flush_dcache_mmap_unlock(mapping);
81476 - mutex_unlock(&mapping->i_mmap_mutex);
81477 + tmp = dup_vma(mm, oldmm, mpnt);
81478 + if (!tmp) {
81479 + retval = -ENOMEM;
81480 + goto out;
81481 }
81482
81483 /*
81484 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81485 if (retval)
81486 goto out;
81487 }
81488 +
81489 +#ifdef CONFIG_PAX_SEGMEXEC
81490 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
81491 + struct vm_area_struct *mpnt_m;
81492 +
81493 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
81494 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
81495 +
81496 + if (!mpnt->vm_mirror)
81497 + continue;
81498 +
81499 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
81500 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
81501 + mpnt->vm_mirror = mpnt_m;
81502 + } else {
81503 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
81504 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
81505 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
81506 + mpnt->vm_mirror->vm_mirror = mpnt;
81507 + }
81508 + }
81509 + BUG_ON(mpnt_m);
81510 + }
81511 +#endif
81512 +
81513 /* a new mm has just been created */
81514 arch_dup_mmap(oldmm, mm);
81515 retval = 0;
81516 @@ -468,14 +521,6 @@ out:
81517 up_write(&oldmm->mmap_sem);
81518 uprobe_end_dup_mmap();
81519 return retval;
81520 -fail_nomem_anon_vma_fork:
81521 - mpol_put(vma_policy(tmp));
81522 -fail_nomem_policy:
81523 - kmem_cache_free(vm_area_cachep, tmp);
81524 -fail_nomem:
81525 - retval = -ENOMEM;
81526 - vm_unacct_memory(charge);
81527 - goto out;
81528 }
81529
81530 static inline int mm_alloc_pgd(struct mm_struct *mm)
81531 @@ -688,8 +733,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
81532 return ERR_PTR(err);
81533
81534 mm = get_task_mm(task);
81535 - if (mm && mm != current->mm &&
81536 - !ptrace_may_access(task, mode)) {
81537 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
81538 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
81539 mmput(mm);
81540 mm = ERR_PTR(-EACCES);
81541 }
81542 @@ -911,13 +956,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
81543 spin_unlock(&fs->lock);
81544 return -EAGAIN;
81545 }
81546 - fs->users++;
81547 + atomic_inc(&fs->users);
81548 spin_unlock(&fs->lock);
81549 return 0;
81550 }
81551 tsk->fs = copy_fs_struct(fs);
81552 if (!tsk->fs)
81553 return -ENOMEM;
81554 + /* Carry through gr_chroot_dentry and is_chrooted instead
81555 + of recomputing it here. Already copied when the task struct
81556 + is duplicated. This allows pivot_root to not be treated as
81557 + a chroot
81558 + */
81559 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
81560 +
81561 return 0;
81562 }
81563
81564 @@ -1128,7 +1180,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
81565 * parts of the process environment (as per the clone
81566 * flags). The actual kick-off is left to the caller.
81567 */
81568 -static struct task_struct *copy_process(unsigned long clone_flags,
81569 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
81570 unsigned long stack_start,
81571 unsigned long stack_size,
81572 int __user *child_tidptr,
81573 @@ -1200,6 +1252,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81574 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
81575 #endif
81576 retval = -EAGAIN;
81577 +
81578 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
81579 +
81580 if (atomic_read(&p->real_cred->user->processes) >=
81581 task_rlimit(p, RLIMIT_NPROC)) {
81582 if (p->real_cred->user != INIT_USER &&
81583 @@ -1449,6 +1504,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81584 goto bad_fork_free_pid;
81585 }
81586
81587 + /* synchronizes with gr_set_acls()
81588 + we need to call this past the point of no return for fork()
81589 + */
81590 + gr_copy_label(p);
81591 +
81592 if (likely(p->pid)) {
81593 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
81594
81595 @@ -1534,6 +1594,8 @@ bad_fork_cleanup_count:
81596 bad_fork_free:
81597 free_task(p);
81598 fork_out:
81599 + gr_log_forkfail(retval);
81600 +
81601 return ERR_PTR(retval);
81602 }
81603
81604 @@ -1595,6 +1657,7 @@ long do_fork(unsigned long clone_flags,
81605
81606 p = copy_process(clone_flags, stack_start, stack_size,
81607 child_tidptr, NULL, trace);
81608 + add_latent_entropy();
81609 /*
81610 * Do this prior waking up the new thread - the thread pointer
81611 * might get invalid after that point, if the thread exits quickly.
81612 @@ -1609,6 +1672,8 @@ long do_fork(unsigned long clone_flags,
81613 if (clone_flags & CLONE_PARENT_SETTID)
81614 put_user(nr, parent_tidptr);
81615
81616 + gr_handle_brute_check();
81617 +
81618 if (clone_flags & CLONE_VFORK) {
81619 p->vfork_done = &vfork;
81620 init_completion(&vfork);
81621 @@ -1725,7 +1790,7 @@ void __init proc_caches_init(void)
81622 mm_cachep = kmem_cache_create("mm_struct",
81623 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81624 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81625 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81626 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81627 mmap_init();
81628 nsproxy_cache_init();
81629 }
81630 @@ -1765,7 +1830,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81631 return 0;
81632
81633 /* don't need lock here; in the worst case we'll do useless copy */
81634 - if (fs->users == 1)
81635 + if (atomic_read(&fs->users) == 1)
81636 return 0;
81637
81638 *new_fsp = copy_fs_struct(fs);
81639 @@ -1872,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
81640 fs = current->fs;
81641 spin_lock(&fs->lock);
81642 current->fs = new_fs;
81643 - if (--fs->users)
81644 + gr_set_chroot_entries(current, &current->fs->root);
81645 + if (atomic_dec_return(&fs->users))
81646 new_fs = NULL;
81647 else
81648 new_fs = fs;
81649 diff --git a/kernel/futex.c b/kernel/futex.c
81650 index c3a1a55..e32b4a98 100644
81651 --- a/kernel/futex.c
81652 +++ b/kernel/futex.c
81653 @@ -54,6 +54,7 @@
81654 #include <linux/mount.h>
81655 #include <linux/pagemap.h>
81656 #include <linux/syscalls.h>
81657 +#include <linux/ptrace.h>
81658 #include <linux/signal.h>
81659 #include <linux/export.h>
81660 #include <linux/magic.h>
81661 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
81662 struct page *page, *page_head;
81663 int err, ro = 0;
81664
81665 +#ifdef CONFIG_PAX_SEGMEXEC
81666 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
81667 + return -EFAULT;
81668 +#endif
81669 +
81670 /*
81671 * The futex address must be "naturally" aligned.
81672 */
81673 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
81674
81675 static int get_futex_value_locked(u32 *dest, u32 __user *from)
81676 {
81677 - int ret;
81678 + unsigned long ret;
81679
81680 pagefault_disable();
81681 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
81682 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
81683 {
81684 u32 curval;
81685 int i;
81686 + mm_segment_t oldfs;
81687
81688 /*
81689 * This will fail and we want it. Some arch implementations do
81690 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
81691 * implementation, the non-functional ones will return
81692 * -ENOSYS.
81693 */
81694 + oldfs = get_fs();
81695 + set_fs(USER_DS);
81696 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
81697 futex_cmpxchg_enabled = 1;
81698 + set_fs(oldfs);
81699
81700 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
81701 plist_head_init(&futex_queues[i].chain);
81702 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
81703 index f9f44fd..29885e4 100644
81704 --- a/kernel/futex_compat.c
81705 +++ b/kernel/futex_compat.c
81706 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
81707 return 0;
81708 }
81709
81710 -static void __user *futex_uaddr(struct robust_list __user *entry,
81711 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
81712 compat_long_t futex_offset)
81713 {
81714 compat_uptr_t base = ptr_to_compat(entry);
81715 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
81716 index 9b22d03..6295b62 100644
81717 --- a/kernel/gcov/base.c
81718 +++ b/kernel/gcov/base.c
81719 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
81720 }
81721
81722 #ifdef CONFIG_MODULES
81723 -static inline int within(void *addr, void *start, unsigned long size)
81724 -{
81725 - return ((addr >= start) && (addr < start + size));
81726 -}
81727 -
81728 /* Update list and generate events when modules are unloaded. */
81729 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81730 void *data)
81731 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81732 prev = NULL;
81733 /* Remove entries located in module from linked list. */
81734 for (info = gcov_info_head; info; info = info->next) {
81735 - if (within(info, mod->module_core, mod->core_size)) {
81736 + if (within_module_core_rw((unsigned long)info, mod)) {
81737 if (prev)
81738 prev->next = info->next;
81739 else
81740 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
81741 index 383319b..56ebb13 100644
81742 --- a/kernel/hrtimer.c
81743 +++ b/kernel/hrtimer.c
81744 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
81745 local_irq_restore(flags);
81746 }
81747
81748 -static void run_hrtimer_softirq(struct softirq_action *h)
81749 +static __latent_entropy void run_hrtimer_softirq(void)
81750 {
81751 hrtimer_peek_ahead_timers();
81752 }
81753 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
81754 index 55fcce6..0e4cf34 100644
81755 --- a/kernel/irq_work.c
81756 +++ b/kernel/irq_work.c
81757 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
81758 return NOTIFY_OK;
81759 }
81760
81761 -static struct notifier_block cpu_notify;
81762 +static struct notifier_block cpu_notify = {
81763 + .notifier_call = irq_work_cpu_notify,
81764 + .priority = 0,
81765 +};
81766
81767 static __init int irq_work_init_cpu_notifier(void)
81768 {
81769 - cpu_notify.notifier_call = irq_work_cpu_notify;
81770 - cpu_notify.priority = 0;
81771 register_cpu_notifier(&cpu_notify);
81772 return 0;
81773 }
81774 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
81775 index 297a924..7290070 100644
81776 --- a/kernel/jump_label.c
81777 +++ b/kernel/jump_label.c
81778 @@ -14,6 +14,7 @@
81779 #include <linux/err.h>
81780 #include <linux/static_key.h>
81781 #include <linux/jump_label_ratelimit.h>
81782 +#include <linux/mm.h>
81783
81784 #ifdef HAVE_JUMP_LABEL
81785
81786 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
81787
81788 size = (((unsigned long)stop - (unsigned long)start)
81789 / sizeof(struct jump_entry));
81790 + pax_open_kernel();
81791 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
81792 + pax_close_kernel();
81793 }
81794
81795 static void jump_label_update(struct static_key *key, int enable);
81796 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
81797 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
81798 struct jump_entry *iter;
81799
81800 + pax_open_kernel();
81801 for (iter = iter_start; iter < iter_stop; iter++) {
81802 if (within_module_init(iter->code, mod))
81803 iter->code = 0;
81804 }
81805 + pax_close_kernel();
81806 }
81807
81808 static int
81809 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
81810 index 3127ad5..159d880 100644
81811 --- a/kernel/kallsyms.c
81812 +++ b/kernel/kallsyms.c
81813 @@ -11,6 +11,9 @@
81814 * Changed the compression method from stem compression to "table lookup"
81815 * compression (see scripts/kallsyms.c for a more complete description)
81816 */
81817 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81818 +#define __INCLUDED_BY_HIDESYM 1
81819 +#endif
81820 #include <linux/kallsyms.h>
81821 #include <linux/module.h>
81822 #include <linux/init.h>
81823 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
81824
81825 static inline int is_kernel_inittext(unsigned long addr)
81826 {
81827 + if (system_state != SYSTEM_BOOTING)
81828 + return 0;
81829 +
81830 if (addr >= (unsigned long)_sinittext
81831 && addr <= (unsigned long)_einittext)
81832 return 1;
81833 return 0;
81834 }
81835
81836 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81837 +#ifdef CONFIG_MODULES
81838 +static inline int is_module_text(unsigned long addr)
81839 +{
81840 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
81841 + return 1;
81842 +
81843 + addr = ktla_ktva(addr);
81844 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
81845 +}
81846 +#else
81847 +static inline int is_module_text(unsigned long addr)
81848 +{
81849 + return 0;
81850 +}
81851 +#endif
81852 +#endif
81853 +
81854 static inline int is_kernel_text(unsigned long addr)
81855 {
81856 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
81857 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
81858
81859 static inline int is_kernel(unsigned long addr)
81860 {
81861 +
81862 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81863 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
81864 + return 1;
81865 +
81866 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
81867 +#else
81868 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
81869 +#endif
81870 +
81871 return 1;
81872 return in_gate_area_no_mm(addr);
81873 }
81874
81875 static int is_ksym_addr(unsigned long addr)
81876 {
81877 +
81878 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81879 + if (is_module_text(addr))
81880 + return 0;
81881 +#endif
81882 +
81883 if (all_var)
81884 return is_kernel(addr);
81885
81886 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
81887
81888 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
81889 {
81890 - iter->name[0] = '\0';
81891 iter->nameoff = get_symbol_offset(new_pos);
81892 iter->pos = new_pos;
81893 }
81894 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
81895 {
81896 struct kallsym_iter *iter = m->private;
81897
81898 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81899 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
81900 + return 0;
81901 +#endif
81902 +
81903 /* Some debugging symbols have no name. Ignore them. */
81904 if (!iter->name[0])
81905 return 0;
81906 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
81907 */
81908 type = iter->exported ? toupper(iter->type) :
81909 tolower(iter->type);
81910 +
81911 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
81912 type, iter->name, iter->module_name);
81913 } else
81914 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
81915 struct kallsym_iter *iter;
81916 int ret;
81917
81918 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81919 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81920 if (!iter)
81921 return -ENOMEM;
81922 reset_iter(iter, 0);
81923 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81924 index e30ac0f..3528cac 100644
81925 --- a/kernel/kcmp.c
81926 +++ b/kernel/kcmp.c
81927 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81928 struct task_struct *task1, *task2;
81929 int ret;
81930
81931 +#ifdef CONFIG_GRKERNSEC
81932 + return -ENOSYS;
81933 +#endif
81934 +
81935 rcu_read_lock();
81936
81937 /*
81938 diff --git a/kernel/kexec.c b/kernel/kexec.c
81939 index 2a74f30..d139351 100644
81940 --- a/kernel/kexec.c
81941 +++ b/kernel/kexec.c
81942 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81943 unsigned long flags)
81944 {
81945 struct compat_kexec_segment in;
81946 - struct kexec_segment out, __user *ksegments;
81947 + struct kexec_segment out;
81948 + struct kexec_segment __user *ksegments;
81949 unsigned long i, result;
81950
81951 /* Don't allow clients that don't understand the native
81952 diff --git a/kernel/kmod.c b/kernel/kmod.c
81953 index b086006..6d2e579 100644
81954 --- a/kernel/kmod.c
81955 +++ b/kernel/kmod.c
81956 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81957 kfree(info->argv);
81958 }
81959
81960 -static int call_modprobe(char *module_name, int wait)
81961 +static int call_modprobe(char *module_name, char *module_param, int wait)
81962 {
81963 struct subprocess_info *info;
81964 static char *envp[] = {
81965 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81966 NULL
81967 };
81968
81969 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81970 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81971 if (!argv)
81972 goto out;
81973
81974 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81975 argv[1] = "-q";
81976 argv[2] = "--";
81977 argv[3] = module_name; /* check free_modprobe_argv() */
81978 - argv[4] = NULL;
81979 + argv[4] = module_param;
81980 + argv[5] = NULL;
81981
81982 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81983 NULL, free_modprobe_argv, NULL);
81984 @@ -129,9 +130,8 @@ out:
81985 * If module auto-loading support is disabled then this function
81986 * becomes a no-operation.
81987 */
81988 -int __request_module(bool wait, const char *fmt, ...)
81989 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81990 {
81991 - va_list args;
81992 char module_name[MODULE_NAME_LEN];
81993 unsigned int max_modprobes;
81994 int ret;
81995 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81996 if (!modprobe_path[0])
81997 return 0;
81998
81999 - va_start(args, fmt);
82000 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82001 - va_end(args);
82002 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82003 if (ret >= MODULE_NAME_LEN)
82004 return -ENAMETOOLONG;
82005
82006 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
82007 if (ret)
82008 return ret;
82009
82010 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82011 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82012 + /* hack to workaround consolekit/udisks stupidity */
82013 + read_lock(&tasklist_lock);
82014 + if (!strcmp(current->comm, "mount") &&
82015 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82016 + read_unlock(&tasklist_lock);
82017 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82018 + return -EPERM;
82019 + }
82020 + read_unlock(&tasklist_lock);
82021 + }
82022 +#endif
82023 +
82024 /* If modprobe needs a service that is in a module, we get a recursive
82025 * loop. Limit the number of running kmod threads to max_threads/2 or
82026 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82027 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
82028
82029 trace_module_request(module_name, wait, _RET_IP_);
82030
82031 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82032 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82033
82034 atomic_dec(&kmod_concurrent);
82035 return ret;
82036 }
82037 +
82038 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82039 +{
82040 + va_list args;
82041 + int ret;
82042 +
82043 + va_start(args, fmt);
82044 + ret = ____request_module(wait, module_param, fmt, args);
82045 + va_end(args);
82046 +
82047 + return ret;
82048 +}
82049 +
82050 +int __request_module(bool wait, const char *fmt, ...)
82051 +{
82052 + va_list args;
82053 + int ret;
82054 +
82055 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82056 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82057 + char module_param[MODULE_NAME_LEN];
82058 +
82059 + memset(module_param, 0, sizeof(module_param));
82060 +
82061 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82062 +
82063 + va_start(args, fmt);
82064 + ret = ____request_module(wait, module_param, fmt, args);
82065 + va_end(args);
82066 +
82067 + return ret;
82068 + }
82069 +#endif
82070 +
82071 + va_start(args, fmt);
82072 + ret = ____request_module(wait, NULL, fmt, args);
82073 + va_end(args);
82074 +
82075 + return ret;
82076 +}
82077 +
82078 EXPORT_SYMBOL(__request_module);
82079 #endif /* CONFIG_MODULES */
82080
82081 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
82082 */
82083 set_user_nice(current, 0);
82084
82085 +#ifdef CONFIG_GRKERNSEC
82086 + /* this is race-free as far as userland is concerned as we copied
82087 + out the path to be used prior to this point and are now operating
82088 + on that copy
82089 + */
82090 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
82091 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
82092 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
82093 + retval = -EPERM;
82094 + goto fail;
82095 + }
82096 +#endif
82097 +
82098 retval = -ENOMEM;
82099 new = prepare_kernel_cred(current);
82100 if (!new)
82101 @@ -260,6 +326,10 @@ static int call_helper(void *data)
82102
82103 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
82104 {
82105 +#ifdef CONFIG_GRKERNSEC
82106 + kfree(info->path);
82107 + info->path = info->origpath;
82108 +#endif
82109 if (info->cleanup)
82110 (*info->cleanup)(info);
82111 kfree(info);
82112 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
82113 *
82114 * Thus the __user pointer cast is valid here.
82115 */
82116 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82117 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82118
82119 /*
82120 * If ret is 0, either ____call_usermodehelper failed and the
82121 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
82122 goto out;
82123
82124 INIT_WORK(&sub_info->work, __call_usermodehelper);
82125 +#ifdef CONFIG_GRKERNSEC
82126 + sub_info->origpath = path;
82127 + sub_info->path = kstrdup(path, gfp_mask);
82128 +#else
82129 sub_info->path = path;
82130 +#endif
82131 sub_info->argv = argv;
82132 sub_info->envp = envp;
82133
82134 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82135 static int proc_cap_handler(struct ctl_table *table, int write,
82136 void __user *buffer, size_t *lenp, loff_t *ppos)
82137 {
82138 - struct ctl_table t;
82139 + ctl_table_no_const t;
82140 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82141 kernel_cap_t new_cap;
82142 int err, i;
82143 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82144 index a0d367a..11c18b6 100644
82145 --- a/kernel/kprobes.c
82146 +++ b/kernel/kprobes.c
82147 @@ -31,6 +31,9 @@
82148 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82149 * <prasanna@in.ibm.com> added function-return probes.
82150 */
82151 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82152 +#define __INCLUDED_BY_HIDESYM 1
82153 +#endif
82154 #include <linux/kprobes.h>
82155 #include <linux/hash.h>
82156 #include <linux/init.h>
82157 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
82158
82159 static void *alloc_insn_page(void)
82160 {
82161 - return module_alloc(PAGE_SIZE);
82162 + return module_alloc_exec(PAGE_SIZE);
82163 }
82164
82165 static void free_insn_page(void *page)
82166 {
82167 - module_free(NULL, page);
82168 + module_free_exec(NULL, page);
82169 }
82170
82171 struct kprobe_insn_cache kprobe_insn_slots = {
82172 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
82173 {
82174 int i, err = 0;
82175 unsigned long offset = 0, size = 0;
82176 - char *modname, namebuf[128];
82177 + char *modname, namebuf[KSYM_NAME_LEN];
82178 const char *symbol_name;
82179 void *addr;
82180 struct kprobe_blackpoint *kb;
82181 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82182 kprobe_type = "k";
82183
82184 if (sym)
82185 - seq_printf(pi, "%p %s %s+0x%x %s ",
82186 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82187 p->addr, kprobe_type, sym, offset,
82188 (modname ? modname : " "));
82189 else
82190 - seq_printf(pi, "%p %s %p ",
82191 + seq_printf(pi, "%pK %s %pK ",
82192 p->addr, kprobe_type, p->addr);
82193
82194 if (!pp)
82195 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82196 const char *sym = NULL;
82197 unsigned int i = *(loff_t *) v;
82198 unsigned long offset = 0;
82199 - char *modname, namebuf[128];
82200 + char *modname, namebuf[KSYM_NAME_LEN];
82201
82202 head = &kprobe_table[i];
82203 preempt_disable();
82204 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82205 index 9659d38..bffd520 100644
82206 --- a/kernel/ksysfs.c
82207 +++ b/kernel/ksysfs.c
82208 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82209 {
82210 if (count+1 > UEVENT_HELPER_PATH_LEN)
82211 return -ENOENT;
82212 + if (!capable(CAP_SYS_ADMIN))
82213 + return -EPERM;
82214 memcpy(uevent_helper, buf, count);
82215 uevent_helper[count] = '\0';
82216 if (count && uevent_helper[count-1] == '\n')
82217 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82218 return count;
82219 }
82220
82221 -static struct bin_attribute notes_attr = {
82222 +static bin_attribute_no_const notes_attr __read_only = {
82223 .attr = {
82224 .name = "notes",
82225 .mode = S_IRUGO,
82226 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82227 index e16c45b..6f49c48 100644
82228 --- a/kernel/lockdep.c
82229 +++ b/kernel/lockdep.c
82230 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82231 end = (unsigned long) &_end,
82232 addr = (unsigned long) obj;
82233
82234 +#ifdef CONFIG_PAX_KERNEXEC
82235 + start = ktla_ktva(start);
82236 +#endif
82237 +
82238 /*
82239 * static variable?
82240 */
82241 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82242 if (!static_obj(lock->key)) {
82243 debug_locks_off();
82244 printk("INFO: trying to register non-static key.\n");
82245 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82246 printk("the code is fine but needs lockdep annotation.\n");
82247 printk("turning off the locking correctness validator.\n");
82248 dump_stack();
82249 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82250 if (!class)
82251 return 0;
82252 }
82253 - atomic_inc((atomic_t *)&class->ops);
82254 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82255 if (very_verbose(class)) {
82256 printk("\nacquire class [%p] %s", class->key, class->name);
82257 if (class->name_version > 1)
82258 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
82259 index b2c71c5..7b88d63 100644
82260 --- a/kernel/lockdep_proc.c
82261 +++ b/kernel/lockdep_proc.c
82262 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
82263 return 0;
82264 }
82265
82266 - seq_printf(m, "%p", class->key);
82267 + seq_printf(m, "%pK", class->key);
82268 #ifdef CONFIG_DEBUG_LOCKDEP
82269 seq_printf(m, " OPS:%8ld", class->ops);
82270 #endif
82271 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
82272
82273 list_for_each_entry(entry, &class->locks_after, entry) {
82274 if (entry->distance == 1) {
82275 - seq_printf(m, " -> [%p] ", entry->class->key);
82276 + seq_printf(m, " -> [%pK] ", entry->class->key);
82277 print_name(m, entry->class);
82278 seq_puts(m, "\n");
82279 }
82280 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
82281 if (!class->key)
82282 continue;
82283
82284 - seq_printf(m, "[%p] ", class->key);
82285 + seq_printf(m, "[%pK] ", class->key);
82286 print_name(m, class);
82287 seq_puts(m, "\n");
82288 }
82289 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82290 if (!i)
82291 seq_line(m, '-', 40-namelen, namelen);
82292
82293 - snprintf(ip, sizeof(ip), "[<%p>]",
82294 + snprintf(ip, sizeof(ip), "[<%pK>]",
82295 (void *)class->contention_point[i]);
82296 seq_printf(m, "%40s %14lu %29s %pS\n",
82297 name, stats->contention_point[i],
82298 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82299 if (!i)
82300 seq_line(m, '-', 40-namelen, namelen);
82301
82302 - snprintf(ip, sizeof(ip), "[<%p>]",
82303 + snprintf(ip, sizeof(ip), "[<%pK>]",
82304 (void *)class->contending_point[i]);
82305 seq_printf(m, "%40s %14lu %29s %pS\n",
82306 name, stats->contending_point[i],
82307 diff --git a/kernel/module.c b/kernel/module.c
82308 index dc58274..3ddfa55 100644
82309 --- a/kernel/module.c
82310 +++ b/kernel/module.c
82311 @@ -61,6 +61,7 @@
82312 #include <linux/pfn.h>
82313 #include <linux/bsearch.h>
82314 #include <linux/fips.h>
82315 +#include <linux/grsecurity.h>
82316 #include <uapi/linux/module.h>
82317 #include "module-internal.h"
82318
82319 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
82320
82321 /* Bounds of module allocation, for speeding __module_address.
82322 * Protected by module_mutex. */
82323 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
82324 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
82325 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
82326
82327 int register_module_notifier(struct notifier_block * nb)
82328 {
82329 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82330 return true;
82331
82332 list_for_each_entry_rcu(mod, &modules, list) {
82333 - struct symsearch arr[] = {
82334 + struct symsearch modarr[] = {
82335 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
82336 NOT_GPL_ONLY, false },
82337 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
82338 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82339 if (mod->state == MODULE_STATE_UNFORMED)
82340 continue;
82341
82342 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
82343 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
82344 return true;
82345 }
82346 return false;
82347 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
82348 if (!pcpusec->sh_size)
82349 return 0;
82350
82351 - if (align > PAGE_SIZE) {
82352 + if (align-1 >= PAGE_SIZE) {
82353 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
82354 mod->name, align, PAGE_SIZE);
82355 align = PAGE_SIZE;
82356 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
82357 static ssize_t show_coresize(struct module_attribute *mattr,
82358 struct module_kobject *mk, char *buffer)
82359 {
82360 - return sprintf(buffer, "%u\n", mk->mod->core_size);
82361 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
82362 }
82363
82364 static struct module_attribute modinfo_coresize =
82365 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
82366 static ssize_t show_initsize(struct module_attribute *mattr,
82367 struct module_kobject *mk, char *buffer)
82368 {
82369 - return sprintf(buffer, "%u\n", mk->mod->init_size);
82370 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
82371 }
82372
82373 static struct module_attribute modinfo_initsize =
82374 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
82375 */
82376 #ifdef CONFIG_SYSFS
82377
82378 -#ifdef CONFIG_KALLSYMS
82379 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82380 static inline bool sect_empty(const Elf_Shdr *sect)
82381 {
82382 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
82383 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
82384 {
82385 unsigned int notes, loaded, i;
82386 struct module_notes_attrs *notes_attrs;
82387 - struct bin_attribute *nattr;
82388 + bin_attribute_no_const *nattr;
82389
82390 /* failed to create section attributes, so can't create notes */
82391 if (!mod->sect_attrs)
82392 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
82393 static int module_add_modinfo_attrs(struct module *mod)
82394 {
82395 struct module_attribute *attr;
82396 - struct module_attribute *temp_attr;
82397 + module_attribute_no_const *temp_attr;
82398 int error = 0;
82399 int i;
82400
82401 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
82402
82403 static void unset_module_core_ro_nx(struct module *mod)
82404 {
82405 - set_page_attributes(mod->module_core + mod->core_text_size,
82406 - mod->module_core + mod->core_size,
82407 + set_page_attributes(mod->module_core_rw,
82408 + mod->module_core_rw + mod->core_size_rw,
82409 set_memory_x);
82410 - set_page_attributes(mod->module_core,
82411 - mod->module_core + mod->core_ro_size,
82412 + set_page_attributes(mod->module_core_rx,
82413 + mod->module_core_rx + mod->core_size_rx,
82414 set_memory_rw);
82415 }
82416
82417 static void unset_module_init_ro_nx(struct module *mod)
82418 {
82419 - set_page_attributes(mod->module_init + mod->init_text_size,
82420 - mod->module_init + mod->init_size,
82421 + set_page_attributes(mod->module_init_rw,
82422 + mod->module_init_rw + mod->init_size_rw,
82423 set_memory_x);
82424 - set_page_attributes(mod->module_init,
82425 - mod->module_init + mod->init_ro_size,
82426 + set_page_attributes(mod->module_init_rx,
82427 + mod->module_init_rx + mod->init_size_rx,
82428 set_memory_rw);
82429 }
82430
82431 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
82432 list_for_each_entry_rcu(mod, &modules, list) {
82433 if (mod->state == MODULE_STATE_UNFORMED)
82434 continue;
82435 - if ((mod->module_core) && (mod->core_text_size)) {
82436 - set_page_attributes(mod->module_core,
82437 - mod->module_core + mod->core_text_size,
82438 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82439 + set_page_attributes(mod->module_core_rx,
82440 + mod->module_core_rx + mod->core_size_rx,
82441 set_memory_rw);
82442 }
82443 - if ((mod->module_init) && (mod->init_text_size)) {
82444 - set_page_attributes(mod->module_init,
82445 - mod->module_init + mod->init_text_size,
82446 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82447 + set_page_attributes(mod->module_init_rx,
82448 + mod->module_init_rx + mod->init_size_rx,
82449 set_memory_rw);
82450 }
82451 }
82452 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
82453 list_for_each_entry_rcu(mod, &modules, list) {
82454 if (mod->state == MODULE_STATE_UNFORMED)
82455 continue;
82456 - if ((mod->module_core) && (mod->core_text_size)) {
82457 - set_page_attributes(mod->module_core,
82458 - mod->module_core + mod->core_text_size,
82459 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82460 + set_page_attributes(mod->module_core_rx,
82461 + mod->module_core_rx + mod->core_size_rx,
82462 set_memory_ro);
82463 }
82464 - if ((mod->module_init) && (mod->init_text_size)) {
82465 - set_page_attributes(mod->module_init,
82466 - mod->module_init + mod->init_text_size,
82467 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82468 + set_page_attributes(mod->module_init_rx,
82469 + mod->module_init_rx + mod->init_size_rx,
82470 set_memory_ro);
82471 }
82472 }
82473 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
82474
82475 /* This may be NULL, but that's OK */
82476 unset_module_init_ro_nx(mod);
82477 - module_free(mod, mod->module_init);
82478 + module_free(mod, mod->module_init_rw);
82479 + module_free_exec(mod, mod->module_init_rx);
82480 kfree(mod->args);
82481 percpu_modfree(mod);
82482
82483 /* Free lock-classes: */
82484 - lockdep_free_key_range(mod->module_core, mod->core_size);
82485 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
82486 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
82487
82488 /* Finally, free the core (containing the module structure) */
82489 unset_module_core_ro_nx(mod);
82490 - module_free(mod, mod->module_core);
82491 + module_free_exec(mod, mod->module_core_rx);
82492 + module_free(mod, mod->module_core_rw);
82493
82494 #ifdef CONFIG_MPU
82495 update_protections(current->mm);
82496 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82497 int ret = 0;
82498 const struct kernel_symbol *ksym;
82499
82500 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82501 + int is_fs_load = 0;
82502 + int register_filesystem_found = 0;
82503 + char *p;
82504 +
82505 + p = strstr(mod->args, "grsec_modharden_fs");
82506 + if (p) {
82507 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
82508 + /* copy \0 as well */
82509 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
82510 + is_fs_load = 1;
82511 + }
82512 +#endif
82513 +
82514 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
82515 const char *name = info->strtab + sym[i].st_name;
82516
82517 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82518 + /* it's a real shame this will never get ripped and copied
82519 + upstream! ;(
82520 + */
82521 + if (is_fs_load && !strcmp(name, "register_filesystem"))
82522 + register_filesystem_found = 1;
82523 +#endif
82524 +
82525 switch (sym[i].st_shndx) {
82526 case SHN_COMMON:
82527 /* We compiled with -fno-common. These are not
82528 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82529 ksym = resolve_symbol_wait(mod, info, name);
82530 /* Ok if resolved. */
82531 if (ksym && !IS_ERR(ksym)) {
82532 + pax_open_kernel();
82533 sym[i].st_value = ksym->value;
82534 + pax_close_kernel();
82535 break;
82536 }
82537
82538 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82539 secbase = (unsigned long)mod_percpu(mod);
82540 else
82541 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
82542 + pax_open_kernel();
82543 sym[i].st_value += secbase;
82544 + pax_close_kernel();
82545 break;
82546 }
82547 }
82548
82549 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82550 + if (is_fs_load && !register_filesystem_found) {
82551 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
82552 + ret = -EPERM;
82553 + }
82554 +#endif
82555 +
82556 return ret;
82557 }
82558
82559 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
82560 || s->sh_entsize != ~0UL
82561 || strstarts(sname, ".init"))
82562 continue;
82563 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
82564 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82565 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
82566 + else
82567 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
82568 pr_debug("\t%s\n", sname);
82569 }
82570 - switch (m) {
82571 - case 0: /* executable */
82572 - mod->core_size = debug_align(mod->core_size);
82573 - mod->core_text_size = mod->core_size;
82574 - break;
82575 - case 1: /* RO: text and ro-data */
82576 - mod->core_size = debug_align(mod->core_size);
82577 - mod->core_ro_size = mod->core_size;
82578 - break;
82579 - case 3: /* whole core */
82580 - mod->core_size = debug_align(mod->core_size);
82581 - break;
82582 - }
82583 }
82584
82585 pr_debug("Init section allocation order:\n");
82586 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
82587 || s->sh_entsize != ~0UL
82588 || !strstarts(sname, ".init"))
82589 continue;
82590 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
82591 - | INIT_OFFSET_MASK);
82592 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82593 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
82594 + else
82595 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
82596 + s->sh_entsize |= INIT_OFFSET_MASK;
82597 pr_debug("\t%s\n", sname);
82598 }
82599 - switch (m) {
82600 - case 0: /* executable */
82601 - mod->init_size = debug_align(mod->init_size);
82602 - mod->init_text_size = mod->init_size;
82603 - break;
82604 - case 1: /* RO: text and ro-data */
82605 - mod->init_size = debug_align(mod->init_size);
82606 - mod->init_ro_size = mod->init_size;
82607 - break;
82608 - case 3: /* whole init */
82609 - mod->init_size = debug_align(mod->init_size);
82610 - break;
82611 - }
82612 }
82613 }
82614
82615 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82616
82617 /* Put symbol section at end of init part of module. */
82618 symsect->sh_flags |= SHF_ALLOC;
82619 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82620 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82621 info->index.sym) | INIT_OFFSET_MASK;
82622 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82623
82624 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82625 }
82626
82627 /* Append room for core symbols at end of core part. */
82628 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82629 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82630 - mod->core_size += strtab_size;
82631 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82632 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82633 + mod->core_size_rx += strtab_size;
82634
82635 /* Put string table section at end of init part of module. */
82636 strsect->sh_flags |= SHF_ALLOC;
82637 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82638 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82639 info->index.str) | INIT_OFFSET_MASK;
82640 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82641 }
82642 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82643 /* Make sure we get permanent strtab: don't use info->strtab. */
82644 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82645
82646 + pax_open_kernel();
82647 +
82648 /* Set types up while we still have access to sections. */
82649 for (i = 0; i < mod->num_symtab; i++)
82650 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82651
82652 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82653 - mod->core_strtab = s = mod->module_core + info->stroffs;
82654 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82655 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82656 src = mod->symtab;
82657 for (ndst = i = 0; i < mod->num_symtab; i++) {
82658 if (i == 0 ||
82659 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82660 }
82661 }
82662 mod->core_num_syms = ndst;
82663 +
82664 + pax_close_kernel();
82665 }
82666 #else
82667 static inline void layout_symtab(struct module *mod, struct load_info *info)
82668 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
82669 return vmalloc_exec(size);
82670 }
82671
82672 -static void *module_alloc_update_bounds(unsigned long size)
82673 +static void *module_alloc_update_bounds_rw(unsigned long size)
82674 {
82675 void *ret = module_alloc(size);
82676
82677 if (ret) {
82678 mutex_lock(&module_mutex);
82679 /* Update module bounds. */
82680 - if ((unsigned long)ret < module_addr_min)
82681 - module_addr_min = (unsigned long)ret;
82682 - if ((unsigned long)ret + size > module_addr_max)
82683 - module_addr_max = (unsigned long)ret + size;
82684 + if ((unsigned long)ret < module_addr_min_rw)
82685 + module_addr_min_rw = (unsigned long)ret;
82686 + if ((unsigned long)ret + size > module_addr_max_rw)
82687 + module_addr_max_rw = (unsigned long)ret + size;
82688 + mutex_unlock(&module_mutex);
82689 + }
82690 + return ret;
82691 +}
82692 +
82693 +static void *module_alloc_update_bounds_rx(unsigned long size)
82694 +{
82695 + void *ret = module_alloc_exec(size);
82696 +
82697 + if (ret) {
82698 + mutex_lock(&module_mutex);
82699 + /* Update module bounds. */
82700 + if ((unsigned long)ret < module_addr_min_rx)
82701 + module_addr_min_rx = (unsigned long)ret;
82702 + if ((unsigned long)ret + size > module_addr_max_rx)
82703 + module_addr_max_rx = (unsigned long)ret + size;
82704 mutex_unlock(&module_mutex);
82705 }
82706 return ret;
82707 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
82708 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82709 {
82710 const char *modmagic = get_modinfo(info, "vermagic");
82711 + const char *license = get_modinfo(info, "license");
82712 int err;
82713
82714 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
82715 + if (!license || !license_is_gpl_compatible(license))
82716 + return -ENOEXEC;
82717 +#endif
82718 +
82719 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
82720 modmagic = NULL;
82721
82722 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82723 }
82724
82725 /* Set up license info based on the info section */
82726 - set_license(mod, get_modinfo(info, "license"));
82727 + set_license(mod, license);
82728
82729 return 0;
82730 }
82731 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
82732 void *ptr;
82733
82734 /* Do the allocs. */
82735 - ptr = module_alloc_update_bounds(mod->core_size);
82736 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
82737 /*
82738 * The pointer to this block is stored in the module structure
82739 * which is inside the block. Just mark it as not being a
82740 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
82741 if (!ptr)
82742 return -ENOMEM;
82743
82744 - memset(ptr, 0, mod->core_size);
82745 - mod->module_core = ptr;
82746 + memset(ptr, 0, mod->core_size_rw);
82747 + mod->module_core_rw = ptr;
82748
82749 - if (mod->init_size) {
82750 - ptr = module_alloc_update_bounds(mod->init_size);
82751 + if (mod->init_size_rw) {
82752 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
82753 /*
82754 * The pointer to this block is stored in the module structure
82755 * which is inside the block. This block doesn't need to be
82756 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
82757 */
82758 kmemleak_ignore(ptr);
82759 if (!ptr) {
82760 - module_free(mod, mod->module_core);
82761 + module_free(mod, mod->module_core_rw);
82762 return -ENOMEM;
82763 }
82764 - memset(ptr, 0, mod->init_size);
82765 - mod->module_init = ptr;
82766 + memset(ptr, 0, mod->init_size_rw);
82767 + mod->module_init_rw = ptr;
82768 } else
82769 - mod->module_init = NULL;
82770 + mod->module_init_rw = NULL;
82771 +
82772 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
82773 + kmemleak_not_leak(ptr);
82774 + if (!ptr) {
82775 + if (mod->module_init_rw)
82776 + module_free(mod, mod->module_init_rw);
82777 + module_free(mod, mod->module_core_rw);
82778 + return -ENOMEM;
82779 + }
82780 +
82781 + pax_open_kernel();
82782 + memset(ptr, 0, mod->core_size_rx);
82783 + pax_close_kernel();
82784 + mod->module_core_rx = ptr;
82785 +
82786 + if (mod->init_size_rx) {
82787 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
82788 + kmemleak_ignore(ptr);
82789 + if (!ptr && mod->init_size_rx) {
82790 + module_free_exec(mod, mod->module_core_rx);
82791 + if (mod->module_init_rw)
82792 + module_free(mod, mod->module_init_rw);
82793 + module_free(mod, mod->module_core_rw);
82794 + return -ENOMEM;
82795 + }
82796 +
82797 + pax_open_kernel();
82798 + memset(ptr, 0, mod->init_size_rx);
82799 + pax_close_kernel();
82800 + mod->module_init_rx = ptr;
82801 + } else
82802 + mod->module_init_rx = NULL;
82803
82804 /* Transfer each section which specifies SHF_ALLOC */
82805 pr_debug("final section addresses:\n");
82806 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
82807 if (!(shdr->sh_flags & SHF_ALLOC))
82808 continue;
82809
82810 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
82811 - dest = mod->module_init
82812 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82813 - else
82814 - dest = mod->module_core + shdr->sh_entsize;
82815 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
82816 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82817 + dest = mod->module_init_rw
82818 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82819 + else
82820 + dest = mod->module_init_rx
82821 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82822 + } else {
82823 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82824 + dest = mod->module_core_rw + shdr->sh_entsize;
82825 + else
82826 + dest = mod->module_core_rx + shdr->sh_entsize;
82827 + }
82828 +
82829 + if (shdr->sh_type != SHT_NOBITS) {
82830 +
82831 +#ifdef CONFIG_PAX_KERNEXEC
82832 +#ifdef CONFIG_X86_64
82833 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
82834 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
82835 +#endif
82836 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
82837 + pax_open_kernel();
82838 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82839 + pax_close_kernel();
82840 + } else
82841 +#endif
82842
82843 - if (shdr->sh_type != SHT_NOBITS)
82844 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82845 + }
82846 /* Update sh_addr to point to copy in image. */
82847 - shdr->sh_addr = (unsigned long)dest;
82848 +
82849 +#ifdef CONFIG_PAX_KERNEXEC
82850 + if (shdr->sh_flags & SHF_EXECINSTR)
82851 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
82852 + else
82853 +#endif
82854 +
82855 + shdr->sh_addr = (unsigned long)dest;
82856 pr_debug("\t0x%lx %s\n",
82857 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
82858 }
82859 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
82860 * Do it before processing of module parameters, so the module
82861 * can provide parameter accessor functions of its own.
82862 */
82863 - if (mod->module_init)
82864 - flush_icache_range((unsigned long)mod->module_init,
82865 - (unsigned long)mod->module_init
82866 - + mod->init_size);
82867 - flush_icache_range((unsigned long)mod->module_core,
82868 - (unsigned long)mod->module_core + mod->core_size);
82869 + if (mod->module_init_rx)
82870 + flush_icache_range((unsigned long)mod->module_init_rx,
82871 + (unsigned long)mod->module_init_rx
82872 + + mod->init_size_rx);
82873 + flush_icache_range((unsigned long)mod->module_core_rx,
82874 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
82875
82876 set_fs(old_fs);
82877 }
82878 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
82879 static void module_deallocate(struct module *mod, struct load_info *info)
82880 {
82881 percpu_modfree(mod);
82882 - module_free(mod, mod->module_init);
82883 - module_free(mod, mod->module_core);
82884 + module_free_exec(mod, mod->module_init_rx);
82885 + module_free_exec(mod, mod->module_core_rx);
82886 + module_free(mod, mod->module_init_rw);
82887 + module_free(mod, mod->module_core_rw);
82888 }
82889
82890 int __weak module_finalize(const Elf_Ehdr *hdr,
82891 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
82892 static int post_relocation(struct module *mod, const struct load_info *info)
82893 {
82894 /* Sort exception table now relocations are done. */
82895 + pax_open_kernel();
82896 sort_extable(mod->extable, mod->extable + mod->num_exentries);
82897 + pax_close_kernel();
82898
82899 /* Copy relocated percpu area over. */
82900 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
82901 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
82902 MODULE_STATE_COMING, mod);
82903
82904 /* Set RO and NX regions for core */
82905 - set_section_ro_nx(mod->module_core,
82906 - mod->core_text_size,
82907 - mod->core_ro_size,
82908 - mod->core_size);
82909 + set_section_ro_nx(mod->module_core_rx,
82910 + mod->core_size_rx,
82911 + mod->core_size_rx,
82912 + mod->core_size_rx);
82913
82914 /* Set RO and NX regions for init */
82915 - set_section_ro_nx(mod->module_init,
82916 - mod->init_text_size,
82917 - mod->init_ro_size,
82918 - mod->init_size);
82919 + set_section_ro_nx(mod->module_init_rx,
82920 + mod->init_size_rx,
82921 + mod->init_size_rx,
82922 + mod->init_size_rx);
82923
82924 do_mod_ctors(mod);
82925 /* Start the module */
82926 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
82927 mod->strtab = mod->core_strtab;
82928 #endif
82929 unset_module_init_ro_nx(mod);
82930 - module_free(mod, mod->module_init);
82931 - mod->module_init = NULL;
82932 - mod->init_size = 0;
82933 - mod->init_ro_size = 0;
82934 - mod->init_text_size = 0;
82935 + module_free(mod, mod->module_init_rw);
82936 + module_free_exec(mod, mod->module_init_rx);
82937 + mod->module_init_rw = NULL;
82938 + mod->module_init_rx = NULL;
82939 + mod->init_size_rw = 0;
82940 + mod->init_size_rx = 0;
82941 mutex_unlock(&module_mutex);
82942 wake_up_all(&module_wq);
82943
82944 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
82945 if (err)
82946 goto free_unload;
82947
82948 + /* Now copy in args */
82949 + mod->args = strndup_user(uargs, ~0UL >> 1);
82950 + if (IS_ERR(mod->args)) {
82951 + err = PTR_ERR(mod->args);
82952 + goto free_unload;
82953 + }
82954 +
82955 /* Set up MODINFO_ATTR fields */
82956 setup_modinfo(mod, info);
82957
82958 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82959 + {
82960 + char *p, *p2;
82961 +
82962 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82963 + 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);
82964 + err = -EPERM;
82965 + goto free_modinfo;
82966 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82967 + p += sizeof("grsec_modharden_normal") - 1;
82968 + p2 = strstr(p, "_");
82969 + if (p2) {
82970 + *p2 = '\0';
82971 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82972 + *p2 = '_';
82973 + }
82974 + err = -EPERM;
82975 + goto free_modinfo;
82976 + }
82977 + }
82978 +#endif
82979 +
82980 /* Fix up syms, so that st_value is a pointer to location. */
82981 err = simplify_symbols(mod, info);
82982 if (err < 0)
82983 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82984
82985 flush_module_icache(mod);
82986
82987 - /* Now copy in args */
82988 - mod->args = strndup_user(uargs, ~0UL >> 1);
82989 - if (IS_ERR(mod->args)) {
82990 - err = PTR_ERR(mod->args);
82991 - goto free_arch_cleanup;
82992 - }
82993 -
82994 dynamic_debug_setup(info->debug, info->num_debug);
82995
82996 /* Finally it's fully formed, ready to start executing. */
82997 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
82998 ddebug_cleanup:
82999 dynamic_debug_remove(info->debug);
83000 synchronize_sched();
83001 - kfree(mod->args);
83002 - free_arch_cleanup:
83003 module_arch_cleanup(mod);
83004 free_modinfo:
83005 free_modinfo(mod);
83006 + kfree(mod->args);
83007 free_unload:
83008 module_unload_free(mod);
83009 unlink_mod:
83010 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
83011 unsigned long nextval;
83012
83013 /* At worse, next value is at end of module */
83014 - if (within_module_init(addr, mod))
83015 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83016 + if (within_module_init_rx(addr, mod))
83017 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83018 + else if (within_module_init_rw(addr, mod))
83019 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83020 + else if (within_module_core_rx(addr, mod))
83021 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83022 + else if (within_module_core_rw(addr, mod))
83023 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83024 else
83025 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83026 + return NULL;
83027
83028 /* Scan for closest preceding symbol, and next symbol. (ELF
83029 starts real symbols at 1). */
83030 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
83031 return 0;
83032
83033 seq_printf(m, "%s %u",
83034 - mod->name, mod->init_size + mod->core_size);
83035 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83036 print_unload_info(m, mod);
83037
83038 /* Informative for users. */
83039 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
83040 mod->state == MODULE_STATE_COMING ? "Loading":
83041 "Live");
83042 /* Used by oprofile and other similar tools. */
83043 - seq_printf(m, " 0x%pK", mod->module_core);
83044 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83045
83046 /* Taints info */
83047 if (mod->taints)
83048 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
83049
83050 static int __init proc_modules_init(void)
83051 {
83052 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83053 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83054 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83055 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83056 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83057 +#else
83058 proc_create("modules", 0, NULL, &proc_modules_operations);
83059 +#endif
83060 +#else
83061 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83062 +#endif
83063 return 0;
83064 }
83065 module_init(proc_modules_init);
83066 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
83067 {
83068 struct module *mod;
83069
83070 - if (addr < module_addr_min || addr > module_addr_max)
83071 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83072 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83073 return NULL;
83074
83075 list_for_each_entry_rcu(mod, &modules, list) {
83076 if (mod->state == MODULE_STATE_UNFORMED)
83077 continue;
83078 - if (within_module_core(addr, mod)
83079 - || within_module_init(addr, mod))
83080 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83081 return mod;
83082 }
83083 return NULL;
83084 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
83085 */
83086 struct module *__module_text_address(unsigned long addr)
83087 {
83088 - struct module *mod = __module_address(addr);
83089 + struct module *mod;
83090 +
83091 +#ifdef CONFIG_X86_32
83092 + addr = ktla_ktva(addr);
83093 +#endif
83094 +
83095 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83096 + return NULL;
83097 +
83098 + mod = __module_address(addr);
83099 +
83100 if (mod) {
83101 /* Make sure it's within the text section. */
83102 - if (!within(addr, mod->module_init, mod->init_text_size)
83103 - && !within(addr, mod->module_core, mod->core_text_size))
83104 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83105 mod = NULL;
83106 }
83107 return mod;
83108 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83109 index 7e3443f..b2a1e6b 100644
83110 --- a/kernel/mutex-debug.c
83111 +++ b/kernel/mutex-debug.c
83112 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83113 }
83114
83115 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83116 - struct thread_info *ti)
83117 + struct task_struct *task)
83118 {
83119 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83120
83121 /* Mark the current thread as blocked on the lock: */
83122 - ti->task->blocked_on = waiter;
83123 + task->blocked_on = waiter;
83124 }
83125
83126 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83127 - struct thread_info *ti)
83128 + struct task_struct *task)
83129 {
83130 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83131 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83132 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83133 - ti->task->blocked_on = NULL;
83134 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83135 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83136 + task->blocked_on = NULL;
83137
83138 list_del_init(&waiter->list);
83139 waiter->task = NULL;
83140 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83141 index 0799fd3..d06ae3b 100644
83142 --- a/kernel/mutex-debug.h
83143 +++ b/kernel/mutex-debug.h
83144 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83145 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83146 extern void debug_mutex_add_waiter(struct mutex *lock,
83147 struct mutex_waiter *waiter,
83148 - struct thread_info *ti);
83149 + struct task_struct *task);
83150 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83151 - struct thread_info *ti);
83152 + struct task_struct *task);
83153 extern void debug_mutex_unlock(struct mutex *lock);
83154 extern void debug_mutex_init(struct mutex *lock, const char *name,
83155 struct lock_class_key *key);
83156 diff --git a/kernel/mutex.c b/kernel/mutex.c
83157 index d24105b..15648eb 100644
83158 --- a/kernel/mutex.c
83159 +++ b/kernel/mutex.c
83160 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83161 node->locked = 1;
83162 return;
83163 }
83164 - ACCESS_ONCE(prev->next) = node;
83165 + ACCESS_ONCE_RW(prev->next) = node;
83166 smp_wmb();
83167 /* Wait until the lock holder passes the lock down */
83168 while (!ACCESS_ONCE(node->locked))
83169 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83170 while (!(next = ACCESS_ONCE(node->next)))
83171 arch_mutex_cpu_relax();
83172 }
83173 - ACCESS_ONCE(next->locked) = 1;
83174 + ACCESS_ONCE_RW(next->locked) = 1;
83175 smp_wmb();
83176 }
83177
83178 @@ -520,7 +520,7 @@ slowpath:
83179 goto skip_wait;
83180
83181 debug_mutex_lock_common(lock, &waiter);
83182 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83183 + debug_mutex_add_waiter(lock, &waiter, task);
83184
83185 /* add waiting tasks to the end of the waitqueue (FIFO): */
83186 list_add_tail(&waiter.list, &lock->wait_list);
83187 @@ -564,7 +564,7 @@ slowpath:
83188 schedule_preempt_disabled();
83189 spin_lock_mutex(&lock->wait_lock, flags);
83190 }
83191 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83192 + mutex_remove_waiter(lock, &waiter, task);
83193 /* set it to 0 if there are no waiters left: */
83194 if (likely(list_empty(&lock->wait_list)))
83195 atomic_set(&lock->count, 0);
83196 @@ -601,7 +601,7 @@ skip_wait:
83197 return 0;
83198
83199 err:
83200 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
83201 + mutex_remove_waiter(lock, &waiter, task);
83202 spin_unlock_mutex(&lock->wait_lock, flags);
83203 debug_mutex_free_waiter(&waiter);
83204 mutex_release(&lock->dep_map, 1, ip);
83205 diff --git a/kernel/notifier.c b/kernel/notifier.c
83206 index 2d5cc4c..d9ea600 100644
83207 --- a/kernel/notifier.c
83208 +++ b/kernel/notifier.c
83209 @@ -5,6 +5,7 @@
83210 #include <linux/rcupdate.h>
83211 #include <linux/vmalloc.h>
83212 #include <linux/reboot.h>
83213 +#include <linux/mm.h>
83214
83215 /*
83216 * Notifier list for kernel code which wants to be called
83217 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83218 while ((*nl) != NULL) {
83219 if (n->priority > (*nl)->priority)
83220 break;
83221 - nl = &((*nl)->next);
83222 + nl = (struct notifier_block **)&((*nl)->next);
83223 }
83224 - n->next = *nl;
83225 + pax_open_kernel();
83226 + *(const void **)&n->next = *nl;
83227 rcu_assign_pointer(*nl, n);
83228 + pax_close_kernel();
83229 return 0;
83230 }
83231
83232 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83233 return 0;
83234 if (n->priority > (*nl)->priority)
83235 break;
83236 - nl = &((*nl)->next);
83237 + nl = (struct notifier_block **)&((*nl)->next);
83238 }
83239 - n->next = *nl;
83240 + pax_open_kernel();
83241 + *(const void **)&n->next = *nl;
83242 rcu_assign_pointer(*nl, n);
83243 + pax_close_kernel();
83244 return 0;
83245 }
83246
83247 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83248 {
83249 while ((*nl) != NULL) {
83250 if ((*nl) == n) {
83251 + pax_open_kernel();
83252 rcu_assign_pointer(*nl, n->next);
83253 + pax_close_kernel();
83254 return 0;
83255 }
83256 - nl = &((*nl)->next);
83257 + nl = (struct notifier_block **)&((*nl)->next);
83258 }
83259 return -ENOENT;
83260 }
83261 diff --git a/kernel/panic.c b/kernel/panic.c
83262 index b6c482c..5578061 100644
83263 --- a/kernel/panic.c
83264 +++ b/kernel/panic.c
83265 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
83266 disable_trace_on_warning();
83267
83268 pr_warn("------------[ cut here ]------------\n");
83269 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
83270 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
83271 raw_smp_processor_id(), current->pid, file, line, caller);
83272
83273 if (args)
83274 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
83275 */
83276 void __stack_chk_fail(void)
83277 {
83278 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
83279 + dump_stack();
83280 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
83281 __builtin_return_address(0));
83282 }
83283 EXPORT_SYMBOL(__stack_chk_fail);
83284 diff --git a/kernel/pid.c b/kernel/pid.c
83285 index 9b9a266..c20ef80 100644
83286 --- a/kernel/pid.c
83287 +++ b/kernel/pid.c
83288 @@ -33,6 +33,7 @@
83289 #include <linux/rculist.h>
83290 #include <linux/bootmem.h>
83291 #include <linux/hash.h>
83292 +#include <linux/security.h>
83293 #include <linux/pid_namespace.h>
83294 #include <linux/init_task.h>
83295 #include <linux/syscalls.h>
83296 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
83297
83298 int pid_max = PID_MAX_DEFAULT;
83299
83300 -#define RESERVED_PIDS 300
83301 +#define RESERVED_PIDS 500
83302
83303 int pid_max_min = RESERVED_PIDS + 1;
83304 int pid_max_max = PID_MAX_LIMIT;
83305 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
83306 */
83307 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
83308 {
83309 + struct task_struct *task;
83310 +
83311 rcu_lockdep_assert(rcu_read_lock_held(),
83312 "find_task_by_pid_ns() needs rcu_read_lock()"
83313 " protection");
83314 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83315 +
83316 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83317 +
83318 + if (gr_pid_is_chrooted(task))
83319 + return NULL;
83320 +
83321 + return task;
83322 }
83323
83324 struct task_struct *find_task_by_vpid(pid_t vnr)
83325 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
83326 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
83327 }
83328
83329 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
83330 +{
83331 + rcu_lockdep_assert(rcu_read_lock_held(),
83332 + "find_task_by_pid_ns() needs rcu_read_lock()"
83333 + " protection");
83334 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
83335 +}
83336 +
83337 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
83338 {
83339 struct pid *pid;
83340 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
83341 index 4208655..19f36a5 100644
83342 --- a/kernel/pid_namespace.c
83343 +++ b/kernel/pid_namespace.c
83344 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
83345 void __user *buffer, size_t *lenp, loff_t *ppos)
83346 {
83347 struct pid_namespace *pid_ns = task_active_pid_ns(current);
83348 - struct ctl_table tmp = *table;
83349 + ctl_table_no_const tmp = *table;
83350
83351 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
83352 return -EPERM;
83353 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
83354 index c7f31aa..2b44977 100644
83355 --- a/kernel/posix-cpu-timers.c
83356 +++ b/kernel/posix-cpu-timers.c
83357 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
83358
83359 static __init int init_posix_cpu_timers(void)
83360 {
83361 - struct k_clock process = {
83362 + static struct k_clock process = {
83363 .clock_getres = process_cpu_clock_getres,
83364 .clock_get = process_cpu_clock_get,
83365 .timer_create = process_cpu_timer_create,
83366 .nsleep = process_cpu_nsleep,
83367 .nsleep_restart = process_cpu_nsleep_restart,
83368 };
83369 - struct k_clock thread = {
83370 + static struct k_clock thread = {
83371 .clock_getres = thread_cpu_clock_getres,
83372 .clock_get = thread_cpu_clock_get,
83373 .timer_create = thread_cpu_timer_create,
83374 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
83375 index 424c2d4..679242f 100644
83376 --- a/kernel/posix-timers.c
83377 +++ b/kernel/posix-timers.c
83378 @@ -43,6 +43,7 @@
83379 #include <linux/hash.h>
83380 #include <linux/posix-clock.h>
83381 #include <linux/posix-timers.h>
83382 +#include <linux/grsecurity.h>
83383 #include <linux/syscalls.h>
83384 #include <linux/wait.h>
83385 #include <linux/workqueue.h>
83386 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
83387 * which we beg off on and pass to do_sys_settimeofday().
83388 */
83389
83390 -static struct k_clock posix_clocks[MAX_CLOCKS];
83391 +static struct k_clock *posix_clocks[MAX_CLOCKS];
83392
83393 /*
83394 * These ones are defined below.
83395 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
83396 */
83397 static __init int init_posix_timers(void)
83398 {
83399 - struct k_clock clock_realtime = {
83400 + static struct k_clock clock_realtime = {
83401 .clock_getres = hrtimer_get_res,
83402 .clock_get = posix_clock_realtime_get,
83403 .clock_set = posix_clock_realtime_set,
83404 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
83405 .timer_get = common_timer_get,
83406 .timer_del = common_timer_del,
83407 };
83408 - struct k_clock clock_monotonic = {
83409 + static struct k_clock clock_monotonic = {
83410 .clock_getres = hrtimer_get_res,
83411 .clock_get = posix_ktime_get_ts,
83412 .nsleep = common_nsleep,
83413 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
83414 .timer_get = common_timer_get,
83415 .timer_del = common_timer_del,
83416 };
83417 - struct k_clock clock_monotonic_raw = {
83418 + static struct k_clock clock_monotonic_raw = {
83419 .clock_getres = hrtimer_get_res,
83420 .clock_get = posix_get_monotonic_raw,
83421 };
83422 - struct k_clock clock_realtime_coarse = {
83423 + static struct k_clock clock_realtime_coarse = {
83424 .clock_getres = posix_get_coarse_res,
83425 .clock_get = posix_get_realtime_coarse,
83426 };
83427 - struct k_clock clock_monotonic_coarse = {
83428 + static struct k_clock clock_monotonic_coarse = {
83429 .clock_getres = posix_get_coarse_res,
83430 .clock_get = posix_get_monotonic_coarse,
83431 };
83432 - struct k_clock clock_tai = {
83433 + static struct k_clock clock_tai = {
83434 .clock_getres = hrtimer_get_res,
83435 .clock_get = posix_get_tai,
83436 .nsleep = common_nsleep,
83437 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
83438 .timer_get = common_timer_get,
83439 .timer_del = common_timer_del,
83440 };
83441 - struct k_clock clock_boottime = {
83442 + static struct k_clock clock_boottime = {
83443 .clock_getres = hrtimer_get_res,
83444 .clock_get = posix_get_boottime,
83445 .nsleep = common_nsleep,
83446 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
83447 return;
83448 }
83449
83450 - posix_clocks[clock_id] = *new_clock;
83451 + posix_clocks[clock_id] = new_clock;
83452 }
83453 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
83454
83455 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
83456 return (id & CLOCKFD_MASK) == CLOCKFD ?
83457 &clock_posix_dynamic : &clock_posix_cpu;
83458
83459 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
83460 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
83461 return NULL;
83462 - return &posix_clocks[id];
83463 + return posix_clocks[id];
83464 }
83465
83466 static int common_timer_create(struct k_itimer *new_timer)
83467 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
83468 struct k_clock *kc = clockid_to_kclock(which_clock);
83469 struct k_itimer *new_timer;
83470 int error, new_timer_id;
83471 - sigevent_t event;
83472 + sigevent_t event = { };
83473 int it_id_set = IT_ID_NOT_SET;
83474
83475 if (!kc)
83476 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
83477 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
83478 return -EFAULT;
83479
83480 + /* only the CLOCK_REALTIME clock can be set, all other clocks
83481 + have their clock_set fptr set to a nosettime dummy function
83482 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
83483 + call common_clock_set, which calls do_sys_settimeofday, which
83484 + we hook
83485 + */
83486 +
83487 return kc->clock_set(which_clock, &new_tp);
83488 }
83489
83490 diff --git a/kernel/power/process.c b/kernel/power/process.c
83491 index 06ec886..9dba35e 100644
83492 --- a/kernel/power/process.c
83493 +++ b/kernel/power/process.c
83494 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
83495 unsigned int elapsed_msecs;
83496 bool wakeup = false;
83497 int sleep_usecs = USEC_PER_MSEC;
83498 + bool timedout = false;
83499
83500 do_gettimeofday(&start);
83501
83502 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
83503
83504 while (true) {
83505 todo = 0;
83506 + if (time_after(jiffies, end_time))
83507 + timedout = true;
83508 read_lock(&tasklist_lock);
83509 do_each_thread(g, p) {
83510 if (p == current || !freeze_task(p))
83511 continue;
83512
83513 - if (!freezer_should_skip(p))
83514 + if (!freezer_should_skip(p)) {
83515 todo++;
83516 + if (timedout) {
83517 + printk(KERN_ERR "Task refusing to freeze:\n");
83518 + sched_show_task(p);
83519 + }
83520 + }
83521 } while_each_thread(g, p);
83522 read_unlock(&tasklist_lock);
83523
83524 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
83525 todo += wq_busy;
83526 }
83527
83528 - if (!todo || time_after(jiffies, end_time))
83529 + if (!todo || timedout)
83530 break;
83531
83532 if (pm_wakeup_pending()) {
83533 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
83534 index b4e8500..b457a6c 100644
83535 --- a/kernel/printk/printk.c
83536 +++ b/kernel/printk/printk.c
83537 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
83538 if (from_file && type != SYSLOG_ACTION_OPEN)
83539 return 0;
83540
83541 +#ifdef CONFIG_GRKERNSEC_DMESG
83542 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
83543 + return -EPERM;
83544 +#endif
83545 +
83546 if (syslog_action_restricted(type)) {
83547 if (capable(CAP_SYSLOG))
83548 return 0;
83549 diff --git a/kernel/profile.c b/kernel/profile.c
83550 index 6631e1e..310c266 100644
83551 --- a/kernel/profile.c
83552 +++ b/kernel/profile.c
83553 @@ -37,7 +37,7 @@ struct profile_hit {
83554 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
83555 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
83556
83557 -static atomic_t *prof_buffer;
83558 +static atomic_unchecked_t *prof_buffer;
83559 static unsigned long prof_len, prof_shift;
83560
83561 int prof_on __read_mostly;
83562 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
83563 hits[i].pc = 0;
83564 continue;
83565 }
83566 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83567 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83568 hits[i].hits = hits[i].pc = 0;
83569 }
83570 }
83571 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83572 * Add the current hit(s) and flush the write-queue out
83573 * to the global buffer:
83574 */
83575 - atomic_add(nr_hits, &prof_buffer[pc]);
83576 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
83577 for (i = 0; i < NR_PROFILE_HIT; ++i) {
83578 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83579 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83580 hits[i].pc = hits[i].hits = 0;
83581 }
83582 out:
83583 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83584 {
83585 unsigned long pc;
83586 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
83587 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83588 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83589 }
83590 #endif /* !CONFIG_SMP */
83591
83592 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
83593 return -EFAULT;
83594 buf++; p++; count--; read++;
83595 }
83596 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
83597 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
83598 if (copy_to_user(buf, (void *)pnt, count))
83599 return -EFAULT;
83600 read += count;
83601 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83602 }
83603 #endif
83604 profile_discard_flip_buffers();
83605 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83606 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83607 return count;
83608 }
83609
83610 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83611 index 1f4bcb3..99cf7ab 100644
83612 --- a/kernel/ptrace.c
83613 +++ b/kernel/ptrace.c
83614 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83615 if (seize)
83616 flags |= PT_SEIZED;
83617 rcu_read_lock();
83618 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83619 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83620 flags |= PT_PTRACE_CAP;
83621 rcu_read_unlock();
83622 task->ptrace = flags;
83623 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83624 break;
83625 return -EIO;
83626 }
83627 - if (copy_to_user(dst, buf, retval))
83628 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83629 return -EFAULT;
83630 copied += retval;
83631 src += retval;
83632 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
83633 bool seized = child->ptrace & PT_SEIZED;
83634 int ret = -EIO;
83635 siginfo_t siginfo, *si;
83636 - void __user *datavp = (void __user *) data;
83637 + void __user *datavp = (__force void __user *) data;
83638 unsigned long __user *datalp = datavp;
83639 unsigned long flags;
83640
83641 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83642 goto out;
83643 }
83644
83645 + if (gr_handle_ptrace(child, request)) {
83646 + ret = -EPERM;
83647 + goto out_put_task_struct;
83648 + }
83649 +
83650 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83651 ret = ptrace_attach(child, request, addr, data);
83652 /*
83653 * Some architectures need to do book-keeping after
83654 * a ptrace attach.
83655 */
83656 - if (!ret)
83657 + if (!ret) {
83658 arch_ptrace_attach(child);
83659 + gr_audit_ptrace(child);
83660 + }
83661 goto out_put_task_struct;
83662 }
83663
83664 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
83665 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
83666 if (copied != sizeof(tmp))
83667 return -EIO;
83668 - return put_user(tmp, (unsigned long __user *)data);
83669 + return put_user(tmp, (__force unsigned long __user *)data);
83670 }
83671
83672 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
83673 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
83674 }
83675
83676 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83677 - compat_long_t addr, compat_long_t data)
83678 + compat_ulong_t addr, compat_ulong_t data)
83679 {
83680 struct task_struct *child;
83681 long ret;
83682 @@ -1197,14 +1204,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83683 goto out;
83684 }
83685
83686 + if (gr_handle_ptrace(child, request)) {
83687 + ret = -EPERM;
83688 + goto out_put_task_struct;
83689 + }
83690 +
83691 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83692 ret = ptrace_attach(child, request, addr, data);
83693 /*
83694 * Some architectures need to do book-keeping after
83695 * a ptrace attach.
83696 */
83697 - if (!ret)
83698 + if (!ret) {
83699 arch_ptrace_attach(child);
83700 + gr_audit_ptrace(child);
83701 + }
83702 goto out_put_task_struct;
83703 }
83704
83705 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
83706 index b02a339..ce2d20c 100644
83707 --- a/kernel/rcupdate.c
83708 +++ b/kernel/rcupdate.c
83709 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
83710 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
83711 */
83712 if (till_stall_check < 3) {
83713 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
83714 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
83715 till_stall_check = 3;
83716 } else if (till_stall_check > 300) {
83717 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
83718 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
83719 till_stall_check = 300;
83720 }
83721 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
83722 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
83723 index 9ed6075..c9e8a63 100644
83724 --- a/kernel/rcutiny.c
83725 +++ b/kernel/rcutiny.c
83726 @@ -45,7 +45,7 @@
83727 /* Forward declarations for rcutiny_plugin.h. */
83728 struct rcu_ctrlblk;
83729 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
83730 -static void rcu_process_callbacks(struct softirq_action *unused);
83731 +static void rcu_process_callbacks(void);
83732 static void __call_rcu(struct rcu_head *head,
83733 void (*func)(struct rcu_head *rcu),
83734 struct rcu_ctrlblk *rcp);
83735 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
83736 false));
83737 }
83738
83739 -static void rcu_process_callbacks(struct softirq_action *unused)
83740 +static __latent_entropy void rcu_process_callbacks(void)
83741 {
83742 __rcu_process_callbacks(&rcu_sched_ctrlblk);
83743 __rcu_process_callbacks(&rcu_bh_ctrlblk);
83744 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
83745 index be63101..05cf721 100644
83746 --- a/kernel/rcutorture.c
83747 +++ b/kernel/rcutorture.c
83748 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
83749 { 0 };
83750 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
83751 { 0 };
83752 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83753 -static atomic_t n_rcu_torture_alloc;
83754 -static atomic_t n_rcu_torture_alloc_fail;
83755 -static atomic_t n_rcu_torture_free;
83756 -static atomic_t n_rcu_torture_mberror;
83757 -static atomic_t n_rcu_torture_error;
83758 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83759 +static atomic_unchecked_t n_rcu_torture_alloc;
83760 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
83761 +static atomic_unchecked_t n_rcu_torture_free;
83762 +static atomic_unchecked_t n_rcu_torture_mberror;
83763 +static atomic_unchecked_t n_rcu_torture_error;
83764 static long n_rcu_torture_barrier_error;
83765 static long n_rcu_torture_boost_ktrerror;
83766 static long n_rcu_torture_boost_rterror;
83767 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
83768
83769 spin_lock_bh(&rcu_torture_lock);
83770 if (list_empty(&rcu_torture_freelist)) {
83771 - atomic_inc(&n_rcu_torture_alloc_fail);
83772 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
83773 spin_unlock_bh(&rcu_torture_lock);
83774 return NULL;
83775 }
83776 - atomic_inc(&n_rcu_torture_alloc);
83777 + atomic_inc_unchecked(&n_rcu_torture_alloc);
83778 p = rcu_torture_freelist.next;
83779 list_del_init(p);
83780 spin_unlock_bh(&rcu_torture_lock);
83781 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
83782 static void
83783 rcu_torture_free(struct rcu_torture *p)
83784 {
83785 - atomic_inc(&n_rcu_torture_free);
83786 + atomic_inc_unchecked(&n_rcu_torture_free);
83787 spin_lock_bh(&rcu_torture_lock);
83788 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
83789 spin_unlock_bh(&rcu_torture_lock);
83790 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
83791 i = rp->rtort_pipe_count;
83792 if (i > RCU_TORTURE_PIPE_LEN)
83793 i = RCU_TORTURE_PIPE_LEN;
83794 - atomic_inc(&rcu_torture_wcount[i]);
83795 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83796 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
83797 rp->rtort_mbtest = 0;
83798 rcu_torture_free(rp);
83799 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
83800 i = old_rp->rtort_pipe_count;
83801 if (i > RCU_TORTURE_PIPE_LEN)
83802 i = RCU_TORTURE_PIPE_LEN;
83803 - atomic_inc(&rcu_torture_wcount[i]);
83804 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83805 old_rp->rtort_pipe_count++;
83806 if (gp_normal == gp_exp)
83807 exp = !!(rcu_random(&rand) & 0x80);
83808 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
83809 i = rp->rtort_pipe_count;
83810 if (i > RCU_TORTURE_PIPE_LEN)
83811 i = RCU_TORTURE_PIPE_LEN;
83812 - atomic_inc(&rcu_torture_wcount[i]);
83813 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83814 if (++rp->rtort_pipe_count >=
83815 RCU_TORTURE_PIPE_LEN) {
83816 rp->rtort_mbtest = 0;
83817 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
83818 return;
83819 }
83820 if (p->rtort_mbtest == 0)
83821 - atomic_inc(&n_rcu_torture_mberror);
83822 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83823 spin_lock(&rand_lock);
83824 cur_ops->read_delay(&rand);
83825 n_rcu_torture_timers++;
83826 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
83827 continue;
83828 }
83829 if (p->rtort_mbtest == 0)
83830 - atomic_inc(&n_rcu_torture_mberror);
83831 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83832 cur_ops->read_delay(&rand);
83833 preempt_disable();
83834 pipe_count = p->rtort_pipe_count;
83835 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
83836 rcu_torture_current,
83837 rcu_torture_current_version,
83838 list_empty(&rcu_torture_freelist),
83839 - atomic_read(&n_rcu_torture_alloc),
83840 - atomic_read(&n_rcu_torture_alloc_fail),
83841 - atomic_read(&n_rcu_torture_free));
83842 + atomic_read_unchecked(&n_rcu_torture_alloc),
83843 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
83844 + atomic_read_unchecked(&n_rcu_torture_free));
83845 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
83846 - atomic_read(&n_rcu_torture_mberror),
83847 + atomic_read_unchecked(&n_rcu_torture_mberror),
83848 n_rcu_torture_boost_ktrerror,
83849 n_rcu_torture_boost_rterror);
83850 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
83851 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
83852 n_barrier_attempts,
83853 n_rcu_torture_barrier_error);
83854 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
83855 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
83856 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
83857 n_rcu_torture_barrier_error != 0 ||
83858 n_rcu_torture_boost_ktrerror != 0 ||
83859 n_rcu_torture_boost_rterror != 0 ||
83860 n_rcu_torture_boost_failure != 0 ||
83861 i > 1) {
83862 cnt += sprintf(&page[cnt], "!!! ");
83863 - atomic_inc(&n_rcu_torture_error);
83864 + atomic_inc_unchecked(&n_rcu_torture_error);
83865 WARN_ON_ONCE(1);
83866 }
83867 cnt += sprintf(&page[cnt], "Reader Pipe: ");
83868 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
83869 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
83870 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83871 cnt += sprintf(&page[cnt], " %d",
83872 - atomic_read(&rcu_torture_wcount[i]));
83873 + atomic_read_unchecked(&rcu_torture_wcount[i]));
83874 }
83875 cnt += sprintf(&page[cnt], "\n");
83876 if (cur_ops->stats)
83877 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
83878
83879 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
83880
83881 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83882 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83883 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
83884 else if (n_online_successes != n_online_attempts ||
83885 n_offline_successes != n_offline_attempts)
83886 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
83887
83888 rcu_torture_current = NULL;
83889 rcu_torture_current_version = 0;
83890 - atomic_set(&n_rcu_torture_alloc, 0);
83891 - atomic_set(&n_rcu_torture_alloc_fail, 0);
83892 - atomic_set(&n_rcu_torture_free, 0);
83893 - atomic_set(&n_rcu_torture_mberror, 0);
83894 - atomic_set(&n_rcu_torture_error, 0);
83895 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
83896 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
83897 + atomic_set_unchecked(&n_rcu_torture_free, 0);
83898 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
83899 + atomic_set_unchecked(&n_rcu_torture_error, 0);
83900 n_rcu_torture_barrier_error = 0;
83901 n_rcu_torture_boost_ktrerror = 0;
83902 n_rcu_torture_boost_rterror = 0;
83903 n_rcu_torture_boost_failure = 0;
83904 n_rcu_torture_boosts = 0;
83905 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
83906 - atomic_set(&rcu_torture_wcount[i], 0);
83907 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
83908 for_each_possible_cpu(cpu) {
83909 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83910 per_cpu(rcu_torture_count, cpu)[i] = 0;
83911 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
83912 index 32618b3..c1fb822 100644
83913 --- a/kernel/rcutree.c
83914 +++ b/kernel/rcutree.c
83915 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
83916 rcu_prepare_for_idle(smp_processor_id());
83917 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83918 smp_mb__before_atomic_inc(); /* See above. */
83919 - atomic_inc(&rdtp->dynticks);
83920 + atomic_inc_unchecked(&rdtp->dynticks);
83921 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
83922 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83923 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83924
83925 /*
83926 * It is illegal to enter an extended quiescent state while
83927 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
83928 int user)
83929 {
83930 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
83931 - atomic_inc(&rdtp->dynticks);
83932 + atomic_inc_unchecked(&rdtp->dynticks);
83933 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83934 smp_mb__after_atomic_inc(); /* See above. */
83935 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83936 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83937 rcu_cleanup_after_idle(smp_processor_id());
83938 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
83939 if (!user && !is_idle_task(current)) {
83940 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
83941 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
83942
83943 if (rdtp->dynticks_nmi_nesting == 0 &&
83944 - (atomic_read(&rdtp->dynticks) & 0x1))
83945 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
83946 return;
83947 rdtp->dynticks_nmi_nesting++;
83948 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
83949 - atomic_inc(&rdtp->dynticks);
83950 + atomic_inc_unchecked(&rdtp->dynticks);
83951 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83952 smp_mb__after_atomic_inc(); /* See above. */
83953 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83954 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83955 }
83956
83957 /**
83958 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
83959 return;
83960 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83961 smp_mb__before_atomic_inc(); /* See above. */
83962 - atomic_inc(&rdtp->dynticks);
83963 + atomic_inc_unchecked(&rdtp->dynticks);
83964 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83965 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83966 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83967 }
83968
83969 /**
83970 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
83971 int ret;
83972
83973 preempt_disable();
83974 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83975 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83976 preempt_enable();
83977 return ret;
83978 }
83979 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83980 static int dyntick_save_progress_counter(struct rcu_data *rdp,
83981 bool *isidle, unsigned long *maxj)
83982 {
83983 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83984 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83985 rcu_sysidle_check_cpu(rdp, isidle, maxj);
83986 return (rdp->dynticks_snap & 0x1) == 0;
83987 }
83988 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
83989 unsigned int curr;
83990 unsigned int snap;
83991
83992 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83993 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83994 snap = (unsigned int)rdp->dynticks_snap;
83995
83996 /*
83997 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
83998 rdp = this_cpu_ptr(rsp->rda);
83999 rcu_preempt_check_blocked_tasks(rnp);
84000 rnp->qsmask = rnp->qsmaskinit;
84001 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84002 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84003 WARN_ON_ONCE(rnp->completed != rsp->completed);
84004 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84005 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84006 if (rnp == rdp->mynode)
84007 __note_gp_changes(rsp, rnp, rdp);
84008 rcu_preempt_boost_start_gp(rnp);
84009 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84010 */
84011 rcu_for_each_node_breadth_first(rsp, rnp) {
84012 raw_spin_lock_irq(&rnp->lock);
84013 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84014 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84015 rdp = this_cpu_ptr(rsp->rda);
84016 if (rnp == rdp->mynode)
84017 __note_gp_changes(rsp, rnp, rdp);
84018 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84019 rsp->qlen += rdp->qlen;
84020 rdp->n_cbs_orphaned += rdp->qlen;
84021 rdp->qlen_lazy = 0;
84022 - ACCESS_ONCE(rdp->qlen) = 0;
84023 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84024 }
84025
84026 /*
84027 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84028 }
84029 smp_mb(); /* List handling before counting for rcu_barrier(). */
84030 rdp->qlen_lazy -= count_lazy;
84031 - ACCESS_ONCE(rdp->qlen) -= count;
84032 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84033 rdp->n_cbs_invoked += count;
84034
84035 /* Reinstate batch limit if we have worked down the excess. */
84036 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84037 /*
84038 * Do RCU core processing for the current CPU.
84039 */
84040 -static void rcu_process_callbacks(struct softirq_action *unused)
84041 +static __latent_entropy void rcu_process_callbacks(void)
84042 {
84043 struct rcu_state *rsp;
84044
84045 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84046 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
84047 if (debug_rcu_head_queue(head)) {
84048 /* Probable double call_rcu(), so leak the callback. */
84049 - ACCESS_ONCE(head->func) = rcu_leak_callback;
84050 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
84051 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
84052 return;
84053 }
84054 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84055 local_irq_restore(flags);
84056 return;
84057 }
84058 - ACCESS_ONCE(rdp->qlen)++;
84059 + ACCESS_ONCE_RW(rdp->qlen)++;
84060 if (lazy)
84061 rdp->qlen_lazy++;
84062 else
84063 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
84064 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84065 * course be required on a 64-bit system.
84066 */
84067 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84068 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84069 (ulong)atomic_long_read(&rsp->expedited_done) +
84070 ULONG_MAX / 8)) {
84071 synchronize_sched();
84072 - atomic_long_inc(&rsp->expedited_wrap);
84073 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84074 return;
84075 }
84076
84077 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
84078 * Take a ticket. Note that atomic_inc_return() implies a
84079 * full memory barrier.
84080 */
84081 - snap = atomic_long_inc_return(&rsp->expedited_start);
84082 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84083 firstsnap = snap;
84084 get_online_cpus();
84085 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84086 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
84087 synchronize_sched_expedited_cpu_stop,
84088 NULL) == -EAGAIN) {
84089 put_online_cpus();
84090 - atomic_long_inc(&rsp->expedited_tryfail);
84091 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84092
84093 /* Check to see if someone else did our work for us. */
84094 s = atomic_long_read(&rsp->expedited_done);
84095 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84096 /* ensure test happens before caller kfree */
84097 smp_mb__before_atomic_inc(); /* ^^^ */
84098 - atomic_long_inc(&rsp->expedited_workdone1);
84099 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84100 return;
84101 }
84102
84103 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
84104 udelay(trycount * num_online_cpus());
84105 } else {
84106 wait_rcu_gp(call_rcu_sched);
84107 - atomic_long_inc(&rsp->expedited_normal);
84108 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84109 return;
84110 }
84111
84112 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
84113 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84114 /* ensure test happens before caller kfree */
84115 smp_mb__before_atomic_inc(); /* ^^^ */
84116 - atomic_long_inc(&rsp->expedited_workdone2);
84117 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84118 return;
84119 }
84120
84121 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
84122 * period works for us.
84123 */
84124 get_online_cpus();
84125 - snap = atomic_long_read(&rsp->expedited_start);
84126 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84127 smp_mb(); /* ensure read is before try_stop_cpus(). */
84128 }
84129 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84130 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84131
84132 /*
84133 * Everyone up to our most recent fetch is covered by our grace
84134 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
84135 * than we did already did their update.
84136 */
84137 do {
84138 - atomic_long_inc(&rsp->expedited_done_tries);
84139 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84140 s = atomic_long_read(&rsp->expedited_done);
84141 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84142 /* ensure test happens before caller kfree */
84143 smp_mb__before_atomic_inc(); /* ^^^ */
84144 - atomic_long_inc(&rsp->expedited_done_lost);
84145 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84146 break;
84147 }
84148 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84149 - atomic_long_inc(&rsp->expedited_done_exit);
84150 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84151
84152 put_online_cpus();
84153 }
84154 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84155 * ACCESS_ONCE() to prevent the compiler from speculating
84156 * the increment to precede the early-exit check.
84157 */
84158 - ACCESS_ONCE(rsp->n_barrier_done)++;
84159 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84160 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84161 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84162 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84163 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84164
84165 /* Increment ->n_barrier_done to prevent duplicate work. */
84166 smp_mb(); /* Keep increment after above mechanism. */
84167 - ACCESS_ONCE(rsp->n_barrier_done)++;
84168 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84169 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84170 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84171 smp_mb(); /* Keep increment before caller's subsequent code. */
84172 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84173 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84174 init_callback_list(rdp);
84175 rdp->qlen_lazy = 0;
84176 - ACCESS_ONCE(rdp->qlen) = 0;
84177 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84178 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84179 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84180 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84181 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84182 rdp->cpu = cpu;
84183 rdp->rsp = rsp;
84184 rcu_boot_init_nocb_percpu_data(rdp);
84185 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84186 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84187 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84188 rcu_sysidle_init_percpu_data(rdp->dynticks);
84189 - atomic_set(&rdp->dynticks->dynticks,
84190 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84191 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84192 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84193 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84194
84195 /* Add CPU to rcu_node bitmasks. */
84196 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84197 index 5f97eab..db8f687 100644
84198 --- a/kernel/rcutree.h
84199 +++ b/kernel/rcutree.h
84200 @@ -87,11 +87,11 @@ struct rcu_dynticks {
84201 long long dynticks_nesting; /* Track irq/process nesting level. */
84202 /* Process level is worth LLONG_MAX/2. */
84203 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84204 - atomic_t dynticks; /* Even value for idle, else odd. */
84205 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84206 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
84207 long long dynticks_idle_nesting;
84208 /* irq/process nesting level from idle. */
84209 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
84210 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
84211 /* "Idle" excludes userspace execution. */
84212 unsigned long dynticks_idle_jiffies;
84213 /* End of last non-NMI non-idle period. */
84214 @@ -427,17 +427,17 @@ struct rcu_state {
84215 /* _rcu_barrier(). */
84216 /* End of fields guarded by barrier_mutex. */
84217
84218 - atomic_long_t expedited_start; /* Starting ticket. */
84219 - atomic_long_t expedited_done; /* Done ticket. */
84220 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84221 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84222 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84223 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84224 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84225 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84226 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84227 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84228 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84229 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84230 + atomic_long_t expedited_done; /* Done ticket. */
84231 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84232 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84233 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84234 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84235 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84236 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84237 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84238 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84239 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84240
84241 unsigned long jiffies_force_qs; /* Time at which to invoke */
84242 /* force_quiescent_state(). */
84243 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84244 index 130c97b..da2e5fc 100644
84245 --- a/kernel/rcutree_plugin.h
84246 +++ b/kernel/rcutree_plugin.h
84247 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
84248
84249 /* Clean up and exit. */
84250 smp_mb(); /* ensure expedited GP seen before counter increment. */
84251 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
84252 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
84253 unlock_mb_ret:
84254 mutex_unlock(&sync_rcu_preempt_exp_mutex);
84255 mb_ret:
84256 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
84257 free_cpumask_var(cm);
84258 }
84259
84260 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
84261 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
84262 .store = &rcu_cpu_kthread_task,
84263 .thread_should_run = rcu_cpu_kthread_should_run,
84264 .thread_fn = rcu_cpu_kthread,
84265 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
84266 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
84267 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
84268 cpu, ticks_value, ticks_title,
84269 - atomic_read(&rdtp->dynticks) & 0xfff,
84270 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
84271 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
84272 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
84273 fast_no_hz);
84274 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
84275
84276 /* Enqueue the callback on the nocb list and update counts. */
84277 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
84278 - ACCESS_ONCE(*old_rhpp) = rhp;
84279 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
84280 atomic_long_add(rhcount, &rdp->nocb_q_count);
84281 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
84282
84283 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
84284 * Extract queued callbacks, update counts, and wait
84285 * for a grace period to elapse.
84286 */
84287 - ACCESS_ONCE(rdp->nocb_head) = NULL;
84288 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
84289 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
84290 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
84291 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
84292 - ACCESS_ONCE(rdp->nocb_p_count) += c;
84293 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
84294 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
84295 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
84296 rcu_nocb_wait_gp(rdp);
84297
84298 /* Each pass through the following loop invokes a callback. */
84299 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
84300 list = next;
84301 }
84302 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
84303 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
84304 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
84305 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
84306 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
84307 rdp->n_nocbs_invoked += c;
84308 }
84309 return 0;
84310 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
84311 t = kthread_run(rcu_nocb_kthread, rdp,
84312 "rcuo%c/%d", rsp->abbr, cpu);
84313 BUG_ON(IS_ERR(t));
84314 - ACCESS_ONCE(rdp->nocb_kthread) = t;
84315 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
84316 }
84317 }
84318
84319 @@ -2425,9 +2425,9 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
84320 j = jiffies;
84321 ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
84322 smp_mb__before_atomic_inc();
84323 - atomic_inc(&rdtp->dynticks_idle);
84324 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84325 smp_mb__after_atomic_inc();
84326 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
84327 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
84328 }
84329
84330 /*
84331 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
84332
84333 /* Record end of idle period. */
84334 smp_mb__before_atomic_inc();
84335 - atomic_inc(&rdtp->dynticks_idle);
84336 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84337 smp_mb__after_atomic_inc();
84338 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
84339 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
84340
84341 /*
84342 * If we are the timekeeping CPU, we are permitted to be non-idle
84343 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
84344 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
84345
84346 /* Pick up current idle and NMI-nesting counter and check. */
84347 - cur = atomic_read(&rdtp->dynticks_idle);
84348 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
84349 if (cur & 0x1) {
84350 *isidle = false; /* We are not idle! */
84351 return;
84352 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
84353 index cf6c174..a8f4b50 100644
84354 --- a/kernel/rcutree_trace.c
84355 +++ b/kernel/rcutree_trace.c
84356 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
84357 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
84358 rdp->passed_quiesce, rdp->qs_pending);
84359 seq_printf(m, " dt=%d/%llx/%d df=%lu",
84360 - atomic_read(&rdp->dynticks->dynticks),
84361 + atomic_read_unchecked(&rdp->dynticks->dynticks),
84362 rdp->dynticks->dynticks_nesting,
84363 rdp->dynticks->dynticks_nmi_nesting,
84364 rdp->dynticks_fqs);
84365 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
84366 struct rcu_state *rsp = (struct rcu_state *)m->private;
84367
84368 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",
84369 - atomic_long_read(&rsp->expedited_start),
84370 + atomic_long_read_unchecked(&rsp->expedited_start),
84371 atomic_long_read(&rsp->expedited_done),
84372 - atomic_long_read(&rsp->expedited_wrap),
84373 - atomic_long_read(&rsp->expedited_tryfail),
84374 - atomic_long_read(&rsp->expedited_workdone1),
84375 - atomic_long_read(&rsp->expedited_workdone2),
84376 - atomic_long_read(&rsp->expedited_normal),
84377 - atomic_long_read(&rsp->expedited_stoppedcpus),
84378 - atomic_long_read(&rsp->expedited_done_tries),
84379 - atomic_long_read(&rsp->expedited_done_lost),
84380 - atomic_long_read(&rsp->expedited_done_exit));
84381 + atomic_long_read_unchecked(&rsp->expedited_wrap),
84382 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
84383 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
84384 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
84385 + atomic_long_read_unchecked(&rsp->expedited_normal),
84386 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
84387 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
84388 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
84389 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
84390 return 0;
84391 }
84392
84393 diff --git a/kernel/resource.c b/kernel/resource.c
84394 index 3f285dc..5755f62 100644
84395 --- a/kernel/resource.c
84396 +++ b/kernel/resource.c
84397 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
84398
84399 static int __init ioresources_init(void)
84400 {
84401 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84402 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84403 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
84404 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
84405 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84406 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
84407 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
84408 +#endif
84409 +#else
84410 proc_create("ioports", 0, NULL, &proc_ioports_operations);
84411 proc_create("iomem", 0, NULL, &proc_iomem_operations);
84412 +#endif
84413 return 0;
84414 }
84415 __initcall(ioresources_init);
84416 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
84417 index 1d96dd0..994ff19 100644
84418 --- a/kernel/rtmutex-tester.c
84419 +++ b/kernel/rtmutex-tester.c
84420 @@ -22,7 +22,7 @@
84421 #define MAX_RT_TEST_MUTEXES 8
84422
84423 static spinlock_t rttest_lock;
84424 -static atomic_t rttest_event;
84425 +static atomic_unchecked_t rttest_event;
84426
84427 struct test_thread_data {
84428 int opcode;
84429 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84430
84431 case RTTEST_LOCKCONT:
84432 td->mutexes[td->opdata] = 1;
84433 - td->event = atomic_add_return(1, &rttest_event);
84434 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84435 return 0;
84436
84437 case RTTEST_RESET:
84438 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84439 return 0;
84440
84441 case RTTEST_RESETEVENT:
84442 - atomic_set(&rttest_event, 0);
84443 + atomic_set_unchecked(&rttest_event, 0);
84444 return 0;
84445
84446 default:
84447 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84448 return ret;
84449
84450 td->mutexes[id] = 1;
84451 - td->event = atomic_add_return(1, &rttest_event);
84452 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84453 rt_mutex_lock(&mutexes[id]);
84454 - td->event = atomic_add_return(1, &rttest_event);
84455 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84456 td->mutexes[id] = 4;
84457 return 0;
84458
84459 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84460 return ret;
84461
84462 td->mutexes[id] = 1;
84463 - td->event = atomic_add_return(1, &rttest_event);
84464 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84465 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
84466 - td->event = atomic_add_return(1, &rttest_event);
84467 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84468 td->mutexes[id] = ret ? 0 : 4;
84469 return ret ? -EINTR : 0;
84470
84471 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84472 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
84473 return ret;
84474
84475 - td->event = atomic_add_return(1, &rttest_event);
84476 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84477 rt_mutex_unlock(&mutexes[id]);
84478 - td->event = atomic_add_return(1, &rttest_event);
84479 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84480 td->mutexes[id] = 0;
84481 return 0;
84482
84483 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84484 break;
84485
84486 td->mutexes[dat] = 2;
84487 - td->event = atomic_add_return(1, &rttest_event);
84488 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84489 break;
84490
84491 default:
84492 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84493 return;
84494
84495 td->mutexes[dat] = 3;
84496 - td->event = atomic_add_return(1, &rttest_event);
84497 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84498 break;
84499
84500 case RTTEST_LOCKNOWAIT:
84501 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84502 return;
84503
84504 td->mutexes[dat] = 1;
84505 - td->event = atomic_add_return(1, &rttest_event);
84506 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84507 return;
84508
84509 default:
84510 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
84511 index 4a07353..66b5291 100644
84512 --- a/kernel/sched/auto_group.c
84513 +++ b/kernel/sched/auto_group.c
84514 @@ -11,7 +11,7 @@
84515
84516 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
84517 static struct autogroup autogroup_default;
84518 -static atomic_t autogroup_seq_nr;
84519 +static atomic_unchecked_t autogroup_seq_nr;
84520
84521 void __init autogroup_init(struct task_struct *init_task)
84522 {
84523 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
84524
84525 kref_init(&ag->kref);
84526 init_rwsem(&ag->lock);
84527 - ag->id = atomic_inc_return(&autogroup_seq_nr);
84528 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
84529 ag->tg = tg;
84530 #ifdef CONFIG_RT_GROUP_SCHED
84531 /*
84532 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
84533 index 5ac63c9..d912786 100644
84534 --- a/kernel/sched/core.c
84535 +++ b/kernel/sched/core.c
84536 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
84537 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84538 * or number of jiffies left till timeout) if completed.
84539 */
84540 -long __sched
84541 +long __sched __intentional_overflow(-1)
84542 wait_for_completion_interruptible_timeout(struct completion *x,
84543 unsigned long timeout)
84544 {
84545 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
84546 *
84547 * Return: -ERESTARTSYS if interrupted, 0 if completed.
84548 */
84549 -int __sched wait_for_completion_killable(struct completion *x)
84550 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
84551 {
84552 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
84553 if (t == -ERESTARTSYS)
84554 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
84555 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84556 * or number of jiffies left till timeout) if completed.
84557 */
84558 -long __sched
84559 +long __sched __intentional_overflow(-1)
84560 wait_for_completion_killable_timeout(struct completion *x,
84561 unsigned long timeout)
84562 {
84563 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
84564 /* convert nice value [19,-20] to rlimit style value [1,40] */
84565 int nice_rlim = 20 - nice;
84566
84567 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
84568 +
84569 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
84570 capable(CAP_SYS_NICE));
84571 }
84572 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
84573 if (nice > 19)
84574 nice = 19;
84575
84576 - if (increment < 0 && !can_nice(current, nice))
84577 + if (increment < 0 && (!can_nice(current, nice) ||
84578 + gr_handle_chroot_nice()))
84579 return -EPERM;
84580
84581 retval = security_task_setnice(current, nice);
84582 @@ -3327,6 +3330,7 @@ recheck:
84583 unsigned long rlim_rtprio =
84584 task_rlimit(p, RLIMIT_RTPRIO);
84585
84586 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
84587 /* can't set/change the rt policy */
84588 if (policy != p->policy && !rlim_rtprio)
84589 return -EPERM;
84590 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
84591
84592 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
84593
84594 -static struct ctl_table sd_ctl_dir[] = {
84595 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
84596 {
84597 .procname = "sched_domain",
84598 .mode = 0555,
84599 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
84600 {}
84601 };
84602
84603 -static struct ctl_table *sd_alloc_ctl_entry(int n)
84604 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
84605 {
84606 - struct ctl_table *entry =
84607 + ctl_table_no_const *entry =
84608 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
84609
84610 return entry;
84611 }
84612
84613 -static void sd_free_ctl_entry(struct ctl_table **tablep)
84614 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
84615 {
84616 - struct ctl_table *entry;
84617 + ctl_table_no_const *entry;
84618
84619 /*
84620 * In the intermediate directories, both the child directory and
84621 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
84622 * will always be set. In the lowest directory the names are
84623 * static strings and all have proc handlers.
84624 */
84625 - for (entry = *tablep; entry->mode; entry++) {
84626 - if (entry->child)
84627 - sd_free_ctl_entry(&entry->child);
84628 + for (entry = tablep; entry->mode; entry++) {
84629 + if (entry->child) {
84630 + sd_free_ctl_entry(entry->child);
84631 + pax_open_kernel();
84632 + entry->child = NULL;
84633 + pax_close_kernel();
84634 + }
84635 if (entry->proc_handler == NULL)
84636 kfree(entry->procname);
84637 }
84638
84639 - kfree(*tablep);
84640 - *tablep = NULL;
84641 + kfree(tablep);
84642 }
84643
84644 static int min_load_idx = 0;
84645 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84646
84647 static void
84648 -set_table_entry(struct ctl_table *entry,
84649 +set_table_entry(ctl_table_no_const *entry,
84650 const char *procname, void *data, int maxlen,
84651 umode_t mode, proc_handler *proc_handler,
84652 bool load_idx)
84653 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
84654 static struct ctl_table *
84655 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84656 {
84657 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84658 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84659
84660 if (table == NULL)
84661 return NULL;
84662 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84663 return table;
84664 }
84665
84666 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84667 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84668 {
84669 - struct ctl_table *entry, *table;
84670 + ctl_table_no_const *entry, *table;
84671 struct sched_domain *sd;
84672 int domain_num = 0, i;
84673 char buf[32];
84674 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
84675 static void register_sched_domain_sysctl(void)
84676 {
84677 int i, cpu_num = num_possible_cpus();
84678 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84679 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84680 char buf[32];
84681
84682 WARN_ON(sd_ctl_dir[0].child);
84683 + pax_open_kernel();
84684 sd_ctl_dir[0].child = entry;
84685 + pax_close_kernel();
84686
84687 if (entry == NULL)
84688 return;
84689 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
84690 if (sd_sysctl_header)
84691 unregister_sysctl_table(sd_sysctl_header);
84692 sd_sysctl_header = NULL;
84693 - if (sd_ctl_dir[0].child)
84694 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
84695 + if (sd_ctl_dir[0].child) {
84696 + sd_free_ctl_entry(sd_ctl_dir[0].child);
84697 + pax_open_kernel();
84698 + sd_ctl_dir[0].child = NULL;
84699 + pax_close_kernel();
84700 + }
84701 }
84702 #else
84703 static void register_sched_domain_sysctl(void)
84704 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
84705 index 7c70201..23f52b6 100644
84706 --- a/kernel/sched/fair.c
84707 +++ b/kernel/sched/fair.c
84708 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
84709
84710 static void reset_ptenuma_scan(struct task_struct *p)
84711 {
84712 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
84713 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
84714 p->mm->numa_scan_offset = 0;
84715 }
84716
84717 @@ -5838,7 +5838,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
84718 * run_rebalance_domains is triggered when needed from the scheduler tick.
84719 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
84720 */
84721 -static void run_rebalance_domains(struct softirq_action *h)
84722 +static __latent_entropy void run_rebalance_domains(void)
84723 {
84724 int this_cpu = smp_processor_id();
84725 struct rq *this_rq = cpu_rq(this_cpu);
84726 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
84727 index b3c5653..a4d192a 100644
84728 --- a/kernel/sched/sched.h
84729 +++ b/kernel/sched/sched.h
84730 @@ -1004,7 +1004,7 @@ struct sched_class {
84731 #ifdef CONFIG_FAIR_GROUP_SCHED
84732 void (*task_move_group) (struct task_struct *p, int on_rq);
84733 #endif
84734 -};
84735 +} __do_const;
84736
84737 #define sched_class_highest (&stop_sched_class)
84738 #define for_each_class(class) \
84739 diff --git a/kernel/signal.c b/kernel/signal.c
84740 index ded28b9..6886c08 100644
84741 --- a/kernel/signal.c
84742 +++ b/kernel/signal.c
84743 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
84744
84745 int print_fatal_signals __read_mostly;
84746
84747 -static void __user *sig_handler(struct task_struct *t, int sig)
84748 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
84749 {
84750 return t->sighand->action[sig - 1].sa.sa_handler;
84751 }
84752
84753 -static int sig_handler_ignored(void __user *handler, int sig)
84754 +static int sig_handler_ignored(__sighandler_t handler, int sig)
84755 {
84756 /* Is it explicitly or implicitly ignored? */
84757 return handler == SIG_IGN ||
84758 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
84759
84760 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
84761 {
84762 - void __user *handler;
84763 + __sighandler_t handler;
84764
84765 handler = sig_handler(t, sig);
84766
84767 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
84768 atomic_inc(&user->sigpending);
84769 rcu_read_unlock();
84770
84771 + if (!override_rlimit)
84772 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
84773 +
84774 if (override_rlimit ||
84775 atomic_read(&user->sigpending) <=
84776 task_rlimit(t, RLIMIT_SIGPENDING)) {
84777 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
84778
84779 int unhandled_signal(struct task_struct *tsk, int sig)
84780 {
84781 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
84782 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
84783 if (is_global_init(tsk))
84784 return 1;
84785 if (handler != SIG_IGN && handler != SIG_DFL)
84786 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
84787 }
84788 }
84789
84790 + /* allow glibc communication via tgkill to other threads in our
84791 + thread group */
84792 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
84793 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
84794 + && gr_handle_signal(t, sig))
84795 + return -EPERM;
84796 +
84797 return security_task_kill(t, info, sig, 0);
84798 }
84799
84800 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84801 return send_signal(sig, info, p, 1);
84802 }
84803
84804 -static int
84805 +int
84806 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84807 {
84808 return send_signal(sig, info, t, 0);
84809 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84810 unsigned long int flags;
84811 int ret, blocked, ignored;
84812 struct k_sigaction *action;
84813 + int is_unhandled = 0;
84814
84815 spin_lock_irqsave(&t->sighand->siglock, flags);
84816 action = &t->sighand->action[sig-1];
84817 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84818 }
84819 if (action->sa.sa_handler == SIG_DFL)
84820 t->signal->flags &= ~SIGNAL_UNKILLABLE;
84821 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
84822 + is_unhandled = 1;
84823 ret = specific_send_sig_info(sig, info, t);
84824 spin_unlock_irqrestore(&t->sighand->siglock, flags);
84825
84826 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
84827 + normal operation */
84828 + if (is_unhandled) {
84829 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
84830 + gr_handle_crash(t, sig);
84831 + }
84832 +
84833 return ret;
84834 }
84835
84836 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84837 ret = check_kill_permission(sig, info, p);
84838 rcu_read_unlock();
84839
84840 - if (!ret && sig)
84841 + if (!ret && sig) {
84842 ret = do_send_sig_info(sig, info, p, true);
84843 + if (!ret)
84844 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
84845 + }
84846
84847 return ret;
84848 }
84849 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
84850 int error = -ESRCH;
84851
84852 rcu_read_lock();
84853 - p = find_task_by_vpid(pid);
84854 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
84855 + /* allow glibc communication via tgkill to other threads in our
84856 + thread group */
84857 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
84858 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
84859 + p = find_task_by_vpid_unrestricted(pid);
84860 + else
84861 +#endif
84862 + p = find_task_by_vpid(pid);
84863 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
84864 error = check_kill_permission(sig, info, p);
84865 /*
84866 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
84867 }
84868 seg = get_fs();
84869 set_fs(KERNEL_DS);
84870 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
84871 - (stack_t __force __user *) &uoss,
84872 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
84873 + (stack_t __force_user *) &uoss,
84874 compat_user_stack_pointer());
84875 set_fs(seg);
84876 if (ret >= 0 && uoss_ptr) {
84877 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
84878 index eb89e18..a4e6792 100644
84879 --- a/kernel/smpboot.c
84880 +++ b/kernel/smpboot.c
84881 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
84882 }
84883 smpboot_unpark_thread(plug_thread, cpu);
84884 }
84885 - list_add(&plug_thread->list, &hotplug_threads);
84886 + pax_list_add(&plug_thread->list, &hotplug_threads);
84887 out:
84888 mutex_unlock(&smpboot_threads_lock);
84889 return ret;
84890 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
84891 {
84892 get_online_cpus();
84893 mutex_lock(&smpboot_threads_lock);
84894 - list_del(&plug_thread->list);
84895 + pax_list_del(&plug_thread->list);
84896 smpboot_destroy_threads(plug_thread);
84897 mutex_unlock(&smpboot_threads_lock);
84898 put_online_cpus();
84899 diff --git a/kernel/softirq.c b/kernel/softirq.c
84900 index d7d498d..94fe0f7 100644
84901 --- a/kernel/softirq.c
84902 +++ b/kernel/softirq.c
84903 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
84904 EXPORT_SYMBOL(irq_stat);
84905 #endif
84906
84907 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
84908 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
84909
84910 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
84911
84912 -char *softirq_to_name[NR_SOFTIRQS] = {
84913 +const char * const softirq_to_name[NR_SOFTIRQS] = {
84914 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
84915 "TASKLET", "SCHED", "HRTIMER", "RCU"
84916 };
84917 @@ -248,7 +248,7 @@ restart:
84918 kstat_incr_softirqs_this_cpu(vec_nr);
84919
84920 trace_softirq_entry(vec_nr);
84921 - h->action(h);
84922 + h->action();
84923 trace_softirq_exit(vec_nr);
84924 if (unlikely(prev_count != preempt_count())) {
84925 printk(KERN_ERR "huh, entered softirq %u %s %p"
84926 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
84927 or_softirq_pending(1UL << nr);
84928 }
84929
84930 -void open_softirq(int nr, void (*action)(struct softirq_action *))
84931 +void __init open_softirq(int nr, void (*action)(void))
84932 {
84933 softirq_vec[nr].action = action;
84934 }
84935 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
84936
84937 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
84938
84939 -static void tasklet_action(struct softirq_action *a)
84940 +static __latent_entropy void tasklet_action(void)
84941 {
84942 struct tasklet_struct *list;
84943
84944 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
84945 }
84946 }
84947
84948 -static void tasklet_hi_action(struct softirq_action *a)
84949 +static __latent_entropy void tasklet_hi_action(void)
84950 {
84951 struct tasklet_struct *list;
84952
84953 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
84954 .notifier_call = cpu_callback
84955 };
84956
84957 -static struct smp_hotplug_thread softirq_threads = {
84958 +static struct smp_hotplug_thread softirq_threads __read_only = {
84959 .store = &ksoftirqd,
84960 .thread_should_run = ksoftirqd_should_run,
84961 .thread_fn = run_ksoftirqd,
84962 diff --git a/kernel/srcu.c b/kernel/srcu.c
84963 index 01d5ccb..cdcbee6 100644
84964 --- a/kernel/srcu.c
84965 +++ b/kernel/srcu.c
84966 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
84967
84968 idx = ACCESS_ONCE(sp->completed) & 0x1;
84969 preempt_disable();
84970 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84971 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84972 smp_mb(); /* B */ /* Avoid leaking the critical section. */
84973 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84974 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84975 preempt_enable();
84976 return idx;
84977 }
84978 diff --git a/kernel/sys.c b/kernel/sys.c
84979 index c18ecca..b3c2dd2 100644
84980 --- a/kernel/sys.c
84981 +++ b/kernel/sys.c
84982 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
84983 error = -EACCES;
84984 goto out;
84985 }
84986 +
84987 + if (gr_handle_chroot_setpriority(p, niceval)) {
84988 + error = -EACCES;
84989 + goto out;
84990 + }
84991 +
84992 no_nice = security_task_setnice(p, niceval);
84993 if (no_nice) {
84994 error = no_nice;
84995 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
84996 goto error;
84997 }
84998
84999 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85000 + goto error;
85001 +
85002 if (rgid != (gid_t) -1 ||
85003 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85004 new->sgid = new->egid;
85005 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85006 old = current_cred();
85007
85008 retval = -EPERM;
85009 +
85010 + if (gr_check_group_change(kgid, kgid, kgid))
85011 + goto error;
85012 +
85013 if (ns_capable(old->user_ns, CAP_SETGID))
85014 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85015 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85016 @@ -404,7 +417,7 @@ error:
85017 /*
85018 * change the user struct in a credentials set to match the new UID
85019 */
85020 -static int set_user(struct cred *new)
85021 +int set_user(struct cred *new)
85022 {
85023 struct user_struct *new_user;
85024
85025 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85026 goto error;
85027 }
85028
85029 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85030 + goto error;
85031 +
85032 if (!uid_eq(new->uid, old->uid)) {
85033 retval = set_user(new);
85034 if (retval < 0)
85035 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85036 old = current_cred();
85037
85038 retval = -EPERM;
85039 +
85040 + if (gr_check_crash_uid(kuid))
85041 + goto error;
85042 + if (gr_check_user_change(kuid, kuid, kuid))
85043 + goto error;
85044 +
85045 if (ns_capable(old->user_ns, CAP_SETUID)) {
85046 new->suid = new->uid = kuid;
85047 if (!uid_eq(kuid, old->uid)) {
85048 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85049 goto error;
85050 }
85051
85052 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85053 + goto error;
85054 +
85055 if (ruid != (uid_t) -1) {
85056 new->uid = kruid;
85057 if (!uid_eq(kruid, old->uid)) {
85058 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85059 goto error;
85060 }
85061
85062 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85063 + goto error;
85064 +
85065 if (rgid != (gid_t) -1)
85066 new->gid = krgid;
85067 if (egid != (gid_t) -1)
85068 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85069 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85070 ns_capable(old->user_ns, CAP_SETUID)) {
85071 if (!uid_eq(kuid, old->fsuid)) {
85072 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85073 + goto error;
85074 +
85075 new->fsuid = kuid;
85076 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85077 goto change_okay;
85078 }
85079 }
85080
85081 +error:
85082 abort_creds(new);
85083 return old_fsuid;
85084
85085 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85086 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85087 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85088 ns_capable(old->user_ns, CAP_SETGID)) {
85089 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85090 + goto error;
85091 +
85092 if (!gid_eq(kgid, old->fsgid)) {
85093 new->fsgid = kgid;
85094 goto change_okay;
85095 }
85096 }
85097
85098 +error:
85099 abort_creds(new);
85100 return old_fsgid;
85101
85102 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85103 return -EFAULT;
85104
85105 down_read(&uts_sem);
85106 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85107 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85108 __OLD_UTS_LEN);
85109 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85110 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85111 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85112 __OLD_UTS_LEN);
85113 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85114 - error |= __copy_to_user(&name->release, &utsname()->release,
85115 + error |= __copy_to_user(name->release, &utsname()->release,
85116 __OLD_UTS_LEN);
85117 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85118 - error |= __copy_to_user(&name->version, &utsname()->version,
85119 + error |= __copy_to_user(name->version, &utsname()->version,
85120 __OLD_UTS_LEN);
85121 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85122 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85123 + error |= __copy_to_user(name->machine, &utsname()->machine,
85124 __OLD_UTS_LEN);
85125 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85126 up_read(&uts_sem);
85127 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85128 */
85129 new_rlim->rlim_cur = 1;
85130 }
85131 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85132 + is changed to a lower value. Since tasks can be created by the same
85133 + user in between this limit change and an execve by this task, force
85134 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85135 + */
85136 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85137 + tsk->flags |= PF_NPROC_EXCEEDED;
85138 }
85139 if (!retval) {
85140 if (old_rlim)
85141 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85142 index b2f06f3..e6354ab 100644
85143 --- a/kernel/sysctl.c
85144 +++ b/kernel/sysctl.c
85145 @@ -93,7 +93,6 @@
85146
85147
85148 #if defined(CONFIG_SYSCTL)
85149 -
85150 /* External variables not in a header file. */
85151 extern int sysctl_overcommit_memory;
85152 extern int sysctl_overcommit_ratio;
85153 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
85154
85155 /* Constants used for minimum and maximum */
85156 #ifdef CONFIG_LOCKUP_DETECTOR
85157 -static int sixty = 60;
85158 +static int sixty __read_only = 60;
85159 #endif
85160
85161 -static int zero;
85162 -static int __maybe_unused one = 1;
85163 -static int __maybe_unused two = 2;
85164 -static int __maybe_unused three = 3;
85165 -static unsigned long one_ul = 1;
85166 -static int one_hundred = 100;
85167 +static int neg_one __read_only = -1;
85168 +static int zero __read_only = 0;
85169 +static int __maybe_unused one __read_only = 1;
85170 +static int __maybe_unused two __read_only = 2;
85171 +static int __maybe_unused three __read_only = 3;
85172 +static unsigned long one_ul __read_only = 1;
85173 +static int one_hundred __read_only = 100;
85174 #ifdef CONFIG_PRINTK
85175 -static int ten_thousand = 10000;
85176 +static int ten_thousand __read_only = 10000;
85177 #endif
85178
85179 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85180 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85181 void __user *buffer, size_t *lenp, loff_t *ppos);
85182 #endif
85183
85184 -#ifdef CONFIG_PRINTK
85185 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85186 void __user *buffer, size_t *lenp, loff_t *ppos);
85187 -#endif
85188
85189 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85190 void __user *buffer, size_t *lenp, loff_t *ppos);
85191 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85192
85193 #endif
85194
85195 +extern struct ctl_table grsecurity_table[];
85196 +
85197 static struct ctl_table kern_table[];
85198 static struct ctl_table vm_table[];
85199 static struct ctl_table fs_table[];
85200 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
85201 int sysctl_legacy_va_layout;
85202 #endif
85203
85204 +#ifdef CONFIG_PAX_SOFTMODE
85205 +static ctl_table pax_table[] = {
85206 + {
85207 + .procname = "softmode",
85208 + .data = &pax_softmode,
85209 + .maxlen = sizeof(unsigned int),
85210 + .mode = 0600,
85211 + .proc_handler = &proc_dointvec,
85212 + },
85213 +
85214 + { }
85215 +};
85216 +#endif
85217 +
85218 /* The default sysctl tables: */
85219
85220 static struct ctl_table sysctl_base_table[] = {
85221 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
85222 #endif
85223
85224 static struct ctl_table kern_table[] = {
85225 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
85226 + {
85227 + .procname = "grsecurity",
85228 + .mode = 0500,
85229 + .child = grsecurity_table,
85230 + },
85231 +#endif
85232 +
85233 +#ifdef CONFIG_PAX_SOFTMODE
85234 + {
85235 + .procname = "pax",
85236 + .mode = 0500,
85237 + .child = pax_table,
85238 + },
85239 +#endif
85240 +
85241 {
85242 .procname = "sched_child_runs_first",
85243 .data = &sysctl_sched_child_runs_first,
85244 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
85245 .data = &modprobe_path,
85246 .maxlen = KMOD_PATH_LEN,
85247 .mode = 0644,
85248 - .proc_handler = proc_dostring,
85249 + .proc_handler = proc_dostring_modpriv,
85250 },
85251 {
85252 .procname = "modules_disabled",
85253 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
85254 .extra1 = &zero,
85255 .extra2 = &one,
85256 },
85257 +#endif
85258 {
85259 .procname = "kptr_restrict",
85260 .data = &kptr_restrict,
85261 .maxlen = sizeof(int),
85262 .mode = 0644,
85263 .proc_handler = proc_dointvec_minmax_sysadmin,
85264 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85265 + .extra1 = &two,
85266 +#else
85267 .extra1 = &zero,
85268 +#endif
85269 .extra2 = &two,
85270 },
85271 -#endif
85272 {
85273 .procname = "ngroups_max",
85274 .data = &ngroups_max,
85275 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
85276 */
85277 {
85278 .procname = "perf_event_paranoid",
85279 - .data = &sysctl_perf_event_paranoid,
85280 - .maxlen = sizeof(sysctl_perf_event_paranoid),
85281 + .data = &sysctl_perf_event_legitimately_concerned,
85282 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
85283 .mode = 0644,
85284 - .proc_handler = proc_dointvec,
85285 + /* go ahead, be a hero */
85286 + .proc_handler = proc_dointvec_minmax_sysadmin,
85287 + .extra1 = &neg_one,
85288 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85289 + .extra2 = &three,
85290 +#else
85291 + .extra2 = &two,
85292 +#endif
85293 },
85294 {
85295 .procname = "perf_event_mlock_kb",
85296 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
85297 .proc_handler = proc_dointvec_minmax,
85298 .extra1 = &zero,
85299 },
85300 + {
85301 + .procname = "heap_stack_gap",
85302 + .data = &sysctl_heap_stack_gap,
85303 + .maxlen = sizeof(sysctl_heap_stack_gap),
85304 + .mode = 0644,
85305 + .proc_handler = proc_doulongvec_minmax,
85306 + },
85307 #else
85308 {
85309 .procname = "nr_trim_pages",
85310 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
85311 buffer, lenp, ppos);
85312 }
85313
85314 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85315 + void __user *buffer, size_t *lenp, loff_t *ppos)
85316 +{
85317 + if (write && !capable(CAP_SYS_MODULE))
85318 + return -EPERM;
85319 +
85320 + return _proc_do_string(table->data, table->maxlen, write,
85321 + buffer, lenp, ppos);
85322 +}
85323 +
85324 static size_t proc_skip_spaces(char **buf)
85325 {
85326 size_t ret;
85327 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
85328 len = strlen(tmp);
85329 if (len > *size)
85330 len = *size;
85331 + if (len > sizeof(tmp))
85332 + len = sizeof(tmp);
85333 if (copy_to_user(*buf, tmp, len))
85334 return -EFAULT;
85335 *size -= len;
85336 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
85337 static int proc_taint(struct ctl_table *table, int write,
85338 void __user *buffer, size_t *lenp, loff_t *ppos)
85339 {
85340 - struct ctl_table t;
85341 + ctl_table_no_const t;
85342 unsigned long tmptaint = get_taint();
85343 int err;
85344
85345 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
85346 return err;
85347 }
85348
85349 -#ifdef CONFIG_PRINTK
85350 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85351 void __user *buffer, size_t *lenp, loff_t *ppos)
85352 {
85353 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85354
85355 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
85356 }
85357 -#endif
85358
85359 struct do_proc_dointvec_minmax_conv_param {
85360 int *min;
85361 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
85362 *i = val;
85363 } else {
85364 val = convdiv * (*i) / convmul;
85365 - if (!first)
85366 + if (!first) {
85367 err = proc_put_char(&buffer, &left, '\t');
85368 + if (err)
85369 + break;
85370 + }
85371 err = proc_put_long(&buffer, &left, val, false);
85372 if (err)
85373 break;
85374 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
85375 return -ENOSYS;
85376 }
85377
85378 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85379 + void __user *buffer, size_t *lenp, loff_t *ppos)
85380 +{
85381 + return -ENOSYS;
85382 +}
85383 +
85384 int proc_dointvec(struct ctl_table *table, int write,
85385 void __user *buffer, size_t *lenp, loff_t *ppos)
85386 {
85387 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
85388 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
85389 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
85390 EXPORT_SYMBOL(proc_dostring);
85391 +EXPORT_SYMBOL(proc_dostring_modpriv);
85392 EXPORT_SYMBOL(proc_doulongvec_minmax);
85393 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
85394 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
85395 index 145bb4d..b2aa969 100644
85396 --- a/kernel/taskstats.c
85397 +++ b/kernel/taskstats.c
85398 @@ -28,9 +28,12 @@
85399 #include <linux/fs.h>
85400 #include <linux/file.h>
85401 #include <linux/pid_namespace.h>
85402 +#include <linux/grsecurity.h>
85403 #include <net/genetlink.h>
85404 #include <linux/atomic.h>
85405
85406 +extern int gr_is_taskstats_denied(int pid);
85407 +
85408 /*
85409 * Maximum length of a cpumask that can be specified in
85410 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
85411 @@ -570,6 +573,9 @@ err:
85412
85413 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
85414 {
85415 + if (gr_is_taskstats_denied(current->pid))
85416 + return -EACCES;
85417 +
85418 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
85419 return cmd_attr_register_cpumask(info);
85420 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
85421 diff --git a/kernel/time.c b/kernel/time.c
85422 index 7c7964c..2a0d412 100644
85423 --- a/kernel/time.c
85424 +++ b/kernel/time.c
85425 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
85426 return error;
85427
85428 if (tz) {
85429 + /* we log in do_settimeofday called below, so don't log twice
85430 + */
85431 + if (!tv)
85432 + gr_log_timechange();
85433 +
85434 sys_tz = *tz;
85435 update_vsyscall_tz();
85436 if (firsttime) {
85437 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
85438 index eec50fc..65e5df6 100644
85439 --- a/kernel/time/alarmtimer.c
85440 +++ b/kernel/time/alarmtimer.c
85441 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
85442 struct platform_device *pdev;
85443 int error = 0;
85444 int i;
85445 - struct k_clock alarm_clock = {
85446 + static struct k_clock alarm_clock = {
85447 .clock_getres = alarm_clock_getres,
85448 .clock_get = alarm_clock_get,
85449 .timer_create = alarm_timer_create,
85450 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
85451 index 947ba25..20cbade 100644
85452 --- a/kernel/time/timekeeping.c
85453 +++ b/kernel/time/timekeeping.c
85454 @@ -15,6 +15,7 @@
85455 #include <linux/init.h>
85456 #include <linux/mm.h>
85457 #include <linux/sched.h>
85458 +#include <linux/grsecurity.h>
85459 #include <linux/syscore_ops.h>
85460 #include <linux/clocksource.h>
85461 #include <linux/jiffies.h>
85462 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
85463 if (!timespec_valid_strict(tv))
85464 return -EINVAL;
85465
85466 + gr_log_timechange();
85467 +
85468 raw_spin_lock_irqsave(&timekeeper_lock, flags);
85469 write_seqcount_begin(&timekeeper_seq);
85470
85471 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
85472 index 61ed862..3b52c65 100644
85473 --- a/kernel/time/timer_list.c
85474 +++ b/kernel/time/timer_list.c
85475 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
85476
85477 static void print_name_offset(struct seq_file *m, void *sym)
85478 {
85479 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85480 + SEQ_printf(m, "<%p>", NULL);
85481 +#else
85482 char symname[KSYM_NAME_LEN];
85483
85484 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
85485 SEQ_printf(m, "<%pK>", sym);
85486 else
85487 SEQ_printf(m, "%s", symname);
85488 +#endif
85489 }
85490
85491 static void
85492 @@ -119,7 +123,11 @@ next_one:
85493 static void
85494 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
85495 {
85496 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85497 + SEQ_printf(m, " .base: %p\n", NULL);
85498 +#else
85499 SEQ_printf(m, " .base: %pK\n", base);
85500 +#endif
85501 SEQ_printf(m, " .index: %d\n",
85502 base->index);
85503 SEQ_printf(m, " .resolution: %Lu nsecs\n",
85504 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
85505 {
85506 struct proc_dir_entry *pe;
85507
85508 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85509 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
85510 +#else
85511 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
85512 +#endif
85513 if (!pe)
85514 return -ENOMEM;
85515 return 0;
85516 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
85517 index 0b537f2..40d6c20 100644
85518 --- a/kernel/time/timer_stats.c
85519 +++ b/kernel/time/timer_stats.c
85520 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
85521 static unsigned long nr_entries;
85522 static struct entry entries[MAX_ENTRIES];
85523
85524 -static atomic_t overflow_count;
85525 +static atomic_unchecked_t overflow_count;
85526
85527 /*
85528 * The entries are in a hash-table, for fast lookup:
85529 @@ -140,7 +140,7 @@ static void reset_entries(void)
85530 nr_entries = 0;
85531 memset(entries, 0, sizeof(entries));
85532 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
85533 - atomic_set(&overflow_count, 0);
85534 + atomic_set_unchecked(&overflow_count, 0);
85535 }
85536
85537 static struct entry *alloc_entry(void)
85538 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85539 if (likely(entry))
85540 entry->count++;
85541 else
85542 - atomic_inc(&overflow_count);
85543 + atomic_inc_unchecked(&overflow_count);
85544
85545 out_unlock:
85546 raw_spin_unlock_irqrestore(lock, flags);
85547 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85548
85549 static void print_name_offset(struct seq_file *m, unsigned long addr)
85550 {
85551 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85552 + seq_printf(m, "<%p>", NULL);
85553 +#else
85554 char symname[KSYM_NAME_LEN];
85555
85556 if (lookup_symbol_name(addr, symname) < 0)
85557 - seq_printf(m, "<%p>", (void *)addr);
85558 + seq_printf(m, "<%pK>", (void *)addr);
85559 else
85560 seq_printf(m, "%s", symname);
85561 +#endif
85562 }
85563
85564 static int tstats_show(struct seq_file *m, void *v)
85565 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
85566
85567 seq_puts(m, "Timer Stats Version: v0.2\n");
85568 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
85569 - if (atomic_read(&overflow_count))
85570 + if (atomic_read_unchecked(&overflow_count))
85571 seq_printf(m, "Overflow: %d entries\n",
85572 - atomic_read(&overflow_count));
85573 + atomic_read_unchecked(&overflow_count));
85574
85575 for (i = 0; i < nr_entries; i++) {
85576 entry = entries + i;
85577 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
85578 {
85579 struct proc_dir_entry *pe;
85580
85581 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85582 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
85583 +#else
85584 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
85585 +#endif
85586 if (!pe)
85587 return -ENOMEM;
85588 return 0;
85589 diff --git a/kernel/timer.c b/kernel/timer.c
85590 index 4296d13..0164b04 100644
85591 --- a/kernel/timer.c
85592 +++ b/kernel/timer.c
85593 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
85594 /*
85595 * This function runs timers and the timer-tq in bottom half context.
85596 */
85597 -static void run_timer_softirq(struct softirq_action *h)
85598 +static __latent_entropy void run_timer_softirq(void)
85599 {
85600 struct tvec_base *base = __this_cpu_read(tvec_bases);
85601
85602 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
85603 *
85604 * In all cases the return value is guaranteed to be non-negative.
85605 */
85606 -signed long __sched schedule_timeout(signed long timeout)
85607 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
85608 {
85609 struct timer_list timer;
85610 unsigned long expire;
85611 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
85612 index b8b8560..75b1a09 100644
85613 --- a/kernel/trace/blktrace.c
85614 +++ b/kernel/trace/blktrace.c
85615 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
85616 struct blk_trace *bt = filp->private_data;
85617 char buf[16];
85618
85619 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
85620 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
85621
85622 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
85623 }
85624 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
85625 return 1;
85626
85627 bt = buf->chan->private_data;
85628 - atomic_inc(&bt->dropped);
85629 + atomic_inc_unchecked(&bt->dropped);
85630 return 0;
85631 }
85632
85633 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
85634
85635 bt->dir = dir;
85636 bt->dev = dev;
85637 - atomic_set(&bt->dropped, 0);
85638 + atomic_set_unchecked(&bt->dropped, 0);
85639
85640 ret = -EIO;
85641 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
85642 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
85643 index 03cf44a..3051c64 100644
85644 --- a/kernel/trace/ftrace.c
85645 +++ b/kernel/trace/ftrace.c
85646 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
85647 if (unlikely(ftrace_disabled))
85648 return 0;
85649
85650 + ret = ftrace_arch_code_modify_prepare();
85651 + FTRACE_WARN_ON(ret);
85652 + if (ret)
85653 + return 0;
85654 +
85655 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
85656 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
85657 if (ret) {
85658 ftrace_bug(ret, ip);
85659 - return 0;
85660 }
85661 - return 1;
85662 + return ret ? 0 : 1;
85663 }
85664
85665 /*
85666 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
85667 if (!count)
85668 return 0;
85669
85670 + pax_open_kernel();
85671 sort(start, count, sizeof(*start),
85672 ftrace_cmp_ips, ftrace_swap_ips);
85673 + pax_close_kernel();
85674
85675 start_pg = ftrace_allocate_pages(count);
85676 if (!start_pg)
85677 @@ -4767,8 +4774,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
85678 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
85679
85680 static int ftrace_graph_active;
85681 -static struct notifier_block ftrace_suspend_notifier;
85682 -
85683 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
85684 {
85685 return 0;
85686 @@ -4912,6 +4917,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
85687 return NOTIFY_DONE;
85688 }
85689
85690 +static struct notifier_block ftrace_suspend_notifier = {
85691 + .notifier_call = ftrace_suspend_notifier_call
85692 +};
85693 +
85694 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85695 trace_func_graph_ent_t entryfunc)
85696 {
85697 @@ -4925,7 +4934,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85698 goto out;
85699 }
85700
85701 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
85702 register_pm_notifier(&ftrace_suspend_notifier);
85703
85704 ftrace_graph_active++;
85705 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
85706 index cc2f66f..05edd54 100644
85707 --- a/kernel/trace/ring_buffer.c
85708 +++ b/kernel/trace/ring_buffer.c
85709 @@ -352,9 +352,9 @@ struct buffer_data_page {
85710 */
85711 struct buffer_page {
85712 struct list_head list; /* list of buffer pages */
85713 - local_t write; /* index for next write */
85714 + local_unchecked_t write; /* index for next write */
85715 unsigned read; /* index for next read */
85716 - local_t entries; /* entries on this page */
85717 + local_unchecked_t entries; /* entries on this page */
85718 unsigned long real_end; /* real end of data */
85719 struct buffer_data_page *page; /* Actual data page */
85720 };
85721 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
85722 unsigned long last_overrun;
85723 local_t entries_bytes;
85724 local_t entries;
85725 - local_t overrun;
85726 - local_t commit_overrun;
85727 + local_unchecked_t overrun;
85728 + local_unchecked_t commit_overrun;
85729 local_t dropped_events;
85730 local_t committing;
85731 local_t commits;
85732 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85733 *
85734 * We add a counter to the write field to denote this.
85735 */
85736 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
85737 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
85738 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
85739 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
85740
85741 /*
85742 * Just make sure we have seen our old_write and synchronize
85743 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85744 * cmpxchg to only update if an interrupt did not already
85745 * do it for us. If the cmpxchg fails, we don't care.
85746 */
85747 - (void)local_cmpxchg(&next_page->write, old_write, val);
85748 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
85749 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
85750 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
85751
85752 /*
85753 * No need to worry about races with clearing out the commit.
85754 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
85755
85756 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
85757 {
85758 - return local_read(&bpage->entries) & RB_WRITE_MASK;
85759 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
85760 }
85761
85762 static inline unsigned long rb_page_write(struct buffer_page *bpage)
85763 {
85764 - return local_read(&bpage->write) & RB_WRITE_MASK;
85765 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
85766 }
85767
85768 static int
85769 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
85770 * bytes consumed in ring buffer from here.
85771 * Increment overrun to account for the lost events.
85772 */
85773 - local_add(page_entries, &cpu_buffer->overrun);
85774 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
85775 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85776 }
85777
85778 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
85779 * it is our responsibility to update
85780 * the counters.
85781 */
85782 - local_add(entries, &cpu_buffer->overrun);
85783 + local_add_unchecked(entries, &cpu_buffer->overrun);
85784 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85785
85786 /*
85787 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85788 if (tail == BUF_PAGE_SIZE)
85789 tail_page->real_end = 0;
85790
85791 - local_sub(length, &tail_page->write);
85792 + local_sub_unchecked(length, &tail_page->write);
85793 return;
85794 }
85795
85796 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85797 rb_event_set_padding(event);
85798
85799 /* Set the write back to the previous setting */
85800 - local_sub(length, &tail_page->write);
85801 + local_sub_unchecked(length, &tail_page->write);
85802 return;
85803 }
85804
85805 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85806
85807 /* Set write to end of buffer */
85808 length = (tail + length) - BUF_PAGE_SIZE;
85809 - local_sub(length, &tail_page->write);
85810 + local_sub_unchecked(length, &tail_page->write);
85811 }
85812
85813 /*
85814 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85815 * about it.
85816 */
85817 if (unlikely(next_page == commit_page)) {
85818 - local_inc(&cpu_buffer->commit_overrun);
85819 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85820 goto out_reset;
85821 }
85822
85823 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85824 cpu_buffer->tail_page) &&
85825 (cpu_buffer->commit_page ==
85826 cpu_buffer->reader_page))) {
85827 - local_inc(&cpu_buffer->commit_overrun);
85828 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85829 goto out_reset;
85830 }
85831 }
85832 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85833 length += RB_LEN_TIME_EXTEND;
85834
85835 tail_page = cpu_buffer->tail_page;
85836 - write = local_add_return(length, &tail_page->write);
85837 + write = local_add_return_unchecked(length, &tail_page->write);
85838
85839 /* set write to only the index of the write */
85840 write &= RB_WRITE_MASK;
85841 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85842 kmemcheck_annotate_bitfield(event, bitfield);
85843 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
85844
85845 - local_inc(&tail_page->entries);
85846 + local_inc_unchecked(&tail_page->entries);
85847
85848 /*
85849 * If this is the first commit on the page, then update
85850 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85851
85852 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
85853 unsigned long write_mask =
85854 - local_read(&bpage->write) & ~RB_WRITE_MASK;
85855 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
85856 unsigned long event_length = rb_event_length(event);
85857 /*
85858 * This is on the tail page. It is possible that
85859 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85860 */
85861 old_index += write_mask;
85862 new_index += write_mask;
85863 - index = local_cmpxchg(&bpage->write, old_index, new_index);
85864 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
85865 if (index == old_index) {
85866 /* update counters */
85867 local_sub(event_length, &cpu_buffer->entries_bytes);
85868 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85869
85870 /* Do the likely case first */
85871 if (likely(bpage->page == (void *)addr)) {
85872 - local_dec(&bpage->entries);
85873 + local_dec_unchecked(&bpage->entries);
85874 return;
85875 }
85876
85877 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85878 start = bpage;
85879 do {
85880 if (bpage->page == (void *)addr) {
85881 - local_dec(&bpage->entries);
85882 + local_dec_unchecked(&bpage->entries);
85883 return;
85884 }
85885 rb_inc_page(cpu_buffer, &bpage);
85886 @@ -3139,7 +3139,7 @@ static inline unsigned long
85887 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
85888 {
85889 return local_read(&cpu_buffer->entries) -
85890 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
85891 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
85892 }
85893
85894 /**
85895 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
85896 return 0;
85897
85898 cpu_buffer = buffer->buffers[cpu];
85899 - ret = local_read(&cpu_buffer->overrun);
85900 + ret = local_read_unchecked(&cpu_buffer->overrun);
85901
85902 return ret;
85903 }
85904 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
85905 return 0;
85906
85907 cpu_buffer = buffer->buffers[cpu];
85908 - ret = local_read(&cpu_buffer->commit_overrun);
85909 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
85910
85911 return ret;
85912 }
85913 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
85914 /* if you care about this being correct, lock the buffer */
85915 for_each_buffer_cpu(buffer, cpu) {
85916 cpu_buffer = buffer->buffers[cpu];
85917 - overruns += local_read(&cpu_buffer->overrun);
85918 + overruns += local_read_unchecked(&cpu_buffer->overrun);
85919 }
85920
85921 return overruns;
85922 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85923 /*
85924 * Reset the reader page to size zero.
85925 */
85926 - local_set(&cpu_buffer->reader_page->write, 0);
85927 - local_set(&cpu_buffer->reader_page->entries, 0);
85928 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85929 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85930 local_set(&cpu_buffer->reader_page->page->commit, 0);
85931 cpu_buffer->reader_page->real_end = 0;
85932
85933 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85934 * want to compare with the last_overrun.
85935 */
85936 smp_mb();
85937 - overwrite = local_read(&(cpu_buffer->overrun));
85938 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
85939
85940 /*
85941 * Here's the tricky part.
85942 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85943
85944 cpu_buffer->head_page
85945 = list_entry(cpu_buffer->pages, struct buffer_page, list);
85946 - local_set(&cpu_buffer->head_page->write, 0);
85947 - local_set(&cpu_buffer->head_page->entries, 0);
85948 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
85949 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
85950 local_set(&cpu_buffer->head_page->page->commit, 0);
85951
85952 cpu_buffer->head_page->read = 0;
85953 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85954
85955 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
85956 INIT_LIST_HEAD(&cpu_buffer->new_pages);
85957 - local_set(&cpu_buffer->reader_page->write, 0);
85958 - local_set(&cpu_buffer->reader_page->entries, 0);
85959 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85960 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85961 local_set(&cpu_buffer->reader_page->page->commit, 0);
85962 cpu_buffer->reader_page->read = 0;
85963
85964 local_set(&cpu_buffer->entries_bytes, 0);
85965 - local_set(&cpu_buffer->overrun, 0);
85966 - local_set(&cpu_buffer->commit_overrun, 0);
85967 + local_set_unchecked(&cpu_buffer->overrun, 0);
85968 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
85969 local_set(&cpu_buffer->dropped_events, 0);
85970 local_set(&cpu_buffer->entries, 0);
85971 local_set(&cpu_buffer->committing, 0);
85972 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
85973 rb_init_page(bpage);
85974 bpage = reader->page;
85975 reader->page = *data_page;
85976 - local_set(&reader->write, 0);
85977 - local_set(&reader->entries, 0);
85978 + local_set_unchecked(&reader->write, 0);
85979 + local_set_unchecked(&reader->entries, 0);
85980 reader->read = 0;
85981 *data_page = bpage;
85982
85983 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
85984 index b778e96..4e84621 100644
85985 --- a/kernel/trace/trace.c
85986 +++ b/kernel/trace/trace.c
85987 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
85988 return 0;
85989 }
85990
85991 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
85992 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
85993 {
85994 /* do nothing if flag is already set */
85995 if (!!(trace_flags & mask) == !!enabled)
85996 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
85997 index 10c86fb..645ab0a 100644
85998 --- a/kernel/trace/trace.h
85999 +++ b/kernel/trace/trace.h
86000 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
86001 void trace_printk_init_buffers(void);
86002 void trace_printk_start_comm(void);
86003 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86004 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86005 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86006
86007 /*
86008 * Normal trace_printk() and friends allocates special buffers
86009 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86010 index 26dc348..8708ca7 100644
86011 --- a/kernel/trace/trace_clock.c
86012 +++ b/kernel/trace/trace_clock.c
86013 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86014 return now;
86015 }
86016
86017 -static atomic64_t trace_counter;
86018 +static atomic64_unchecked_t trace_counter;
86019
86020 /*
86021 * trace_clock_counter(): simply an atomic counter.
86022 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86023 */
86024 u64 notrace trace_clock_counter(void)
86025 {
86026 - return atomic64_add_return(1, &trace_counter);
86027 + return atomic64_inc_return_unchecked(&trace_counter);
86028 }
86029 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86030 index 368a4d5..7b6d1d5 100644
86031 --- a/kernel/trace/trace_events.c
86032 +++ b/kernel/trace/trace_events.c
86033 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
86034 return 0;
86035 }
86036
86037 -struct ftrace_module_file_ops;
86038 static void __add_event_to_tracers(struct ftrace_event_call *call);
86039
86040 /* Add an additional event_call dynamically */
86041 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86042 index b3dcfb2..ebee344 100644
86043 --- a/kernel/trace/trace_mmiotrace.c
86044 +++ b/kernel/trace/trace_mmiotrace.c
86045 @@ -24,7 +24,7 @@ struct header_iter {
86046 static struct trace_array *mmio_trace_array;
86047 static bool overrun_detected;
86048 static unsigned long prev_overruns;
86049 -static atomic_t dropped_count;
86050 +static atomic_unchecked_t dropped_count;
86051
86052 static void mmio_reset_data(struct trace_array *tr)
86053 {
86054 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86055
86056 static unsigned long count_overruns(struct trace_iterator *iter)
86057 {
86058 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86059 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86060 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86061
86062 if (over > prev_overruns)
86063 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86064 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86065 sizeof(*entry), 0, pc);
86066 if (!event) {
86067 - atomic_inc(&dropped_count);
86068 + atomic_inc_unchecked(&dropped_count);
86069 return;
86070 }
86071 entry = ring_buffer_event_data(event);
86072 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86073 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86074 sizeof(*entry), 0, pc);
86075 if (!event) {
86076 - atomic_inc(&dropped_count);
86077 + atomic_inc_unchecked(&dropped_count);
86078 return;
86079 }
86080 entry = ring_buffer_event_data(event);
86081 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86082 index 34e7cba..6f9a729 100644
86083 --- a/kernel/trace/trace_output.c
86084 +++ b/kernel/trace/trace_output.c
86085 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86086
86087 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86088 if (!IS_ERR(p)) {
86089 - p = mangle_path(s->buffer + s->len, p, "\n");
86090 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86091 if (p) {
86092 s->len = p - s->buffer;
86093 return 1;
86094 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86095 goto out;
86096 }
86097
86098 + pax_open_kernel();
86099 if (event->funcs->trace == NULL)
86100 - event->funcs->trace = trace_nop_print;
86101 + *(void **)&event->funcs->trace = trace_nop_print;
86102 if (event->funcs->raw == NULL)
86103 - event->funcs->raw = trace_nop_print;
86104 + *(void **)&event->funcs->raw = trace_nop_print;
86105 if (event->funcs->hex == NULL)
86106 - event->funcs->hex = trace_nop_print;
86107 + *(void **)&event->funcs->hex = trace_nop_print;
86108 if (event->funcs->binary == NULL)
86109 - event->funcs->binary = trace_nop_print;
86110 + *(void **)&event->funcs->binary = trace_nop_print;
86111 + pax_close_kernel();
86112
86113 key = event->type & (EVENT_HASHSIZE - 1);
86114
86115 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86116 index b20428c..4845a10 100644
86117 --- a/kernel/trace/trace_stack.c
86118 +++ b/kernel/trace/trace_stack.c
86119 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86120 return;
86121
86122 /* we do not handle interrupt stacks yet */
86123 - if (!object_is_on_stack(stack))
86124 + if (!object_starts_on_stack(stack))
86125 return;
86126
86127 local_irq_save(flags);
86128 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86129 index 13fb113..a6ced3f 100644
86130 --- a/kernel/user_namespace.c
86131 +++ b/kernel/user_namespace.c
86132 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86133 !kgid_has_mapping(parent_ns, group))
86134 return -EPERM;
86135
86136 +#ifdef CONFIG_GRKERNSEC
86137 + /*
86138 + * This doesn't really inspire confidence:
86139 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86140 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86141 + * Increases kernel attack surface in areas developers
86142 + * previously cared little about ("low importance due
86143 + * to requiring "root" capability")
86144 + * To be removed when this code receives *proper* review
86145 + */
86146 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86147 + !capable(CAP_SETGID))
86148 + return -EPERM;
86149 +#endif
86150 +
86151 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86152 if (!ns)
86153 return -ENOMEM;
86154 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86155 if (atomic_read(&current->mm->mm_users) > 1)
86156 return -EINVAL;
86157
86158 - if (current->fs->users != 1)
86159 + if (atomic_read(&current->fs->users) != 1)
86160 return -EINVAL;
86161
86162 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86163 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86164 index 4f69f9a..7c6f8f8 100644
86165 --- a/kernel/utsname_sysctl.c
86166 +++ b/kernel/utsname_sysctl.c
86167 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86168 static int proc_do_uts_string(ctl_table *table, int write,
86169 void __user *buffer, size_t *lenp, loff_t *ppos)
86170 {
86171 - struct ctl_table uts_table;
86172 + ctl_table_no_const uts_table;
86173 int r;
86174 memcpy(&uts_table, table, sizeof(uts_table));
86175 uts_table.data = get_uts(table, write);
86176 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86177 index 4431610..4265616 100644
86178 --- a/kernel/watchdog.c
86179 +++ b/kernel/watchdog.c
86180 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
86181 static void watchdog_nmi_disable(unsigned int cpu) { return; }
86182 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
86183
86184 -static struct smp_hotplug_thread watchdog_threads = {
86185 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86186 .store = &softlockup_watchdog,
86187 .thread_should_run = watchdog_should_run,
86188 .thread_fn = watchdog,
86189 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86190 index 987293d..60b3043 100644
86191 --- a/kernel/workqueue.c
86192 +++ b/kernel/workqueue.c
86193 @@ -4658,7 +4658,7 @@ static void rebind_workers(struct worker_pool *pool)
86194 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86195 worker_flags |= WORKER_REBOUND;
86196 worker_flags &= ~WORKER_UNBOUND;
86197 - ACCESS_ONCE(worker->flags) = worker_flags;
86198 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86199 }
86200
86201 spin_unlock_irq(&pool->lock);
86202 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86203 index 094f315..244a824 100644
86204 --- a/lib/Kconfig.debug
86205 +++ b/lib/Kconfig.debug
86206 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
86207
86208 config DEBUG_WW_MUTEX_SLOWPATH
86209 bool "Wait/wound mutex debugging: Slowpath testing"
86210 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86211 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86212 select DEBUG_LOCK_ALLOC
86213 select DEBUG_SPINLOCK
86214 select DEBUG_MUTEXES
86215 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
86216
86217 config DEBUG_LOCK_ALLOC
86218 bool "Lock debugging: detect incorrect freeing of live locks"
86219 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86220 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86221 select DEBUG_SPINLOCK
86222 select DEBUG_MUTEXES
86223 select LOCKDEP
86224 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
86225
86226 config PROVE_LOCKING
86227 bool "Lock debugging: prove locking correctness"
86228 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86229 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86230 select LOCKDEP
86231 select DEBUG_SPINLOCK
86232 select DEBUG_MUTEXES
86233 @@ -914,7 +914,7 @@ config LOCKDEP
86234
86235 config LOCK_STAT
86236 bool "Lock usage statistics"
86237 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86238 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86239 select LOCKDEP
86240 select DEBUG_SPINLOCK
86241 select DEBUG_MUTEXES
86242 @@ -1376,6 +1376,7 @@ config LATENCYTOP
86243 depends on DEBUG_KERNEL
86244 depends on STACKTRACE_SUPPORT
86245 depends on PROC_FS
86246 + depends on !GRKERNSEC_HIDESYM
86247 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
86248 select KALLSYMS
86249 select KALLSYMS_ALL
86250 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86251 config DEBUG_STRICT_USER_COPY_CHECKS
86252 bool "Strict user copy size checks"
86253 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86254 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
86255 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
86256 help
86257 Enabling this option turns a certain set of sanity checks for user
86258 copy operations into compile time failures.
86259 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
86260
86261 config PROVIDE_OHCI1394_DMA_INIT
86262 bool "Remote debugging over FireWire early on boot"
86263 - depends on PCI && X86
86264 + depends on PCI && X86 && !GRKERNSEC
86265 help
86266 If you want to debug problems which hang or crash the kernel early
86267 on boot and the crashing machine has a FireWire port, you can use
86268 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
86269
86270 config FIREWIRE_OHCI_REMOTE_DMA
86271 bool "Remote debugging over FireWire with firewire-ohci"
86272 - depends on FIREWIRE_OHCI
86273 + depends on FIREWIRE_OHCI && !GRKERNSEC
86274 help
86275 This option lets you use the FireWire bus for remote debugging
86276 with help of the firewire-ohci driver. It enables unfiltered
86277 diff --git a/lib/Makefile b/lib/Makefile
86278 index f3bb2cb..b358ace 100644
86279 --- a/lib/Makefile
86280 +++ b/lib/Makefile
86281 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
86282
86283 obj-$(CONFIG_BTREE) += btree.o
86284 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
86285 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
86286 +obj-y += list_debug.o
86287 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
86288
86289 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
86290 diff --git a/lib/bitmap.c b/lib/bitmap.c
86291 index 06f7e4f..f3cf2b0 100644
86292 --- a/lib/bitmap.c
86293 +++ b/lib/bitmap.c
86294 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
86295 {
86296 int c, old_c, totaldigits, ndigits, nchunks, nbits;
86297 u32 chunk;
86298 - const char __user __force *ubuf = (const char __user __force *)buf;
86299 + const char __user *ubuf = (const char __force_user *)buf;
86300
86301 bitmap_zero(maskp, nmaskbits);
86302
86303 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
86304 {
86305 if (!access_ok(VERIFY_READ, ubuf, ulen))
86306 return -EFAULT;
86307 - return __bitmap_parse((const char __force *)ubuf,
86308 + return __bitmap_parse((const char __force_kernel *)ubuf,
86309 ulen, 1, maskp, nmaskbits);
86310
86311 }
86312 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
86313 {
86314 unsigned a, b;
86315 int c, old_c, totaldigits;
86316 - const char __user __force *ubuf = (const char __user __force *)buf;
86317 + const char __user *ubuf = (const char __force_user *)buf;
86318 int exp_digit, in_range;
86319
86320 totaldigits = c = 0;
86321 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
86322 {
86323 if (!access_ok(VERIFY_READ, ubuf, ulen))
86324 return -EFAULT;
86325 - return __bitmap_parselist((const char __force *)ubuf,
86326 + return __bitmap_parselist((const char __force_kernel *)ubuf,
86327 ulen, 1, maskp, nmaskbits);
86328 }
86329 EXPORT_SYMBOL(bitmap_parselist_user);
86330 diff --git a/lib/bug.c b/lib/bug.c
86331 index 1686034..a9c00c8 100644
86332 --- a/lib/bug.c
86333 +++ b/lib/bug.c
86334 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
86335 return BUG_TRAP_TYPE_NONE;
86336
86337 bug = find_bug(bugaddr);
86338 + if (!bug)
86339 + return BUG_TRAP_TYPE_NONE;
86340
86341 file = NULL;
86342 line = 0;
86343 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
86344 index bf2c8b1..1d00ccf 100644
86345 --- a/lib/debugobjects.c
86346 +++ b/lib/debugobjects.c
86347 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
86348 if (limit > 4)
86349 return;
86350
86351 - is_on_stack = object_is_on_stack(addr);
86352 + is_on_stack = object_starts_on_stack(addr);
86353 if (is_on_stack == onstack)
86354 return;
86355
86356 diff --git a/lib/devres.c b/lib/devres.c
86357 index 8235331..5881053 100644
86358 --- a/lib/devres.c
86359 +++ b/lib/devres.c
86360 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
86361 void devm_iounmap(struct device *dev, void __iomem *addr)
86362 {
86363 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
86364 - (void *)addr));
86365 + (void __force *)addr));
86366 iounmap(addr);
86367 }
86368 EXPORT_SYMBOL(devm_iounmap);
86369 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
86370 {
86371 ioport_unmap(addr);
86372 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
86373 - devm_ioport_map_match, (void *)addr));
86374 + devm_ioport_map_match, (void __force *)addr));
86375 }
86376 EXPORT_SYMBOL(devm_ioport_unmap);
86377 #endif /* CONFIG_HAS_IOPORT */
86378 diff --git a/lib/div64.c b/lib/div64.c
86379 index 4382ad7..08aa558 100644
86380 --- a/lib/div64.c
86381 +++ b/lib/div64.c
86382 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
86383 EXPORT_SYMBOL(__div64_32);
86384
86385 #ifndef div_s64_rem
86386 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86387 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86388 {
86389 u64 quotient;
86390
86391 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
86392 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
86393 */
86394 #ifndef div64_u64
86395 -u64 div64_u64(u64 dividend, u64 divisor)
86396 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
86397 {
86398 u32 high = divisor >> 32;
86399 u64 quot;
86400 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
86401 index d87a17a..ac0d79a 100644
86402 --- a/lib/dma-debug.c
86403 +++ b/lib/dma-debug.c
86404 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
86405
86406 void dma_debug_add_bus(struct bus_type *bus)
86407 {
86408 - struct notifier_block *nb;
86409 + notifier_block_no_const *nb;
86410
86411 if (global_disable)
86412 return;
86413 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
86414
86415 static void check_for_stack(struct device *dev, void *addr)
86416 {
86417 - if (object_is_on_stack(addr))
86418 + if (object_starts_on_stack(addr))
86419 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
86420 "stack [addr=%p]\n", addr);
86421 }
86422 diff --git a/lib/inflate.c b/lib/inflate.c
86423 index 013a761..c28f3fc 100644
86424 --- a/lib/inflate.c
86425 +++ b/lib/inflate.c
86426 @@ -269,7 +269,7 @@ static void free(void *where)
86427 malloc_ptr = free_mem_ptr;
86428 }
86429 #else
86430 -#define malloc(a) kmalloc(a, GFP_KERNEL)
86431 +#define malloc(a) kmalloc((a), GFP_KERNEL)
86432 #define free(a) kfree(a)
86433 #endif
86434
86435 diff --git a/lib/ioremap.c b/lib/ioremap.c
86436 index 0c9216c..863bd89 100644
86437 --- a/lib/ioremap.c
86438 +++ b/lib/ioremap.c
86439 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
86440 unsigned long next;
86441
86442 phys_addr -= addr;
86443 - pmd = pmd_alloc(&init_mm, pud, addr);
86444 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86445 if (!pmd)
86446 return -ENOMEM;
86447 do {
86448 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
86449 unsigned long next;
86450
86451 phys_addr -= addr;
86452 - pud = pud_alloc(&init_mm, pgd, addr);
86453 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86454 if (!pud)
86455 return -ENOMEM;
86456 do {
86457 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
86458 index bd2bea9..6b3c95e 100644
86459 --- a/lib/is_single_threaded.c
86460 +++ b/lib/is_single_threaded.c
86461 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
86462 struct task_struct *p, *t;
86463 bool ret;
86464
86465 + if (!mm)
86466 + return true;
86467 +
86468 if (atomic_read(&task->signal->live) != 1)
86469 return false;
86470
86471 diff --git a/lib/kobject.c b/lib/kobject.c
86472 index 084f7b1..d265b8a 100644
86473 --- a/lib/kobject.c
86474 +++ b/lib/kobject.c
86475 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
86476
86477
86478 static DEFINE_SPINLOCK(kobj_ns_type_lock);
86479 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
86480 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
86481
86482 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86483 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86484 {
86485 enum kobj_ns_type type = ops->type;
86486 int error;
86487 diff --git a/lib/list_debug.c b/lib/list_debug.c
86488 index c24c2f7..f0296f4 100644
86489 --- a/lib/list_debug.c
86490 +++ b/lib/list_debug.c
86491 @@ -11,7 +11,9 @@
86492 #include <linux/bug.h>
86493 #include <linux/kernel.h>
86494 #include <linux/rculist.h>
86495 +#include <linux/mm.h>
86496
86497 +#ifdef CONFIG_DEBUG_LIST
86498 /*
86499 * Insert a new entry between two known consecutive entries.
86500 *
86501 @@ -19,21 +21,40 @@
86502 * the prev/next entries already!
86503 */
86504
86505 +static bool __list_add_debug(struct list_head *new,
86506 + struct list_head *prev,
86507 + struct list_head *next)
86508 +{
86509 + if (unlikely(next->prev != prev)) {
86510 + printk(KERN_ERR "list_add corruption. next->prev should be "
86511 + "prev (%p), but was %p. (next=%p).\n",
86512 + prev, next->prev, next);
86513 + BUG();
86514 + return false;
86515 + }
86516 + if (unlikely(prev->next != next)) {
86517 + printk(KERN_ERR "list_add corruption. prev->next should be "
86518 + "next (%p), but was %p. (prev=%p).\n",
86519 + next, prev->next, prev);
86520 + BUG();
86521 + return false;
86522 + }
86523 + if (unlikely(new == prev || new == next)) {
86524 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
86525 + new, prev, next);
86526 + BUG();
86527 + return false;
86528 + }
86529 + return true;
86530 +}
86531 +
86532 void __list_add(struct list_head *new,
86533 - struct list_head *prev,
86534 - struct list_head *next)
86535 + struct list_head *prev,
86536 + struct list_head *next)
86537 {
86538 - WARN(next->prev != prev,
86539 - "list_add corruption. next->prev should be "
86540 - "prev (%p), but was %p. (next=%p).\n",
86541 - prev, next->prev, next);
86542 - WARN(prev->next != next,
86543 - "list_add corruption. prev->next should be "
86544 - "next (%p), but was %p. (prev=%p).\n",
86545 - next, prev->next, prev);
86546 - WARN(new == prev || new == next,
86547 - "list_add double add: new=%p, prev=%p, next=%p.\n",
86548 - new, prev, next);
86549 + if (!__list_add_debug(new, prev, next))
86550 + return;
86551 +
86552 next->prev = new;
86553 new->next = next;
86554 new->prev = prev;
86555 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
86556 }
86557 EXPORT_SYMBOL(__list_add);
86558
86559 -void __list_del_entry(struct list_head *entry)
86560 +static bool __list_del_entry_debug(struct list_head *entry)
86561 {
86562 struct list_head *prev, *next;
86563
86564 prev = entry->prev;
86565 next = entry->next;
86566
86567 - if (WARN(next == LIST_POISON1,
86568 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86569 - entry, LIST_POISON1) ||
86570 - WARN(prev == LIST_POISON2,
86571 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86572 - entry, LIST_POISON2) ||
86573 - WARN(prev->next != entry,
86574 - "list_del corruption. prev->next should be %p, "
86575 - "but was %p\n", entry, prev->next) ||
86576 - WARN(next->prev != entry,
86577 - "list_del corruption. next->prev should be %p, "
86578 - "but was %p\n", entry, next->prev))
86579 + if (unlikely(next == LIST_POISON1)) {
86580 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86581 + entry, LIST_POISON1);
86582 + BUG();
86583 + return false;
86584 + }
86585 + if (unlikely(prev == LIST_POISON2)) {
86586 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86587 + entry, LIST_POISON2);
86588 + BUG();
86589 + return false;
86590 + }
86591 + if (unlikely(entry->prev->next != entry)) {
86592 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
86593 + "but was %p\n", entry, prev->next);
86594 + BUG();
86595 + return false;
86596 + }
86597 + if (unlikely(entry->next->prev != entry)) {
86598 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
86599 + "but was %p\n", entry, next->prev);
86600 + BUG();
86601 + return false;
86602 + }
86603 + return true;
86604 +}
86605 +
86606 +void __list_del_entry(struct list_head *entry)
86607 +{
86608 + if (!__list_del_entry_debug(entry))
86609 return;
86610
86611 - __list_del(prev, next);
86612 + __list_del(entry->prev, entry->next);
86613 }
86614 EXPORT_SYMBOL(__list_del_entry);
86615
86616 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
86617 void __list_add_rcu(struct list_head *new,
86618 struct list_head *prev, struct list_head *next)
86619 {
86620 - WARN(next->prev != prev,
86621 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
86622 - prev, next->prev, next);
86623 - WARN(prev->next != next,
86624 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
86625 - next, prev->next, prev);
86626 + if (!__list_add_debug(new, prev, next))
86627 + return;
86628 +
86629 new->next = next;
86630 new->prev = prev;
86631 rcu_assign_pointer(list_next_rcu(prev), new);
86632 next->prev = new;
86633 }
86634 EXPORT_SYMBOL(__list_add_rcu);
86635 +#endif
86636 +
86637 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
86638 +{
86639 +#ifdef CONFIG_DEBUG_LIST
86640 + if (!__list_add_debug(new, prev, next))
86641 + return;
86642 +#endif
86643 +
86644 + pax_open_kernel();
86645 + next->prev = new;
86646 + new->next = next;
86647 + new->prev = prev;
86648 + prev->next = new;
86649 + pax_close_kernel();
86650 +}
86651 +EXPORT_SYMBOL(__pax_list_add);
86652 +
86653 +void pax_list_del(struct list_head *entry)
86654 +{
86655 +#ifdef CONFIG_DEBUG_LIST
86656 + if (!__list_del_entry_debug(entry))
86657 + return;
86658 +#endif
86659 +
86660 + pax_open_kernel();
86661 + __list_del(entry->prev, entry->next);
86662 + entry->next = LIST_POISON1;
86663 + entry->prev = LIST_POISON2;
86664 + pax_close_kernel();
86665 +}
86666 +EXPORT_SYMBOL(pax_list_del);
86667 +
86668 +void pax_list_del_init(struct list_head *entry)
86669 +{
86670 + pax_open_kernel();
86671 + __list_del(entry->prev, entry->next);
86672 + INIT_LIST_HEAD(entry);
86673 + pax_close_kernel();
86674 +}
86675 +EXPORT_SYMBOL(pax_list_del_init);
86676 +
86677 +void __pax_list_add_rcu(struct list_head *new,
86678 + struct list_head *prev, struct list_head *next)
86679 +{
86680 +#ifdef CONFIG_DEBUG_LIST
86681 + if (!__list_add_debug(new, prev, next))
86682 + return;
86683 +#endif
86684 +
86685 + pax_open_kernel();
86686 + new->next = next;
86687 + new->prev = prev;
86688 + rcu_assign_pointer(list_next_rcu(prev), new);
86689 + next->prev = new;
86690 + pax_close_kernel();
86691 +}
86692 +EXPORT_SYMBOL(__pax_list_add_rcu);
86693 +
86694 +void pax_list_del_rcu(struct list_head *entry)
86695 +{
86696 +#ifdef CONFIG_DEBUG_LIST
86697 + if (!__list_del_entry_debug(entry))
86698 + return;
86699 +#endif
86700 +
86701 + pax_open_kernel();
86702 + __list_del(entry->prev, entry->next);
86703 + entry->next = LIST_POISON1;
86704 + entry->prev = LIST_POISON2;
86705 + pax_close_kernel();
86706 +}
86707 +EXPORT_SYMBOL(pax_list_del_rcu);
86708 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
86709 index 1a53d49..ace934c 100644
86710 --- a/lib/percpu-refcount.c
86711 +++ b/lib/percpu-refcount.c
86712 @@ -29,7 +29,7 @@
86713 * can't hit 0 before we've added up all the percpu refs.
86714 */
86715
86716 -#define PCPU_COUNT_BIAS (1U << 31)
86717 +#define PCPU_COUNT_BIAS (1U << 30)
86718
86719 /**
86720 * percpu_ref_init - initialize a percpu refcount
86721 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
86722 index 7811ed3..f80ca19 100644
86723 --- a/lib/radix-tree.c
86724 +++ b/lib/radix-tree.c
86725 @@ -93,7 +93,7 @@ struct radix_tree_preload {
86726 int nr;
86727 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
86728 };
86729 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
86730 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
86731
86732 static inline void *ptr_to_indirect(void *ptr)
86733 {
86734 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
86735 index bb2b201..46abaf9 100644
86736 --- a/lib/strncpy_from_user.c
86737 +++ b/lib/strncpy_from_user.c
86738 @@ -21,7 +21,7 @@
86739 */
86740 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
86741 {
86742 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86743 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86744 long res = 0;
86745
86746 /*
86747 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
86748 index a28df52..3d55877 100644
86749 --- a/lib/strnlen_user.c
86750 +++ b/lib/strnlen_user.c
86751 @@ -26,7 +26,7 @@
86752 */
86753 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
86754 {
86755 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86756 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86757 long align, res = 0;
86758 unsigned long c;
86759
86760 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
86761 index 4e8686c..3e8c92f 100644
86762 --- a/lib/swiotlb.c
86763 +++ b/lib/swiotlb.c
86764 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
86765
86766 void
86767 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
86768 - dma_addr_t dev_addr)
86769 + dma_addr_t dev_addr, struct dma_attrs *attrs)
86770 {
86771 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
86772
86773 diff --git a/lib/usercopy.c b/lib/usercopy.c
86774 index 4f5b1dd..7cab418 100644
86775 --- a/lib/usercopy.c
86776 +++ b/lib/usercopy.c
86777 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
86778 WARN(1, "Buffer overflow detected!\n");
86779 }
86780 EXPORT_SYMBOL(copy_from_user_overflow);
86781 +
86782 +void copy_to_user_overflow(void)
86783 +{
86784 + WARN(1, "Buffer overflow detected!\n");
86785 +}
86786 +EXPORT_SYMBOL(copy_to_user_overflow);
86787 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
86788 index 26559bd..ed614df 100644
86789 --- a/lib/vsprintf.c
86790 +++ b/lib/vsprintf.c
86791 @@ -16,6 +16,9 @@
86792 * - scnprintf and vscnprintf
86793 */
86794
86795 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86796 +#define __INCLUDED_BY_HIDESYM 1
86797 +#endif
86798 #include <stdarg.h>
86799 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
86800 #include <linux/types.h>
86801 @@ -1154,7 +1157,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
86802 return number(buf, end, *(const netdev_features_t *)addr, spec);
86803 }
86804
86805 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86806 +int kptr_restrict __read_mostly = 2;
86807 +#else
86808 int kptr_restrict __read_mostly;
86809 +#endif
86810
86811 /*
86812 * Show a '%p' thing. A kernel extension is that the '%p' is followed
86813 @@ -1167,6 +1174,7 @@ int kptr_restrict __read_mostly;
86814 * - 'f' For simple symbolic function names without offset
86815 * - 'S' For symbolic direct pointers with offset
86816 * - 's' For symbolic direct pointers without offset
86817 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
86818 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
86819 * - 'B' For backtraced symbolic direct pointers with offset
86820 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
86821 @@ -1231,12 +1239,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86822
86823 if (!ptr && *fmt != 'K') {
86824 /*
86825 - * Print (null) with the same width as a pointer so it makes
86826 + * Print (nil) with the same width as a pointer so it makes
86827 * tabular output look nice.
86828 */
86829 if (spec.field_width == -1)
86830 spec.field_width = default_width;
86831 - return string(buf, end, "(null)", spec);
86832 + return string(buf, end, "(nil)", spec);
86833 }
86834
86835 switch (*fmt) {
86836 @@ -1246,6 +1254,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86837 /* Fallthrough */
86838 case 'S':
86839 case 's':
86840 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86841 + break;
86842 +#else
86843 + return symbol_string(buf, end, ptr, spec, fmt);
86844 +#endif
86845 + case 'A':
86846 case 'B':
86847 return symbol_string(buf, end, ptr, spec, fmt);
86848 case 'R':
86849 @@ -1301,6 +1315,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86850 va_end(va);
86851 return buf;
86852 }
86853 + case 'P':
86854 + break;
86855 case 'K':
86856 /*
86857 * %pK cannot be used in IRQ context because its test
86858 @@ -1336,6 +1352,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86859 ((const struct file *)ptr)->f_path.dentry,
86860 spec, fmt);
86861 }
86862 +
86863 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86864 + /* 'P' = approved pointers to copy to userland,
86865 + as in the /proc/kallsyms case, as we make it display nothing
86866 + for non-root users, and the real contents for root users
86867 + Also ignore 'K' pointers, since we force their NULLing for non-root users
86868 + above
86869 + */
86870 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
86871 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
86872 + dump_stack();
86873 + ptr = NULL;
86874 + }
86875 +#endif
86876 +
86877 spec.flags |= SMALL;
86878 if (spec.field_width == -1) {
86879 spec.field_width = default_width;
86880 @@ -2059,11 +2090,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86881 typeof(type) value; \
86882 if (sizeof(type) == 8) { \
86883 args = PTR_ALIGN(args, sizeof(u32)); \
86884 - *(u32 *)&value = *(u32 *)args; \
86885 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
86886 + *(u32 *)&value = *(const u32 *)args; \
86887 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
86888 } else { \
86889 args = PTR_ALIGN(args, sizeof(type)); \
86890 - value = *(typeof(type) *)args; \
86891 + value = *(const typeof(type) *)args; \
86892 } \
86893 args += sizeof(type); \
86894 value; \
86895 @@ -2126,7 +2157,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86896 case FORMAT_TYPE_STR: {
86897 const char *str_arg = args;
86898 args += strlen(str_arg) + 1;
86899 - str = string(str, end, (char *)str_arg, spec);
86900 + str = string(str, end, str_arg, spec);
86901 break;
86902 }
86903
86904 diff --git a/localversion-grsec b/localversion-grsec
86905 new file mode 100644
86906 index 0000000..7cd6065
86907 --- /dev/null
86908 +++ b/localversion-grsec
86909 @@ -0,0 +1 @@
86910 +-grsec
86911 diff --git a/mm/Kconfig b/mm/Kconfig
86912 index 394838f..0e5f816 100644
86913 --- a/mm/Kconfig
86914 +++ b/mm/Kconfig
86915 @@ -317,10 +317,11 @@ config KSM
86916 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
86917
86918 config DEFAULT_MMAP_MIN_ADDR
86919 - int "Low address space to protect from user allocation"
86920 + int "Low address space to protect from user allocation"
86921 depends on MMU
86922 - default 4096
86923 - help
86924 + default 32768 if ALPHA || ARM || PARISC || SPARC32
86925 + default 65536
86926 + help
86927 This is the portion of low virtual memory which should be protected
86928 from userspace allocation. Keeping a user from writing to low pages
86929 can help reduce the impact of kernel NULL pointer bugs.
86930 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
86931
86932 config HWPOISON_INJECT
86933 tristate "HWPoison pages injector"
86934 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
86935 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
86936 select PROC_PAGE_MONITOR
86937
86938 config NOMMU_INITIAL_TRIM_EXCESS
86939 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
86940 index ce682f7..1fb54f9 100644
86941 --- a/mm/backing-dev.c
86942 +++ b/mm/backing-dev.c
86943 @@ -12,7 +12,7 @@
86944 #include <linux/device.h>
86945 #include <trace/events/writeback.h>
86946
86947 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
86948 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
86949
86950 struct backing_dev_info default_backing_dev_info = {
86951 .name = "default",
86952 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
86953 return err;
86954
86955 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
86956 - atomic_long_inc_return(&bdi_seq));
86957 + atomic_long_inc_return_unchecked(&bdi_seq));
86958 if (err) {
86959 bdi_destroy(bdi);
86960 return err;
86961 diff --git a/mm/filemap.c b/mm/filemap.c
86962 index ae4846f..b0acebe 100644
86963 --- a/mm/filemap.c
86964 +++ b/mm/filemap.c
86965 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
86966 struct address_space *mapping = file->f_mapping;
86967
86968 if (!mapping->a_ops->readpage)
86969 - return -ENOEXEC;
86970 + return -ENODEV;
86971 file_accessed(file);
86972 vma->vm_ops = &generic_file_vm_ops;
86973 return 0;
86974 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
86975
86976 while (bytes) {
86977 char __user *buf = iov->iov_base + base;
86978 - int copy = min(bytes, iov->iov_len - base);
86979 + size_t copy = min(bytes, iov->iov_len - base);
86980
86981 base = 0;
86982 left = __copy_from_user_inatomic(vaddr, buf, copy);
86983 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
86984 BUG_ON(!in_atomic());
86985 kaddr = kmap_atomic(page);
86986 if (likely(i->nr_segs == 1)) {
86987 - int left;
86988 + size_t left;
86989 char __user *buf = i->iov->iov_base + i->iov_offset;
86990 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
86991 copied = bytes - left;
86992 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
86993
86994 kaddr = kmap(page);
86995 if (likely(i->nr_segs == 1)) {
86996 - int left;
86997 + size_t left;
86998 char __user *buf = i->iov->iov_base + i->iov_offset;
86999 left = __copy_from_user(kaddr + offset, buf, bytes);
87000 copied = bytes - left;
87001 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87002 * zero-length segments (without overruning the iovec).
87003 */
87004 while (bytes || unlikely(i->count && !iov->iov_len)) {
87005 - int copy;
87006 + size_t copy;
87007
87008 copy = min(bytes, iov->iov_len - base);
87009 BUG_ON(!i->count || i->count < copy);
87010 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87011 *pos = i_size_read(inode);
87012
87013 if (limit != RLIM_INFINITY) {
87014 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87015 if (*pos >= limit) {
87016 send_sig(SIGXFSZ, current, 0);
87017 return -EFBIG;
87018 diff --git a/mm/fremap.c b/mm/fremap.c
87019 index 5bff081..d8189a9 100644
87020 --- a/mm/fremap.c
87021 +++ b/mm/fremap.c
87022 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87023 retry:
87024 vma = find_vma(mm, start);
87025
87026 +#ifdef CONFIG_PAX_SEGMEXEC
87027 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87028 + goto out;
87029 +#endif
87030 +
87031 /*
87032 * Make sure the vma is shared, that it supports prefaulting,
87033 * and that the remapped range is valid and fully within
87034 diff --git a/mm/highmem.c b/mm/highmem.c
87035 index b32b70c..e512eb0 100644
87036 --- a/mm/highmem.c
87037 +++ b/mm/highmem.c
87038 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87039 * So no dangers, even with speculative execution.
87040 */
87041 page = pte_page(pkmap_page_table[i]);
87042 + pax_open_kernel();
87043 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87044 -
87045 + pax_close_kernel();
87046 set_page_address(page, NULL);
87047 need_flush = 1;
87048 }
87049 @@ -198,9 +199,11 @@ start:
87050 }
87051 }
87052 vaddr = PKMAP_ADDR(last_pkmap_nr);
87053 +
87054 + pax_open_kernel();
87055 set_pte_at(&init_mm, vaddr,
87056 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87057 -
87058 + pax_close_kernel();
87059 pkmap_count[last_pkmap_nr] = 1;
87060 set_page_address(page, (void *)vaddr);
87061
87062 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87063 index 0b7656e..d21cefc 100644
87064 --- a/mm/hugetlb.c
87065 +++ b/mm/hugetlb.c
87066 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87067 struct hstate *h = &default_hstate;
87068 unsigned long tmp;
87069 int ret;
87070 + ctl_table_no_const hugetlb_table;
87071
87072 tmp = h->max_huge_pages;
87073
87074 if (write && h->order >= MAX_ORDER)
87075 return -EINVAL;
87076
87077 - table->data = &tmp;
87078 - table->maxlen = sizeof(unsigned long);
87079 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87080 + hugetlb_table = *table;
87081 + hugetlb_table.data = &tmp;
87082 + hugetlb_table.maxlen = sizeof(unsigned long);
87083 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87084 if (ret)
87085 goto out;
87086
87087 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87088 struct hstate *h = &default_hstate;
87089 unsigned long tmp;
87090 int ret;
87091 + ctl_table_no_const hugetlb_table;
87092
87093 tmp = h->nr_overcommit_huge_pages;
87094
87095 if (write && h->order >= MAX_ORDER)
87096 return -EINVAL;
87097
87098 - table->data = &tmp;
87099 - table->maxlen = sizeof(unsigned long);
87100 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87101 + hugetlb_table = *table;
87102 + hugetlb_table.data = &tmp;
87103 + hugetlb_table.maxlen = sizeof(unsigned long);
87104 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87105 if (ret)
87106 goto out;
87107
87108 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87109 return 1;
87110 }
87111
87112 +#ifdef CONFIG_PAX_SEGMEXEC
87113 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87114 +{
87115 + struct mm_struct *mm = vma->vm_mm;
87116 + struct vm_area_struct *vma_m;
87117 + unsigned long address_m;
87118 + pte_t *ptep_m;
87119 +
87120 + vma_m = pax_find_mirror_vma(vma);
87121 + if (!vma_m)
87122 + return;
87123 +
87124 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87125 + address_m = address + SEGMEXEC_TASK_SIZE;
87126 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87127 + get_page(page_m);
87128 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87129 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87130 +}
87131 +#endif
87132 +
87133 /*
87134 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87135 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87136 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
87137 make_huge_pte(vma, new_page, 1));
87138 page_remove_rmap(old_page);
87139 hugepage_add_new_anon_rmap(new_page, vma, address);
87140 +
87141 +#ifdef CONFIG_PAX_SEGMEXEC
87142 + pax_mirror_huge_pte(vma, address, new_page);
87143 +#endif
87144 +
87145 /* Make the old page be freed below */
87146 new_page = old_page;
87147 }
87148 @@ -2883,6 +2913,10 @@ retry:
87149 && (vma->vm_flags & VM_SHARED)));
87150 set_huge_pte_at(mm, address, ptep, new_pte);
87151
87152 +#ifdef CONFIG_PAX_SEGMEXEC
87153 + pax_mirror_huge_pte(vma, address, page);
87154 +#endif
87155 +
87156 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87157 /* Optimization, do the COW without a second fault */
87158 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87159 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87160 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87161 struct hstate *h = hstate_vma(vma);
87162
87163 +#ifdef CONFIG_PAX_SEGMEXEC
87164 + struct vm_area_struct *vma_m;
87165 +#endif
87166 +
87167 address &= huge_page_mask(h);
87168
87169 ptep = huge_pte_offset(mm, address);
87170 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87171 VM_FAULT_SET_HINDEX(hstate_index(h));
87172 }
87173
87174 +#ifdef CONFIG_PAX_SEGMEXEC
87175 + vma_m = pax_find_mirror_vma(vma);
87176 + if (vma_m) {
87177 + unsigned long address_m;
87178 +
87179 + if (vma->vm_start > vma_m->vm_start) {
87180 + address_m = address;
87181 + address -= SEGMEXEC_TASK_SIZE;
87182 + vma = vma_m;
87183 + h = hstate_vma(vma);
87184 + } else
87185 + address_m = address + SEGMEXEC_TASK_SIZE;
87186 +
87187 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
87188 + return VM_FAULT_OOM;
87189 + address_m &= HPAGE_MASK;
87190 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
87191 + }
87192 +#endif
87193 +
87194 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
87195 if (!ptep)
87196 return VM_FAULT_OOM;
87197 diff --git a/mm/internal.h b/mm/internal.h
87198 index 684f7aa..9eb9edc 100644
87199 --- a/mm/internal.h
87200 +++ b/mm/internal.h
87201 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
87202 * in mm/page_alloc.c
87203 */
87204 extern void __free_pages_bootmem(struct page *page, unsigned int order);
87205 +extern void free_compound_page(struct page *page);
87206 extern void prep_compound_page(struct page *page, unsigned long order);
87207 #ifdef CONFIG_MEMORY_FAILURE
87208 extern bool is_free_buddy_page(struct page *page);
87209 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
87210
87211 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
87212 unsigned long, unsigned long,
87213 - unsigned long, unsigned long);
87214 + unsigned long, unsigned long) __intentional_overflow(-1);
87215
87216 extern void set_pageblock_order(void);
87217 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
87218 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
87219 index e126b0e..e986018 100644
87220 --- a/mm/kmemleak.c
87221 +++ b/mm/kmemleak.c
87222 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
87223
87224 for (i = 0; i < object->trace_len; i++) {
87225 void *ptr = (void *)object->trace[i];
87226 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
87227 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
87228 }
87229 }
87230
87231 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
87232 return -ENOMEM;
87233 }
87234
87235 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
87236 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
87237 &kmemleak_fops);
87238 if (!dentry)
87239 pr_warning("Failed to create the debugfs kmemleak file\n");
87240 diff --git a/mm/maccess.c b/mm/maccess.c
87241 index d53adf9..03a24bf 100644
87242 --- a/mm/maccess.c
87243 +++ b/mm/maccess.c
87244 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
87245 set_fs(KERNEL_DS);
87246 pagefault_disable();
87247 ret = __copy_from_user_inatomic(dst,
87248 - (__force const void __user *)src, size);
87249 + (const void __force_user *)src, size);
87250 pagefault_enable();
87251 set_fs(old_fs);
87252
87253 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
87254
87255 set_fs(KERNEL_DS);
87256 pagefault_disable();
87257 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
87258 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
87259 pagefault_enable();
87260 set_fs(old_fs);
87261
87262 diff --git a/mm/madvise.c b/mm/madvise.c
87263 index 539eeb9..e24a987 100644
87264 --- a/mm/madvise.c
87265 +++ b/mm/madvise.c
87266 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
87267 pgoff_t pgoff;
87268 unsigned long new_flags = vma->vm_flags;
87269
87270 +#ifdef CONFIG_PAX_SEGMEXEC
87271 + struct vm_area_struct *vma_m;
87272 +#endif
87273 +
87274 switch (behavior) {
87275 case MADV_NORMAL:
87276 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
87277 @@ -126,6 +130,13 @@ success:
87278 /*
87279 * vm_flags is protected by the mmap_sem held in write mode.
87280 */
87281 +
87282 +#ifdef CONFIG_PAX_SEGMEXEC
87283 + vma_m = pax_find_mirror_vma(vma);
87284 + if (vma_m)
87285 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
87286 +#endif
87287 +
87288 vma->vm_flags = new_flags;
87289
87290 out:
87291 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87292 struct vm_area_struct **prev,
87293 unsigned long start, unsigned long end)
87294 {
87295 +
87296 +#ifdef CONFIG_PAX_SEGMEXEC
87297 + struct vm_area_struct *vma_m;
87298 +#endif
87299 +
87300 *prev = vma;
87301 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
87302 return -EINVAL;
87303 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87304 zap_page_range(vma, start, end - start, &details);
87305 } else
87306 zap_page_range(vma, start, end - start, NULL);
87307 +
87308 +#ifdef CONFIG_PAX_SEGMEXEC
87309 + vma_m = pax_find_mirror_vma(vma);
87310 + if (vma_m) {
87311 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
87312 + struct zap_details details = {
87313 + .nonlinear_vma = vma_m,
87314 + .last_index = ULONG_MAX,
87315 + };
87316 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
87317 + } else
87318 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
87319 + }
87320 +#endif
87321 +
87322 return 0;
87323 }
87324
87325 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
87326 if (end < start)
87327 return error;
87328
87329 +#ifdef CONFIG_PAX_SEGMEXEC
87330 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87331 + if (end > SEGMEXEC_TASK_SIZE)
87332 + return error;
87333 + } else
87334 +#endif
87335 +
87336 + if (end > TASK_SIZE)
87337 + return error;
87338 +
87339 error = 0;
87340 if (end == start)
87341 return error;
87342 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
87343 index bf3351b..aea800d 100644
87344 --- a/mm/memory-failure.c
87345 +++ b/mm/memory-failure.c
87346 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
87347
87348 int sysctl_memory_failure_recovery __read_mostly = 1;
87349
87350 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87351 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87352
87353 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
87354
87355 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
87356 pfn, t->comm, t->pid);
87357 si.si_signo = SIGBUS;
87358 si.si_errno = 0;
87359 - si.si_addr = (void *)addr;
87360 + si.si_addr = (void __user *)addr;
87361 #ifdef __ARCH_SI_TRAPNO
87362 si.si_trapno = trapno;
87363 #endif
87364 @@ -762,7 +762,7 @@ static struct page_state {
87365 unsigned long res;
87366 char *msg;
87367 int (*action)(struct page *p, unsigned long pfn);
87368 -} error_states[] = {
87369 +} __do_const error_states[] = {
87370 { reserved, reserved, "reserved kernel", me_kernel },
87371 /*
87372 * free pages are specially detected outside this table:
87373 @@ -1053,7 +1053,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87374 nr_pages = 1 << compound_order(hpage);
87375 else /* normal page or thp */
87376 nr_pages = 1;
87377 - atomic_long_add(nr_pages, &num_poisoned_pages);
87378 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
87379
87380 /*
87381 * We need/can do nothing about count=0 pages.
87382 @@ -1083,7 +1083,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87383 if (!PageHWPoison(hpage)
87384 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
87385 || (p != hpage && TestSetPageHWPoison(hpage))) {
87386 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87387 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87388 return 0;
87389 }
87390 set_page_hwpoison_huge_page(hpage);
87391 @@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87392 }
87393 if (hwpoison_filter(p)) {
87394 if (TestClearPageHWPoison(p))
87395 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87396 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87397 unlock_page(hpage);
87398 put_page(hpage);
87399 return 0;
87400 @@ -1370,7 +1370,7 @@ int unpoison_memory(unsigned long pfn)
87401 return 0;
87402 }
87403 if (TestClearPageHWPoison(p))
87404 - atomic_long_dec(&num_poisoned_pages);
87405 + atomic_long_dec_unchecked(&num_poisoned_pages);
87406 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
87407 return 0;
87408 }
87409 @@ -1384,7 +1384,7 @@ int unpoison_memory(unsigned long pfn)
87410 */
87411 if (TestClearPageHWPoison(page)) {
87412 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
87413 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87414 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87415 freeit = 1;
87416 if (PageHuge(page))
87417 clear_page_hwpoison_huge_page(page);
87418 @@ -1521,7 +1521,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
87419 } else {
87420 set_page_hwpoison_huge_page(hpage);
87421 dequeue_hwpoisoned_huge_page(hpage);
87422 - atomic_long_add(1 << compound_order(hpage),
87423 + atomic_long_add_unchecked(1 << compound_order(hpage),
87424 &num_poisoned_pages);
87425 }
87426 return ret;
87427 @@ -1560,7 +1560,7 @@ static int __soft_offline_page(struct page *page, int flags)
87428 put_page(page);
87429 pr_info("soft_offline: %#lx: invalidated\n", pfn);
87430 SetPageHWPoison(page);
87431 - atomic_long_inc(&num_poisoned_pages);
87432 + atomic_long_inc_unchecked(&num_poisoned_pages);
87433 return 0;
87434 }
87435
87436 @@ -1605,7 +1605,7 @@ static int __soft_offline_page(struct page *page, int flags)
87437 if (!is_free_buddy_page(page))
87438 pr_info("soft offline: %#lx: page leaked\n",
87439 pfn);
87440 - atomic_long_inc(&num_poisoned_pages);
87441 + atomic_long_inc_unchecked(&num_poisoned_pages);
87442 }
87443 } else {
87444 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
87445 @@ -1666,11 +1666,11 @@ int soft_offline_page(struct page *page, int flags)
87446 if (PageHuge(page)) {
87447 set_page_hwpoison_huge_page(hpage);
87448 dequeue_hwpoisoned_huge_page(hpage);
87449 - atomic_long_add(1 << compound_order(hpage),
87450 + atomic_long_add_unchecked(1 << compound_order(hpage),
87451 &num_poisoned_pages);
87452 } else {
87453 SetPageHWPoison(page);
87454 - atomic_long_inc(&num_poisoned_pages);
87455 + atomic_long_inc_unchecked(&num_poisoned_pages);
87456 }
87457 }
87458 unset:
87459 diff --git a/mm/memory.c b/mm/memory.c
87460 index d176154..cd1b387 100644
87461 --- a/mm/memory.c
87462 +++ b/mm/memory.c
87463 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87464 free_pte_range(tlb, pmd, addr);
87465 } while (pmd++, addr = next, addr != end);
87466
87467 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
87468 start &= PUD_MASK;
87469 if (start < floor)
87470 return;
87471 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87472 pmd = pmd_offset(pud, start);
87473 pud_clear(pud);
87474 pmd_free_tlb(tlb, pmd, start);
87475 +#endif
87476 +
87477 }
87478
87479 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87480 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87481 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
87482 } while (pud++, addr = next, addr != end);
87483
87484 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
87485 start &= PGDIR_MASK;
87486 if (start < floor)
87487 return;
87488 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87489 pud = pud_offset(pgd, start);
87490 pgd_clear(pgd);
87491 pud_free_tlb(tlb, pud, start);
87492 +#endif
87493 +
87494 }
87495
87496 /*
87497 @@ -1636,12 +1642,6 @@ no_page_table:
87498 return page;
87499 }
87500
87501 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
87502 -{
87503 - return stack_guard_page_start(vma, addr) ||
87504 - stack_guard_page_end(vma, addr+PAGE_SIZE);
87505 -}
87506 -
87507 /**
87508 * __get_user_pages() - pin user pages in memory
87509 * @tsk: task_struct of target task
87510 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87511
87512 i = 0;
87513
87514 - do {
87515 + while (nr_pages) {
87516 struct vm_area_struct *vma;
87517
87518 - vma = find_extend_vma(mm, start);
87519 + vma = find_vma(mm, start);
87520 if (!vma && in_gate_area(mm, start)) {
87521 unsigned long pg = start & PAGE_MASK;
87522 pgd_t *pgd;
87523 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87524 goto next_page;
87525 }
87526
87527 - if (!vma ||
87528 + if (!vma || start < vma->vm_start ||
87529 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
87530 !(vm_flags & vma->vm_flags))
87531 return i ? : -EFAULT;
87532 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87533 int ret;
87534 unsigned int fault_flags = 0;
87535
87536 - /* For mlock, just skip the stack guard page. */
87537 - if (foll_flags & FOLL_MLOCK) {
87538 - if (stack_guard_page(vma, start))
87539 - goto next_page;
87540 - }
87541 if (foll_flags & FOLL_WRITE)
87542 fault_flags |= FAULT_FLAG_WRITE;
87543 if (nonblocking)
87544 @@ -1893,7 +1888,7 @@ next_page:
87545 start += page_increm * PAGE_SIZE;
87546 nr_pages -= page_increm;
87547 } while (nr_pages && start < vma->vm_end);
87548 - } while (nr_pages);
87549 + }
87550 return i;
87551 }
87552 EXPORT_SYMBOL(__get_user_pages);
87553 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
87554 page_add_file_rmap(page);
87555 set_pte_at(mm, addr, pte, mk_pte(page, prot));
87556
87557 +#ifdef CONFIG_PAX_SEGMEXEC
87558 + pax_mirror_file_pte(vma, addr, page, ptl);
87559 +#endif
87560 +
87561 retval = 0;
87562 pte_unmap_unlock(pte, ptl);
87563 return retval;
87564 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
87565 if (!page_count(page))
87566 return -EINVAL;
87567 if (!(vma->vm_flags & VM_MIXEDMAP)) {
87568 +
87569 +#ifdef CONFIG_PAX_SEGMEXEC
87570 + struct vm_area_struct *vma_m;
87571 +#endif
87572 +
87573 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
87574 BUG_ON(vma->vm_flags & VM_PFNMAP);
87575 vma->vm_flags |= VM_MIXEDMAP;
87576 +
87577 +#ifdef CONFIG_PAX_SEGMEXEC
87578 + vma_m = pax_find_mirror_vma(vma);
87579 + if (vma_m)
87580 + vma_m->vm_flags |= VM_MIXEDMAP;
87581 +#endif
87582 +
87583 }
87584 return insert_page(vma, addr, page, vma->vm_page_prot);
87585 }
87586 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87587 unsigned long pfn)
87588 {
87589 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87590 + BUG_ON(vma->vm_mirror);
87591
87592 if (addr < vma->vm_start || addr >= vma->vm_end)
87593 return -EFAULT;
87594 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87595
87596 BUG_ON(pud_huge(*pud));
87597
87598 - pmd = pmd_alloc(mm, pud, addr);
87599 + pmd = (mm == &init_mm) ?
87600 + pmd_alloc_kernel(mm, pud, addr) :
87601 + pmd_alloc(mm, pud, addr);
87602 if (!pmd)
87603 return -ENOMEM;
87604 do {
87605 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87606 unsigned long next;
87607 int err;
87608
87609 - pud = pud_alloc(mm, pgd, addr);
87610 + pud = (mm == &init_mm) ?
87611 + pud_alloc_kernel(mm, pgd, addr) :
87612 + pud_alloc(mm, pgd, addr);
87613 if (!pud)
87614 return -ENOMEM;
87615 do {
87616 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
87617 copy_user_highpage(dst, src, va, vma);
87618 }
87619
87620 +#ifdef CONFIG_PAX_SEGMEXEC
87621 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
87622 +{
87623 + struct mm_struct *mm = vma->vm_mm;
87624 + spinlock_t *ptl;
87625 + pte_t *pte, entry;
87626 +
87627 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
87628 + entry = *pte;
87629 + if (!pte_present(entry)) {
87630 + if (!pte_none(entry)) {
87631 + BUG_ON(pte_file(entry));
87632 + free_swap_and_cache(pte_to_swp_entry(entry));
87633 + pte_clear_not_present_full(mm, address, pte, 0);
87634 + }
87635 + } else {
87636 + struct page *page;
87637 +
87638 + flush_cache_page(vma, address, pte_pfn(entry));
87639 + entry = ptep_clear_flush(vma, address, pte);
87640 + BUG_ON(pte_dirty(entry));
87641 + page = vm_normal_page(vma, address, entry);
87642 + if (page) {
87643 + update_hiwater_rss(mm);
87644 + if (PageAnon(page))
87645 + dec_mm_counter_fast(mm, MM_ANONPAGES);
87646 + else
87647 + dec_mm_counter_fast(mm, MM_FILEPAGES);
87648 + page_remove_rmap(page);
87649 + page_cache_release(page);
87650 + }
87651 + }
87652 + pte_unmap_unlock(pte, ptl);
87653 +}
87654 +
87655 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
87656 + *
87657 + * the ptl of the lower mapped page is held on entry and is not released on exit
87658 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
87659 + */
87660 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87661 +{
87662 + struct mm_struct *mm = vma->vm_mm;
87663 + unsigned long address_m;
87664 + spinlock_t *ptl_m;
87665 + struct vm_area_struct *vma_m;
87666 + pmd_t *pmd_m;
87667 + pte_t *pte_m, entry_m;
87668 +
87669 + BUG_ON(!page_m || !PageAnon(page_m));
87670 +
87671 + vma_m = pax_find_mirror_vma(vma);
87672 + if (!vma_m)
87673 + return;
87674 +
87675 + BUG_ON(!PageLocked(page_m));
87676 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87677 + address_m = address + SEGMEXEC_TASK_SIZE;
87678 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87679 + pte_m = pte_offset_map(pmd_m, address_m);
87680 + ptl_m = pte_lockptr(mm, pmd_m);
87681 + if (ptl != ptl_m) {
87682 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87683 + if (!pte_none(*pte_m))
87684 + goto out;
87685 + }
87686 +
87687 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87688 + page_cache_get(page_m);
87689 + page_add_anon_rmap(page_m, vma_m, address_m);
87690 + inc_mm_counter_fast(mm, MM_ANONPAGES);
87691 + set_pte_at(mm, address_m, pte_m, entry_m);
87692 + update_mmu_cache(vma_m, address_m, pte_m);
87693 +out:
87694 + if (ptl != ptl_m)
87695 + spin_unlock(ptl_m);
87696 + pte_unmap(pte_m);
87697 + unlock_page(page_m);
87698 +}
87699 +
87700 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87701 +{
87702 + struct mm_struct *mm = vma->vm_mm;
87703 + unsigned long address_m;
87704 + spinlock_t *ptl_m;
87705 + struct vm_area_struct *vma_m;
87706 + pmd_t *pmd_m;
87707 + pte_t *pte_m, entry_m;
87708 +
87709 + BUG_ON(!page_m || PageAnon(page_m));
87710 +
87711 + vma_m = pax_find_mirror_vma(vma);
87712 + if (!vma_m)
87713 + return;
87714 +
87715 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87716 + address_m = address + SEGMEXEC_TASK_SIZE;
87717 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87718 + pte_m = pte_offset_map(pmd_m, address_m);
87719 + ptl_m = pte_lockptr(mm, pmd_m);
87720 + if (ptl != ptl_m) {
87721 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87722 + if (!pte_none(*pte_m))
87723 + goto out;
87724 + }
87725 +
87726 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87727 + page_cache_get(page_m);
87728 + page_add_file_rmap(page_m);
87729 + inc_mm_counter_fast(mm, MM_FILEPAGES);
87730 + set_pte_at(mm, address_m, pte_m, entry_m);
87731 + update_mmu_cache(vma_m, address_m, pte_m);
87732 +out:
87733 + if (ptl != ptl_m)
87734 + spin_unlock(ptl_m);
87735 + pte_unmap(pte_m);
87736 +}
87737 +
87738 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
87739 +{
87740 + struct mm_struct *mm = vma->vm_mm;
87741 + unsigned long address_m;
87742 + spinlock_t *ptl_m;
87743 + struct vm_area_struct *vma_m;
87744 + pmd_t *pmd_m;
87745 + pte_t *pte_m, entry_m;
87746 +
87747 + vma_m = pax_find_mirror_vma(vma);
87748 + if (!vma_m)
87749 + return;
87750 +
87751 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87752 + address_m = address + SEGMEXEC_TASK_SIZE;
87753 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87754 + pte_m = pte_offset_map(pmd_m, address_m);
87755 + ptl_m = pte_lockptr(mm, pmd_m);
87756 + if (ptl != ptl_m) {
87757 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87758 + if (!pte_none(*pte_m))
87759 + goto out;
87760 + }
87761 +
87762 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
87763 + set_pte_at(mm, address_m, pte_m, entry_m);
87764 +out:
87765 + if (ptl != ptl_m)
87766 + spin_unlock(ptl_m);
87767 + pte_unmap(pte_m);
87768 +}
87769 +
87770 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
87771 +{
87772 + struct page *page_m;
87773 + pte_t entry;
87774 +
87775 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
87776 + goto out;
87777 +
87778 + entry = *pte;
87779 + page_m = vm_normal_page(vma, address, entry);
87780 + if (!page_m)
87781 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
87782 + else if (PageAnon(page_m)) {
87783 + if (pax_find_mirror_vma(vma)) {
87784 + pte_unmap_unlock(pte, ptl);
87785 + lock_page(page_m);
87786 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
87787 + if (pte_same(entry, *pte))
87788 + pax_mirror_anon_pte(vma, address, page_m, ptl);
87789 + else
87790 + unlock_page(page_m);
87791 + }
87792 + } else
87793 + pax_mirror_file_pte(vma, address, page_m, ptl);
87794 +
87795 +out:
87796 + pte_unmap_unlock(pte, ptl);
87797 +}
87798 +#endif
87799 +
87800 /*
87801 * This routine handles present pages, when users try to write
87802 * to a shared page. It is done by copying the page to a new address
87803 @@ -2800,6 +2996,12 @@ gotten:
87804 */
87805 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87806 if (likely(pte_same(*page_table, orig_pte))) {
87807 +
87808 +#ifdef CONFIG_PAX_SEGMEXEC
87809 + if (pax_find_mirror_vma(vma))
87810 + BUG_ON(!trylock_page(new_page));
87811 +#endif
87812 +
87813 if (old_page) {
87814 if (!PageAnon(old_page)) {
87815 dec_mm_counter_fast(mm, MM_FILEPAGES);
87816 @@ -2851,6 +3053,10 @@ gotten:
87817 page_remove_rmap(old_page);
87818 }
87819
87820 +#ifdef CONFIG_PAX_SEGMEXEC
87821 + pax_mirror_anon_pte(vma, address, new_page, ptl);
87822 +#endif
87823 +
87824 /* Free the old page.. */
87825 new_page = old_page;
87826 ret |= VM_FAULT_WRITE;
87827 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87828 swap_free(entry);
87829 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
87830 try_to_free_swap(page);
87831 +
87832 +#ifdef CONFIG_PAX_SEGMEXEC
87833 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
87834 +#endif
87835 +
87836 unlock_page(page);
87837 if (page != swapcache) {
87838 /*
87839 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87840
87841 /* No need to invalidate - it was non-present before */
87842 update_mmu_cache(vma, address, page_table);
87843 +
87844 +#ifdef CONFIG_PAX_SEGMEXEC
87845 + pax_mirror_anon_pte(vma, address, page, ptl);
87846 +#endif
87847 +
87848 unlock:
87849 pte_unmap_unlock(page_table, ptl);
87850 out:
87851 @@ -3170,40 +3386,6 @@ out_release:
87852 }
87853
87854 /*
87855 - * This is like a special single-page "expand_{down|up}wards()",
87856 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
87857 - * doesn't hit another vma.
87858 - */
87859 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
87860 -{
87861 - address &= PAGE_MASK;
87862 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
87863 - struct vm_area_struct *prev = vma->vm_prev;
87864 -
87865 - /*
87866 - * Is there a mapping abutting this one below?
87867 - *
87868 - * That's only ok if it's the same stack mapping
87869 - * that has gotten split..
87870 - */
87871 - if (prev && prev->vm_end == address)
87872 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
87873 -
87874 - expand_downwards(vma, address - PAGE_SIZE);
87875 - }
87876 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
87877 - struct vm_area_struct *next = vma->vm_next;
87878 -
87879 - /* As VM_GROWSDOWN but s/below/above/ */
87880 - if (next && next->vm_start == address + PAGE_SIZE)
87881 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
87882 -
87883 - expand_upwards(vma, address + PAGE_SIZE);
87884 - }
87885 - return 0;
87886 -}
87887 -
87888 -/*
87889 * We enter with non-exclusive mmap_sem (to exclude vma changes,
87890 * but allow concurrent faults), and pte mapped but not yet locked.
87891 * We return with mmap_sem still held, but pte unmapped and unlocked.
87892 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87893 unsigned long address, pte_t *page_table, pmd_t *pmd,
87894 unsigned int flags)
87895 {
87896 - struct page *page;
87897 + struct page *page = NULL;
87898 spinlock_t *ptl;
87899 pte_t entry;
87900
87901 - pte_unmap(page_table);
87902 -
87903 - /* Check if we need to add a guard page to the stack */
87904 - if (check_stack_guard_page(vma, address) < 0)
87905 - return VM_FAULT_SIGBUS;
87906 -
87907 - /* Use the zero-page for reads */
87908 if (!(flags & FAULT_FLAG_WRITE)) {
87909 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
87910 vma->vm_page_prot));
87911 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87912 + ptl = pte_lockptr(mm, pmd);
87913 + spin_lock(ptl);
87914 if (!pte_none(*page_table))
87915 goto unlock;
87916 goto setpte;
87917 }
87918
87919 /* Allocate our own private page. */
87920 + pte_unmap(page_table);
87921 +
87922 if (unlikely(anon_vma_prepare(vma)))
87923 goto oom;
87924 page = alloc_zeroed_user_highpage_movable(vma, address);
87925 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87926 if (!pte_none(*page_table))
87927 goto release;
87928
87929 +#ifdef CONFIG_PAX_SEGMEXEC
87930 + if (pax_find_mirror_vma(vma))
87931 + BUG_ON(!trylock_page(page));
87932 +#endif
87933 +
87934 inc_mm_counter_fast(mm, MM_ANONPAGES);
87935 page_add_new_anon_rmap(page, vma, address);
87936 setpte:
87937 @@ -3263,6 +3446,12 @@ setpte:
87938
87939 /* No need to invalidate - it was non-present before */
87940 update_mmu_cache(vma, address, page_table);
87941 +
87942 +#ifdef CONFIG_PAX_SEGMEXEC
87943 + if (page)
87944 + pax_mirror_anon_pte(vma, address, page, ptl);
87945 +#endif
87946 +
87947 unlock:
87948 pte_unmap_unlock(page_table, ptl);
87949 return 0;
87950 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87951 */
87952 /* Only go through if we didn't race with anybody else... */
87953 if (likely(pte_same(*page_table, orig_pte))) {
87954 +
87955 +#ifdef CONFIG_PAX_SEGMEXEC
87956 + if (anon && pax_find_mirror_vma(vma))
87957 + BUG_ON(!trylock_page(page));
87958 +#endif
87959 +
87960 flush_icache_page(vma, page);
87961 entry = mk_pte(page, vma->vm_page_prot);
87962 if (flags & FAULT_FLAG_WRITE)
87963 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87964
87965 /* no need to invalidate: a not-present page won't be cached */
87966 update_mmu_cache(vma, address, page_table);
87967 +
87968 +#ifdef CONFIG_PAX_SEGMEXEC
87969 + if (anon)
87970 + pax_mirror_anon_pte(vma, address, page, ptl);
87971 + else
87972 + pax_mirror_file_pte(vma, address, page, ptl);
87973 +#endif
87974 +
87975 } else {
87976 if (cow_page)
87977 mem_cgroup_uncharge_page(cow_page);
87978 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
87979 if (flags & FAULT_FLAG_WRITE)
87980 flush_tlb_fix_spurious_fault(vma, address);
87981 }
87982 +
87983 +#ifdef CONFIG_PAX_SEGMEXEC
87984 + pax_mirror_pte(vma, address, pte, pmd, ptl);
87985 + return 0;
87986 +#endif
87987 +
87988 unlock:
87989 pte_unmap_unlock(pte, ptl);
87990 return 0;
87991 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87992 pmd_t *pmd;
87993 pte_t *pte;
87994
87995 +#ifdef CONFIG_PAX_SEGMEXEC
87996 + struct vm_area_struct *vma_m;
87997 +#endif
87998 +
87999 if (unlikely(is_vm_hugetlb_page(vma)))
88000 return hugetlb_fault(mm, vma, address, flags);
88001
88002 +#ifdef CONFIG_PAX_SEGMEXEC
88003 + vma_m = pax_find_mirror_vma(vma);
88004 + if (vma_m) {
88005 + unsigned long address_m;
88006 + pgd_t *pgd_m;
88007 + pud_t *pud_m;
88008 + pmd_t *pmd_m;
88009 +
88010 + if (vma->vm_start > vma_m->vm_start) {
88011 + address_m = address;
88012 + address -= SEGMEXEC_TASK_SIZE;
88013 + vma = vma_m;
88014 + } else
88015 + address_m = address + SEGMEXEC_TASK_SIZE;
88016 +
88017 + pgd_m = pgd_offset(mm, address_m);
88018 + pud_m = pud_alloc(mm, pgd_m, address_m);
88019 + if (!pud_m)
88020 + return VM_FAULT_OOM;
88021 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88022 + if (!pmd_m)
88023 + return VM_FAULT_OOM;
88024 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88025 + return VM_FAULT_OOM;
88026 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88027 + }
88028 +#endif
88029 +
88030 retry:
88031 pgd = pgd_offset(mm, address);
88032 pud = pud_alloc(mm, pgd, address);
88033 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88034 spin_unlock(&mm->page_table_lock);
88035 return 0;
88036 }
88037 +
88038 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88039 +{
88040 + pud_t *new = pud_alloc_one(mm, address);
88041 + if (!new)
88042 + return -ENOMEM;
88043 +
88044 + smp_wmb(); /* See comment in __pte_alloc */
88045 +
88046 + spin_lock(&mm->page_table_lock);
88047 + if (pgd_present(*pgd)) /* Another has populated it */
88048 + pud_free(mm, new);
88049 + else
88050 + pgd_populate_kernel(mm, pgd, new);
88051 + spin_unlock(&mm->page_table_lock);
88052 + return 0;
88053 +}
88054 #endif /* __PAGETABLE_PUD_FOLDED */
88055
88056 #ifndef __PAGETABLE_PMD_FOLDED
88057 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88058 spin_unlock(&mm->page_table_lock);
88059 return 0;
88060 }
88061 +
88062 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88063 +{
88064 + pmd_t *new = pmd_alloc_one(mm, address);
88065 + if (!new)
88066 + return -ENOMEM;
88067 +
88068 + smp_wmb(); /* See comment in __pte_alloc */
88069 +
88070 + spin_lock(&mm->page_table_lock);
88071 +#ifndef __ARCH_HAS_4LEVEL_HACK
88072 + if (pud_present(*pud)) /* Another has populated it */
88073 + pmd_free(mm, new);
88074 + else
88075 + pud_populate_kernel(mm, pud, new);
88076 +#else
88077 + if (pgd_present(*pud)) /* Another has populated it */
88078 + pmd_free(mm, new);
88079 + else
88080 + pgd_populate_kernel(mm, pud, new);
88081 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88082 + spin_unlock(&mm->page_table_lock);
88083 + return 0;
88084 +}
88085 #endif /* __PAGETABLE_PMD_FOLDED */
88086
88087 #if !defined(__HAVE_ARCH_GATE_AREA)
88088 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
88089 gate_vma.vm_start = FIXADDR_USER_START;
88090 gate_vma.vm_end = FIXADDR_USER_END;
88091 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88092 - gate_vma.vm_page_prot = __P101;
88093 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88094
88095 return 0;
88096 }
88097 @@ -4071,8 +4353,8 @@ out:
88098 return ret;
88099 }
88100
88101 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88102 - void *buf, int len, int write)
88103 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88104 + void *buf, size_t len, int write)
88105 {
88106 resource_size_t phys_addr;
88107 unsigned long prot = 0;
88108 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
88109 * Access another process' address space as given in mm. If non-NULL, use the
88110 * given task for page fault accounting.
88111 */
88112 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88113 - unsigned long addr, void *buf, int len, int write)
88114 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88115 + unsigned long addr, void *buf, size_t len, int write)
88116 {
88117 struct vm_area_struct *vma;
88118 void *old_buf = buf;
88119 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88120 down_read(&mm->mmap_sem);
88121 /* ignore errors, just check how much was successfully transferred */
88122 while (len) {
88123 - int bytes, ret, offset;
88124 + ssize_t bytes, ret, offset;
88125 void *maddr;
88126 struct page *page = NULL;
88127
88128 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88129 *
88130 * The caller must hold a reference on @mm.
88131 */
88132 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88133 - void *buf, int len, int write)
88134 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88135 + void *buf, size_t len, int write)
88136 {
88137 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88138 }
88139 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88140 * Source/target buffer must be kernel space,
88141 * Do not walk the page table directly, use get_user_pages
88142 */
88143 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88144 - void *buf, int len, int write)
88145 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88146 + void *buf, size_t len, int write)
88147 {
88148 struct mm_struct *mm;
88149 - int ret;
88150 + ssize_t ret;
88151
88152 mm = get_task_mm(tsk);
88153 if (!mm)
88154 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88155 index 0472964..7d5a0ea 100644
88156 --- a/mm/mempolicy.c
88157 +++ b/mm/mempolicy.c
88158 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88159 unsigned long vmstart;
88160 unsigned long vmend;
88161
88162 +#ifdef CONFIG_PAX_SEGMEXEC
88163 + struct vm_area_struct *vma_m;
88164 +#endif
88165 +
88166 vma = find_vma(mm, start);
88167 if (!vma || vma->vm_start > start)
88168 return -EFAULT;
88169 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88170 err = vma_replace_policy(vma, new_pol);
88171 if (err)
88172 goto out;
88173 +
88174 +#ifdef CONFIG_PAX_SEGMEXEC
88175 + vma_m = pax_find_mirror_vma(vma);
88176 + if (vma_m) {
88177 + err = vma_replace_policy(vma_m, new_pol);
88178 + if (err)
88179 + goto out;
88180 + }
88181 +#endif
88182 +
88183 }
88184
88185 out:
88186 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88187
88188 if (end < start)
88189 return -EINVAL;
88190 +
88191 +#ifdef CONFIG_PAX_SEGMEXEC
88192 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88193 + if (end > SEGMEXEC_TASK_SIZE)
88194 + return -EINVAL;
88195 + } else
88196 +#endif
88197 +
88198 + if (end > TASK_SIZE)
88199 + return -EINVAL;
88200 +
88201 if (end == start)
88202 return 0;
88203
88204 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88205 */
88206 tcred = __task_cred(task);
88207 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88208 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88209 - !capable(CAP_SYS_NICE)) {
88210 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88211 rcu_read_unlock();
88212 err = -EPERM;
88213 goto out_put;
88214 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88215 goto out;
88216 }
88217
88218 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
88219 + if (mm != current->mm &&
88220 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
88221 + mmput(mm);
88222 + err = -EPERM;
88223 + goto out;
88224 + }
88225 +#endif
88226 +
88227 err = do_migrate_pages(mm, old, new,
88228 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
88229
88230 diff --git a/mm/migrate.c b/mm/migrate.c
88231 index c046927..6996b40 100644
88232 --- a/mm/migrate.c
88233 +++ b/mm/migrate.c
88234 @@ -1404,8 +1404,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
88235 */
88236 tcred = __task_cred(task);
88237 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88238 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88239 - !capable(CAP_SYS_NICE)) {
88240 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88241 rcu_read_unlock();
88242 err = -EPERM;
88243 goto out;
88244 diff --git a/mm/mlock.c b/mm/mlock.c
88245 index d480cd6..0f98458 100644
88246 --- a/mm/mlock.c
88247 +++ b/mm/mlock.c
88248 @@ -14,6 +14,7 @@
88249 #include <linux/pagevec.h>
88250 #include <linux/mempolicy.h>
88251 #include <linux/syscalls.h>
88252 +#include <linux/security.h>
88253 #include <linux/sched.h>
88254 #include <linux/export.h>
88255 #include <linux/rmap.h>
88256 @@ -568,7 +569,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
88257 {
88258 unsigned long nstart, end, tmp;
88259 struct vm_area_struct * vma, * prev;
88260 - int error;
88261 + int error = 0;
88262
88263 VM_BUG_ON(start & ~PAGE_MASK);
88264 VM_BUG_ON(len != PAGE_ALIGN(len));
88265 @@ -577,6 +578,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
88266 return -EINVAL;
88267 if (end == start)
88268 return 0;
88269 + if (end > TASK_SIZE)
88270 + return -EINVAL;
88271 +
88272 vma = find_vma(current->mm, start);
88273 if (!vma || vma->vm_start > start)
88274 return -ENOMEM;
88275 @@ -588,6 +592,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
88276 for (nstart = start ; ; ) {
88277 vm_flags_t newflags;
88278
88279 +#ifdef CONFIG_PAX_SEGMEXEC
88280 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88281 + break;
88282 +#endif
88283 +
88284 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
88285
88286 newflags = vma->vm_flags & ~VM_LOCKED;
88287 @@ -700,6 +709,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
88288 lock_limit >>= PAGE_SHIFT;
88289
88290 /* check against resource limits */
88291 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
88292 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
88293 error = do_mlock(start, len, 1);
88294 up_write(&current->mm->mmap_sem);
88295 @@ -734,6 +744,11 @@ static int do_mlockall(int flags)
88296 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
88297 vm_flags_t newflags;
88298
88299 +#ifdef CONFIG_PAX_SEGMEXEC
88300 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88301 + break;
88302 +#endif
88303 +
88304 newflags = vma->vm_flags & ~VM_LOCKED;
88305 if (flags & MCL_CURRENT)
88306 newflags |= VM_LOCKED;
88307 @@ -767,6 +782,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
88308 lock_limit >>= PAGE_SHIFT;
88309
88310 ret = -ENOMEM;
88311 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
88312 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
88313 capable(CAP_IPC_LOCK))
88314 ret = do_mlockall(flags);
88315 diff --git a/mm/mmap.c b/mm/mmap.c
88316 index 9d54851..e8c6035 100644
88317 --- a/mm/mmap.c
88318 +++ b/mm/mmap.c
88319 @@ -36,6 +36,7 @@
88320 #include <linux/sched/sysctl.h>
88321 #include <linux/notifier.h>
88322 #include <linux/memory.h>
88323 +#include <linux/random.h>
88324
88325 #include <asm/uaccess.h>
88326 #include <asm/cacheflush.h>
88327 @@ -52,6 +53,16 @@
88328 #define arch_rebalance_pgtables(addr, len) (addr)
88329 #endif
88330
88331 +static inline void verify_mm_writelocked(struct mm_struct *mm)
88332 +{
88333 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
88334 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88335 + up_read(&mm->mmap_sem);
88336 + BUG();
88337 + }
88338 +#endif
88339 +}
88340 +
88341 static void unmap_region(struct mm_struct *mm,
88342 struct vm_area_struct *vma, struct vm_area_struct *prev,
88343 unsigned long start, unsigned long end);
88344 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
88345 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
88346 *
88347 */
88348 -pgprot_t protection_map[16] = {
88349 +pgprot_t protection_map[16] __read_only = {
88350 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
88351 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
88352 };
88353
88354 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
88355 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
88356 {
88357 - return __pgprot(pgprot_val(protection_map[vm_flags &
88358 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
88359 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
88360 pgprot_val(arch_vm_get_page_prot(vm_flags)));
88361 +
88362 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88363 + if (!(__supported_pte_mask & _PAGE_NX) &&
88364 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
88365 + (vm_flags & (VM_READ | VM_WRITE)))
88366 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
88367 +#endif
88368 +
88369 + return prot;
88370 }
88371 EXPORT_SYMBOL(vm_get_page_prot);
88372
88373 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
88374 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
88375 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88376 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88377 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
88378 /*
88379 * Make sure vm_committed_as in one cacheline and not cacheline shared with
88380 * other variables. It can be updated by several CPUs frequently.
88381 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
88382 struct vm_area_struct *next = vma->vm_next;
88383
88384 might_sleep();
88385 + BUG_ON(vma->vm_mirror);
88386 if (vma->vm_ops && vma->vm_ops->close)
88387 vma->vm_ops->close(vma);
88388 if (vma->vm_file)
88389 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
88390 * not page aligned -Ram Gupta
88391 */
88392 rlim = rlimit(RLIMIT_DATA);
88393 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
88394 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
88395 (mm->end_data - mm->start_data) > rlim)
88396 goto out;
88397 @@ -933,6 +956,12 @@ static int
88398 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
88399 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88400 {
88401 +
88402 +#ifdef CONFIG_PAX_SEGMEXEC
88403 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
88404 + return 0;
88405 +#endif
88406 +
88407 if (is_mergeable_vma(vma, file, vm_flags) &&
88408 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88409 if (vma->vm_pgoff == vm_pgoff)
88410 @@ -952,6 +981,12 @@ static int
88411 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88412 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88413 {
88414 +
88415 +#ifdef CONFIG_PAX_SEGMEXEC
88416 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
88417 + return 0;
88418 +#endif
88419 +
88420 if (is_mergeable_vma(vma, file, vm_flags) &&
88421 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88422 pgoff_t vm_pglen;
88423 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88424 struct vm_area_struct *vma_merge(struct mm_struct *mm,
88425 struct vm_area_struct *prev, unsigned long addr,
88426 unsigned long end, unsigned long vm_flags,
88427 - struct anon_vma *anon_vma, struct file *file,
88428 + struct anon_vma *anon_vma, struct file *file,
88429 pgoff_t pgoff, struct mempolicy *policy)
88430 {
88431 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
88432 struct vm_area_struct *area, *next;
88433 int err;
88434
88435 +#ifdef CONFIG_PAX_SEGMEXEC
88436 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
88437 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
88438 +
88439 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
88440 +#endif
88441 +
88442 /*
88443 * We later require that vma->vm_flags == vm_flags,
88444 * so this tests vma->vm_flags & VM_SPECIAL, too.
88445 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88446 if (next && next->vm_end == end) /* cases 6, 7, 8 */
88447 next = next->vm_next;
88448
88449 +#ifdef CONFIG_PAX_SEGMEXEC
88450 + if (prev)
88451 + prev_m = pax_find_mirror_vma(prev);
88452 + if (area)
88453 + area_m = pax_find_mirror_vma(area);
88454 + if (next)
88455 + next_m = pax_find_mirror_vma(next);
88456 +#endif
88457 +
88458 /*
88459 * Can it merge with the predecessor?
88460 */
88461 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88462 /* cases 1, 6 */
88463 err = vma_adjust(prev, prev->vm_start,
88464 next->vm_end, prev->vm_pgoff, NULL);
88465 - } else /* cases 2, 5, 7 */
88466 +
88467 +#ifdef CONFIG_PAX_SEGMEXEC
88468 + if (!err && prev_m)
88469 + err = vma_adjust(prev_m, prev_m->vm_start,
88470 + next_m->vm_end, prev_m->vm_pgoff, NULL);
88471 +#endif
88472 +
88473 + } else { /* cases 2, 5, 7 */
88474 err = vma_adjust(prev, prev->vm_start,
88475 end, prev->vm_pgoff, NULL);
88476 +
88477 +#ifdef CONFIG_PAX_SEGMEXEC
88478 + if (!err && prev_m)
88479 + err = vma_adjust(prev_m, prev_m->vm_start,
88480 + end_m, prev_m->vm_pgoff, NULL);
88481 +#endif
88482 +
88483 + }
88484 if (err)
88485 return NULL;
88486 khugepaged_enter_vma_merge(prev);
88487 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88488 mpol_equal(policy, vma_policy(next)) &&
88489 can_vma_merge_before(next, vm_flags,
88490 anon_vma, file, pgoff+pglen)) {
88491 - if (prev && addr < prev->vm_end) /* case 4 */
88492 + if (prev && addr < prev->vm_end) { /* case 4 */
88493 err = vma_adjust(prev, prev->vm_start,
88494 addr, prev->vm_pgoff, NULL);
88495 - else /* cases 3, 8 */
88496 +
88497 +#ifdef CONFIG_PAX_SEGMEXEC
88498 + if (!err && prev_m)
88499 + err = vma_adjust(prev_m, prev_m->vm_start,
88500 + addr_m, prev_m->vm_pgoff, NULL);
88501 +#endif
88502 +
88503 + } else { /* cases 3, 8 */
88504 err = vma_adjust(area, addr, next->vm_end,
88505 next->vm_pgoff - pglen, NULL);
88506 +
88507 +#ifdef CONFIG_PAX_SEGMEXEC
88508 + if (!err && area_m)
88509 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
88510 + next_m->vm_pgoff - pglen, NULL);
88511 +#endif
88512 +
88513 + }
88514 if (err)
88515 return NULL;
88516 khugepaged_enter_vma_merge(area);
88517 @@ -1165,8 +1246,10 @@ none:
88518 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88519 struct file *file, long pages)
88520 {
88521 - const unsigned long stack_flags
88522 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
88523 +
88524 +#ifdef CONFIG_PAX_RANDMMAP
88525 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88526 +#endif
88527
88528 mm->total_vm += pages;
88529
88530 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88531 mm->shared_vm += pages;
88532 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
88533 mm->exec_vm += pages;
88534 - } else if (flags & stack_flags)
88535 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
88536 mm->stack_vm += pages;
88537 }
88538 #endif /* CONFIG_PROC_FS */
88539 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88540 * (the exception is when the underlying filesystem is noexec
88541 * mounted, in which case we dont add PROT_EXEC.)
88542 */
88543 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88544 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88545 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
88546 prot |= PROT_EXEC;
88547
88548 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88549 /* Obtain the address to map to. we verify (or select) it and ensure
88550 * that it represents a valid section of the address space.
88551 */
88552 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
88553 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
88554 if (addr & ~PAGE_MASK)
88555 return addr;
88556
88557 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88558 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
88559 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
88560
88561 +#ifdef CONFIG_PAX_MPROTECT
88562 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88563 +
88564 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
88565 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
88566 + mm->binfmt->handle_mmap)
88567 + mm->binfmt->handle_mmap(file);
88568 +#endif
88569 +
88570 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88571 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
88572 + gr_log_rwxmmap(file);
88573 +
88574 +#ifdef CONFIG_PAX_EMUPLT
88575 + vm_flags &= ~VM_EXEC;
88576 +#else
88577 + return -EPERM;
88578 +#endif
88579 +
88580 + }
88581 +
88582 + if (!(vm_flags & VM_EXEC))
88583 + vm_flags &= ~VM_MAYEXEC;
88584 +#else
88585 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88586 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88587 +#endif
88588 + else
88589 + vm_flags &= ~VM_MAYWRITE;
88590 + }
88591 +#endif
88592 +
88593 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88594 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88595 + vm_flags &= ~VM_PAGEEXEC;
88596 +#endif
88597 +
88598 if (flags & MAP_LOCKED)
88599 if (!can_do_mlock())
88600 return -EPERM;
88601 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88602 locked += mm->locked_vm;
88603 lock_limit = rlimit(RLIMIT_MEMLOCK);
88604 lock_limit >>= PAGE_SHIFT;
88605 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88606 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
88607 return -EAGAIN;
88608 }
88609 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88610 vm_flags |= VM_NORESERVE;
88611 }
88612
88613 + if (!gr_acl_handle_mmap(file, prot))
88614 + return -EACCES;
88615 +
88616 addr = mmap_region(file, addr, len, vm_flags, pgoff);
88617 if (!IS_ERR_VALUE(addr) &&
88618 ((vm_flags & VM_LOCKED) ||
88619 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
88620 vm_flags_t vm_flags = vma->vm_flags;
88621
88622 /* If it was private or non-writable, the write bit is already clear */
88623 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
88624 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
88625 return 0;
88626
88627 /* The backer wishes to know when pages are first written to? */
88628 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88629 struct rb_node **rb_link, *rb_parent;
88630 unsigned long charged = 0;
88631
88632 +#ifdef CONFIG_PAX_SEGMEXEC
88633 + struct vm_area_struct *vma_m = NULL;
88634 +#endif
88635 +
88636 + /*
88637 + * mm->mmap_sem is required to protect against another thread
88638 + * changing the mappings in case we sleep.
88639 + */
88640 + verify_mm_writelocked(mm);
88641 +
88642 /* Check against address space limit. */
88643 +
88644 +#ifdef CONFIG_PAX_RANDMMAP
88645 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88646 +#endif
88647 +
88648 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
88649 unsigned long nr_pages;
88650
88651 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88652
88653 /* Clear old maps */
88654 error = -ENOMEM;
88655 -munmap_back:
88656 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88657 if (do_munmap(mm, addr, len))
88658 return -ENOMEM;
88659 - goto munmap_back;
88660 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88661 }
88662
88663 /*
88664 @@ -1537,6 +1675,16 @@ munmap_back:
88665 goto unacct_error;
88666 }
88667
88668 +#ifdef CONFIG_PAX_SEGMEXEC
88669 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
88670 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88671 + if (!vma_m) {
88672 + error = -ENOMEM;
88673 + goto free_vma;
88674 + }
88675 + }
88676 +#endif
88677 +
88678 vma->vm_mm = mm;
88679 vma->vm_start = addr;
88680 vma->vm_end = addr + len;
88681 @@ -1556,6 +1704,13 @@ munmap_back:
88682 if (error)
88683 goto unmap_and_free_vma;
88684
88685 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88686 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
88687 + vma->vm_flags |= VM_PAGEEXEC;
88688 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88689 + }
88690 +#endif
88691 +
88692 /* Can addr have changed??
88693 *
88694 * Answer: Yes, several device drivers can do it in their
88695 @@ -1589,6 +1744,12 @@ munmap_back:
88696 }
88697
88698 vma_link(mm, vma, prev, rb_link, rb_parent);
88699 +
88700 +#ifdef CONFIG_PAX_SEGMEXEC
88701 + if (vma_m)
88702 + BUG_ON(pax_mirror_vma(vma_m, vma));
88703 +#endif
88704 +
88705 /* Once vma denies write, undo our temporary denial count */
88706 if (vm_flags & VM_DENYWRITE)
88707 allow_write_access(file);
88708 @@ -1597,6 +1758,7 @@ out:
88709 perf_event_mmap(vma);
88710
88711 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
88712 + track_exec_limit(mm, addr, addr + len, vm_flags);
88713 if (vm_flags & VM_LOCKED) {
88714 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
88715 vma == get_gate_vma(current->mm)))
88716 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
88717 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
88718 charged = 0;
88719 free_vma:
88720 +
88721 +#ifdef CONFIG_PAX_SEGMEXEC
88722 + if (vma_m)
88723 + kmem_cache_free(vm_area_cachep, vma_m);
88724 +#endif
88725 +
88726 kmem_cache_free(vm_area_cachep, vma);
88727 unacct_error:
88728 if (charged)
88729 @@ -1636,7 +1804,63 @@ unacct_error:
88730 return error;
88731 }
88732
88733 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88734 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
88735 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
88736 +{
88737 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
88738 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
88739 +
88740 + return 0;
88741 +}
88742 +#endif
88743 +
88744 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
88745 +{
88746 + if (!vma) {
88747 +#ifdef CONFIG_STACK_GROWSUP
88748 + if (addr > sysctl_heap_stack_gap)
88749 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
88750 + else
88751 + vma = find_vma(current->mm, 0);
88752 + if (vma && (vma->vm_flags & VM_GROWSUP))
88753 + return false;
88754 +#endif
88755 + return true;
88756 + }
88757 +
88758 + if (addr + len > vma->vm_start)
88759 + return false;
88760 +
88761 + if (vma->vm_flags & VM_GROWSDOWN)
88762 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
88763 +#ifdef CONFIG_STACK_GROWSUP
88764 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
88765 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
88766 +#endif
88767 + else if (offset)
88768 + return offset <= vma->vm_start - addr - len;
88769 +
88770 + return true;
88771 +}
88772 +
88773 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
88774 +{
88775 + if (vma->vm_start < len)
88776 + return -ENOMEM;
88777 +
88778 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
88779 + if (offset <= vma->vm_start - len)
88780 + return vma->vm_start - len - offset;
88781 + else
88782 + return -ENOMEM;
88783 + }
88784 +
88785 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
88786 + return vma->vm_start - len - sysctl_heap_stack_gap;
88787 + return -ENOMEM;
88788 +}
88789 +
88790 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
88791 {
88792 /*
88793 * We implement the search by looking for an rbtree node that
88794 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88795 }
88796 }
88797
88798 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
88799 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
88800 check_current:
88801 /* Check if current node has a suitable gap */
88802 if (gap_start > high_limit)
88803 return -ENOMEM;
88804 +
88805 + if (gap_end - gap_start > info->threadstack_offset)
88806 + gap_start += info->threadstack_offset;
88807 + else
88808 + gap_start = gap_end;
88809 +
88810 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88811 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88812 + gap_start += sysctl_heap_stack_gap;
88813 + else
88814 + gap_start = gap_end;
88815 + }
88816 + if (vma->vm_flags & VM_GROWSDOWN) {
88817 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88818 + gap_end -= sysctl_heap_stack_gap;
88819 + else
88820 + gap_end = gap_start;
88821 + }
88822 if (gap_end >= low_limit && gap_end - gap_start >= length)
88823 goto found;
88824
88825 @@ -1738,7 +1980,7 @@ found:
88826 return gap_start;
88827 }
88828
88829 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
88830 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
88831 {
88832 struct mm_struct *mm = current->mm;
88833 struct vm_area_struct *vma;
88834 @@ -1792,6 +2034,24 @@ check_current:
88835 gap_end = vma->vm_start;
88836 if (gap_end < low_limit)
88837 return -ENOMEM;
88838 +
88839 + if (gap_end - gap_start > info->threadstack_offset)
88840 + gap_end -= info->threadstack_offset;
88841 + else
88842 + gap_end = gap_start;
88843 +
88844 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88845 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88846 + gap_start += sysctl_heap_stack_gap;
88847 + else
88848 + gap_start = gap_end;
88849 + }
88850 + if (vma->vm_flags & VM_GROWSDOWN) {
88851 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88852 + gap_end -= sysctl_heap_stack_gap;
88853 + else
88854 + gap_end = gap_start;
88855 + }
88856 if (gap_start <= high_limit && gap_end - gap_start >= length)
88857 goto found;
88858
88859 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88860 struct mm_struct *mm = current->mm;
88861 struct vm_area_struct *vma;
88862 struct vm_unmapped_area_info info;
88863 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88864
88865 if (len > TASK_SIZE)
88866 return -ENOMEM;
88867 @@ -1862,19 +2123,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88868 if (flags & MAP_FIXED)
88869 return addr;
88870
88871 +#ifdef CONFIG_PAX_RANDMMAP
88872 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88873 +#endif
88874 +
88875 if (addr) {
88876 addr = PAGE_ALIGN(addr);
88877 vma = find_vma(mm, addr);
88878 - if (TASK_SIZE - len >= addr &&
88879 - (!vma || addr + len <= vma->vm_start))
88880 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88881 return addr;
88882 }
88883
88884 info.flags = 0;
88885 info.length = len;
88886 info.low_limit = TASK_UNMAPPED_BASE;
88887 +
88888 +#ifdef CONFIG_PAX_RANDMMAP
88889 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88890 + info.low_limit += mm->delta_mmap;
88891 +#endif
88892 +
88893 info.high_limit = TASK_SIZE;
88894 info.align_mask = 0;
88895 + info.threadstack_offset = offset;
88896 return vm_unmapped_area(&info);
88897 }
88898 #endif
88899 @@ -1893,6 +2164,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88900 struct mm_struct *mm = current->mm;
88901 unsigned long addr = addr0;
88902 struct vm_unmapped_area_info info;
88903 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88904
88905 /* requested length too big for entire address space */
88906 if (len > TASK_SIZE)
88907 @@ -1901,12 +2173,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88908 if (flags & MAP_FIXED)
88909 return addr;
88910
88911 +#ifdef CONFIG_PAX_RANDMMAP
88912 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88913 +#endif
88914 +
88915 /* requesting a specific address */
88916 if (addr) {
88917 addr = PAGE_ALIGN(addr);
88918 vma = find_vma(mm, addr);
88919 - if (TASK_SIZE - len >= addr &&
88920 - (!vma || addr + len <= vma->vm_start))
88921 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88922 return addr;
88923 }
88924
88925 @@ -1915,6 +2190,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88926 info.low_limit = PAGE_SIZE;
88927 info.high_limit = mm->mmap_base;
88928 info.align_mask = 0;
88929 + info.threadstack_offset = offset;
88930 addr = vm_unmapped_area(&info);
88931
88932 /*
88933 @@ -1927,6 +2203,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88934 VM_BUG_ON(addr != -ENOMEM);
88935 info.flags = 0;
88936 info.low_limit = TASK_UNMAPPED_BASE;
88937 +
88938 +#ifdef CONFIG_PAX_RANDMMAP
88939 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88940 + info.low_limit += mm->delta_mmap;
88941 +#endif
88942 +
88943 info.high_limit = TASK_SIZE;
88944 addr = vm_unmapped_area(&info);
88945 }
88946 @@ -2028,6 +2310,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
88947 return vma;
88948 }
88949
88950 +#ifdef CONFIG_PAX_SEGMEXEC
88951 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88952 +{
88953 + struct vm_area_struct *vma_m;
88954 +
88955 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88956 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88957 + BUG_ON(vma->vm_mirror);
88958 + return NULL;
88959 + }
88960 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88961 + vma_m = vma->vm_mirror;
88962 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88963 + BUG_ON(vma->vm_file != vma_m->vm_file);
88964 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88965 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88966 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88967 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88968 + return vma_m;
88969 +}
88970 +#endif
88971 +
88972 /*
88973 * Verify that the stack growth is acceptable and
88974 * update accounting. This is shared with both the
88975 @@ -2044,6 +2348,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88976 return -ENOMEM;
88977
88978 /* Stack limit test */
88979 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88980 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88981 return -ENOMEM;
88982
88983 @@ -2054,6 +2359,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88984 locked = mm->locked_vm + grow;
88985 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88986 limit >>= PAGE_SHIFT;
88987 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88988 if (locked > limit && !capable(CAP_IPC_LOCK))
88989 return -ENOMEM;
88990 }
88991 @@ -2083,37 +2389,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88992 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88993 * vma is the last one with address > vma->vm_end. Have to extend vma.
88994 */
88995 +#ifndef CONFIG_IA64
88996 +static
88997 +#endif
88998 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88999 {
89000 int error;
89001 + bool locknext;
89002
89003 if (!(vma->vm_flags & VM_GROWSUP))
89004 return -EFAULT;
89005
89006 + /* Also guard against wrapping around to address 0. */
89007 + if (address < PAGE_ALIGN(address+1))
89008 + address = PAGE_ALIGN(address+1);
89009 + else
89010 + return -ENOMEM;
89011 +
89012 /*
89013 * We must make sure the anon_vma is allocated
89014 * so that the anon_vma locking is not a noop.
89015 */
89016 if (unlikely(anon_vma_prepare(vma)))
89017 return -ENOMEM;
89018 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89019 + if (locknext && anon_vma_prepare(vma->vm_next))
89020 + return -ENOMEM;
89021 vma_lock_anon_vma(vma);
89022 + if (locknext)
89023 + vma_lock_anon_vma(vma->vm_next);
89024
89025 /*
89026 * vma->vm_start/vm_end cannot change under us because the caller
89027 * is required to hold the mmap_sem in read mode. We need the
89028 - * anon_vma lock to serialize against concurrent expand_stacks.
89029 - * Also guard against wrapping around to address 0.
89030 + * anon_vma locks to serialize against concurrent expand_stacks
89031 + * and expand_upwards.
89032 */
89033 - if (address < PAGE_ALIGN(address+4))
89034 - address = PAGE_ALIGN(address+4);
89035 - else {
89036 - vma_unlock_anon_vma(vma);
89037 - return -ENOMEM;
89038 - }
89039 error = 0;
89040
89041 /* Somebody else might have raced and expanded it already */
89042 - if (address > vma->vm_end) {
89043 + 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)
89044 + error = -ENOMEM;
89045 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89046 unsigned long size, grow;
89047
89048 size = address - vma->vm_start;
89049 @@ -2148,6 +2465,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89050 }
89051 }
89052 }
89053 + if (locknext)
89054 + vma_unlock_anon_vma(vma->vm_next);
89055 vma_unlock_anon_vma(vma);
89056 khugepaged_enter_vma_merge(vma);
89057 validate_mm(vma->vm_mm);
89058 @@ -2162,6 +2481,8 @@ int expand_downwards(struct vm_area_struct *vma,
89059 unsigned long address)
89060 {
89061 int error;
89062 + bool lockprev = false;
89063 + struct vm_area_struct *prev;
89064
89065 /*
89066 * We must make sure the anon_vma is allocated
89067 @@ -2175,6 +2496,15 @@ int expand_downwards(struct vm_area_struct *vma,
89068 if (error)
89069 return error;
89070
89071 + prev = vma->vm_prev;
89072 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89073 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89074 +#endif
89075 + if (lockprev && anon_vma_prepare(prev))
89076 + return -ENOMEM;
89077 + if (lockprev)
89078 + vma_lock_anon_vma(prev);
89079 +
89080 vma_lock_anon_vma(vma);
89081
89082 /*
89083 @@ -2184,9 +2514,17 @@ int expand_downwards(struct vm_area_struct *vma,
89084 */
89085
89086 /* Somebody else might have raced and expanded it already */
89087 - if (address < vma->vm_start) {
89088 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89089 + error = -ENOMEM;
89090 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89091 unsigned long size, grow;
89092
89093 +#ifdef CONFIG_PAX_SEGMEXEC
89094 + struct vm_area_struct *vma_m;
89095 +
89096 + vma_m = pax_find_mirror_vma(vma);
89097 +#endif
89098 +
89099 size = vma->vm_end - address;
89100 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89101
89102 @@ -2211,13 +2549,27 @@ int expand_downwards(struct vm_area_struct *vma,
89103 vma->vm_pgoff -= grow;
89104 anon_vma_interval_tree_post_update_vma(vma);
89105 vma_gap_update(vma);
89106 +
89107 +#ifdef CONFIG_PAX_SEGMEXEC
89108 + if (vma_m) {
89109 + anon_vma_interval_tree_pre_update_vma(vma_m);
89110 + vma_m->vm_start -= grow << PAGE_SHIFT;
89111 + vma_m->vm_pgoff -= grow;
89112 + anon_vma_interval_tree_post_update_vma(vma_m);
89113 + vma_gap_update(vma_m);
89114 + }
89115 +#endif
89116 +
89117 spin_unlock(&vma->vm_mm->page_table_lock);
89118
89119 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89120 perf_event_mmap(vma);
89121 }
89122 }
89123 }
89124 vma_unlock_anon_vma(vma);
89125 + if (lockprev)
89126 + vma_unlock_anon_vma(prev);
89127 khugepaged_enter_vma_merge(vma);
89128 validate_mm(vma->vm_mm);
89129 return error;
89130 @@ -2315,6 +2667,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89131 do {
89132 long nrpages = vma_pages(vma);
89133
89134 +#ifdef CONFIG_PAX_SEGMEXEC
89135 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89136 + vma = remove_vma(vma);
89137 + continue;
89138 + }
89139 +#endif
89140 +
89141 if (vma->vm_flags & VM_ACCOUNT)
89142 nr_accounted += nrpages;
89143 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89144 @@ -2359,6 +2718,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89145 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89146 vma->vm_prev = NULL;
89147 do {
89148 +
89149 +#ifdef CONFIG_PAX_SEGMEXEC
89150 + if (vma->vm_mirror) {
89151 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89152 + vma->vm_mirror->vm_mirror = NULL;
89153 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89154 + vma->vm_mirror = NULL;
89155 + }
89156 +#endif
89157 +
89158 vma_rb_erase(vma, &mm->mm_rb);
89159 mm->map_count--;
89160 tail_vma = vma;
89161 @@ -2384,14 +2753,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89162 struct vm_area_struct *new;
89163 int err = -ENOMEM;
89164
89165 +#ifdef CONFIG_PAX_SEGMEXEC
89166 + struct vm_area_struct *vma_m, *new_m = NULL;
89167 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89168 +#endif
89169 +
89170 if (is_vm_hugetlb_page(vma) && (addr &
89171 ~(huge_page_mask(hstate_vma(vma)))))
89172 return -EINVAL;
89173
89174 +#ifdef CONFIG_PAX_SEGMEXEC
89175 + vma_m = pax_find_mirror_vma(vma);
89176 +#endif
89177 +
89178 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89179 if (!new)
89180 goto out_err;
89181
89182 +#ifdef CONFIG_PAX_SEGMEXEC
89183 + if (vma_m) {
89184 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89185 + if (!new_m) {
89186 + kmem_cache_free(vm_area_cachep, new);
89187 + goto out_err;
89188 + }
89189 + }
89190 +#endif
89191 +
89192 /* most fields are the same, copy all, and then fixup */
89193 *new = *vma;
89194
89195 @@ -2404,6 +2792,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89196 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
89197 }
89198
89199 +#ifdef CONFIG_PAX_SEGMEXEC
89200 + if (vma_m) {
89201 + *new_m = *vma_m;
89202 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
89203 + new_m->vm_mirror = new;
89204 + new->vm_mirror = new_m;
89205 +
89206 + if (new_below)
89207 + new_m->vm_end = addr_m;
89208 + else {
89209 + new_m->vm_start = addr_m;
89210 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
89211 + }
89212 + }
89213 +#endif
89214 +
89215 err = vma_dup_policy(vma, new);
89216 if (err)
89217 goto out_free_vma;
89218 @@ -2423,6 +2827,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89219 else
89220 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
89221
89222 +#ifdef CONFIG_PAX_SEGMEXEC
89223 + if (!err && vma_m) {
89224 + struct mempolicy *pol = vma_policy(new);
89225 +
89226 + if (anon_vma_clone(new_m, vma_m))
89227 + goto out_free_mpol;
89228 +
89229 + mpol_get(pol);
89230 + set_vma_policy(new_m, pol);
89231 +
89232 + if (new_m->vm_file)
89233 + get_file(new_m->vm_file);
89234 +
89235 + if (new_m->vm_ops && new_m->vm_ops->open)
89236 + new_m->vm_ops->open(new_m);
89237 +
89238 + if (new_below)
89239 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
89240 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
89241 + else
89242 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
89243 +
89244 + if (err) {
89245 + if (new_m->vm_ops && new_m->vm_ops->close)
89246 + new_m->vm_ops->close(new_m);
89247 + if (new_m->vm_file)
89248 + fput(new_m->vm_file);
89249 + mpol_put(pol);
89250 + }
89251 + }
89252 +#endif
89253 +
89254 /* Success. */
89255 if (!err)
89256 return 0;
89257 @@ -2432,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89258 new->vm_ops->close(new);
89259 if (new->vm_file)
89260 fput(new->vm_file);
89261 - unlink_anon_vmas(new);
89262 out_free_mpol:
89263 mpol_put(vma_policy(new));
89264 out_free_vma:
89265 +
89266 +#ifdef CONFIG_PAX_SEGMEXEC
89267 + if (new_m) {
89268 + unlink_anon_vmas(new_m);
89269 + kmem_cache_free(vm_area_cachep, new_m);
89270 + }
89271 +#endif
89272 +
89273 + unlink_anon_vmas(new);
89274 kmem_cache_free(vm_area_cachep, new);
89275 out_err:
89276 return err;
89277 @@ -2448,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89278 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89279 unsigned long addr, int new_below)
89280 {
89281 +
89282 +#ifdef CONFIG_PAX_SEGMEXEC
89283 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89284 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
89285 + if (mm->map_count >= sysctl_max_map_count-1)
89286 + return -ENOMEM;
89287 + } else
89288 +#endif
89289 +
89290 if (mm->map_count >= sysctl_max_map_count)
89291 return -ENOMEM;
89292
89293 @@ -2459,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89294 * work. This now handles partial unmappings.
89295 * Jeremy Fitzhardinge <jeremy@goop.org>
89296 */
89297 +#ifdef CONFIG_PAX_SEGMEXEC
89298 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89299 {
89300 + int ret = __do_munmap(mm, start, len);
89301 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
89302 + return ret;
89303 +
89304 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
89305 +}
89306 +
89307 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89308 +#else
89309 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89310 +#endif
89311 +{
89312 unsigned long end;
89313 struct vm_area_struct *vma, *prev, *last;
89314
89315 + /*
89316 + * mm->mmap_sem is required to protect against another thread
89317 + * changing the mappings in case we sleep.
89318 + */
89319 + verify_mm_writelocked(mm);
89320 +
89321 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
89322 return -EINVAL;
89323
89324 @@ -2538,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89325 /* Fix up all other VM information */
89326 remove_vma_list(mm, vma);
89327
89328 + track_exec_limit(mm, start, end, 0UL);
89329 +
89330 return 0;
89331 }
89332
89333 @@ -2546,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
89334 int ret;
89335 struct mm_struct *mm = current->mm;
89336
89337 +
89338 +#ifdef CONFIG_PAX_SEGMEXEC
89339 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
89340 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
89341 + return -EINVAL;
89342 +#endif
89343 +
89344 down_write(&mm->mmap_sem);
89345 ret = do_munmap(mm, start, len);
89346 up_write(&mm->mmap_sem);
89347 @@ -2559,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
89348 return vm_munmap(addr, len);
89349 }
89350
89351 -static inline void verify_mm_writelocked(struct mm_struct *mm)
89352 -{
89353 -#ifdef CONFIG_DEBUG_VM
89354 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89355 - WARN_ON(1);
89356 - up_read(&mm->mmap_sem);
89357 - }
89358 -#endif
89359 -}
89360 -
89361 /*
89362 * this is really a simplified "do_mmap". it only handles
89363 * anonymous maps. eventually we may be able to do some
89364 @@ -2582,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89365 struct rb_node ** rb_link, * rb_parent;
89366 pgoff_t pgoff = addr >> PAGE_SHIFT;
89367 int error;
89368 + unsigned long charged;
89369
89370 len = PAGE_ALIGN(len);
89371 if (!len)
89372 @@ -2589,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89373
89374 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
89375
89376 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
89377 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
89378 + flags &= ~VM_EXEC;
89379 +
89380 +#ifdef CONFIG_PAX_MPROTECT
89381 + if (mm->pax_flags & MF_PAX_MPROTECT)
89382 + flags &= ~VM_MAYEXEC;
89383 +#endif
89384 +
89385 + }
89386 +#endif
89387 +
89388 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
89389 if (error & ~PAGE_MASK)
89390 return error;
89391
89392 + charged = len >> PAGE_SHIFT;
89393 +
89394 /*
89395 * mlock MCL_FUTURE?
89396 */
89397 if (mm->def_flags & VM_LOCKED) {
89398 unsigned long locked, lock_limit;
89399 - locked = len >> PAGE_SHIFT;
89400 + locked = charged;
89401 locked += mm->locked_vm;
89402 lock_limit = rlimit(RLIMIT_MEMLOCK);
89403 lock_limit >>= PAGE_SHIFT;
89404 @@ -2615,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89405 /*
89406 * Clear old maps. this also does some error checking for us
89407 */
89408 - munmap_back:
89409 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89410 if (do_munmap(mm, addr, len))
89411 return -ENOMEM;
89412 - goto munmap_back;
89413 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89414 }
89415
89416 /* Check against address space limits *after* clearing old maps... */
89417 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
89418 + if (!may_expand_vm(mm, charged))
89419 return -ENOMEM;
89420
89421 if (mm->map_count > sysctl_max_map_count)
89422 return -ENOMEM;
89423
89424 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
89425 + if (security_vm_enough_memory_mm(mm, charged))
89426 return -ENOMEM;
89427
89428 /* Can we just expand an old private anonymous mapping? */
89429 @@ -2643,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89430 */
89431 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89432 if (!vma) {
89433 - vm_unacct_memory(len >> PAGE_SHIFT);
89434 + vm_unacct_memory(charged);
89435 return -ENOMEM;
89436 }
89437
89438 @@ -2657,10 +3142,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89439 vma_link(mm, vma, prev, rb_link, rb_parent);
89440 out:
89441 perf_event_mmap(vma);
89442 - mm->total_vm += len >> PAGE_SHIFT;
89443 + mm->total_vm += charged;
89444 if (flags & VM_LOCKED)
89445 - mm->locked_vm += (len >> PAGE_SHIFT);
89446 + mm->locked_vm += charged;
89447 vma->vm_flags |= VM_SOFTDIRTY;
89448 + track_exec_limit(mm, addr, addr + len, flags);
89449 return addr;
89450 }
89451
89452 @@ -2722,6 +3208,7 @@ void exit_mmap(struct mm_struct *mm)
89453 while (vma) {
89454 if (vma->vm_flags & VM_ACCOUNT)
89455 nr_accounted += vma_pages(vma);
89456 + vma->vm_mirror = NULL;
89457 vma = remove_vma(vma);
89458 }
89459 vm_unacct_memory(nr_accounted);
89460 @@ -2738,6 +3225,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89461 struct vm_area_struct *prev;
89462 struct rb_node **rb_link, *rb_parent;
89463
89464 +#ifdef CONFIG_PAX_SEGMEXEC
89465 + struct vm_area_struct *vma_m = NULL;
89466 +#endif
89467 +
89468 + if (security_mmap_addr(vma->vm_start))
89469 + return -EPERM;
89470 +
89471 /*
89472 * The vm_pgoff of a purely anonymous vma should be irrelevant
89473 * until its first write fault, when page's anon_vma and index
89474 @@ -2761,7 +3255,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89475 security_vm_enough_memory_mm(mm, vma_pages(vma)))
89476 return -ENOMEM;
89477
89478 +#ifdef CONFIG_PAX_SEGMEXEC
89479 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
89480 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89481 + if (!vma_m)
89482 + return -ENOMEM;
89483 + }
89484 +#endif
89485 +
89486 vma_link(mm, vma, prev, rb_link, rb_parent);
89487 +
89488 +#ifdef CONFIG_PAX_SEGMEXEC
89489 + if (vma_m)
89490 + BUG_ON(pax_mirror_vma(vma_m, vma));
89491 +#endif
89492 +
89493 return 0;
89494 }
89495
89496 @@ -2780,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89497 struct rb_node **rb_link, *rb_parent;
89498 bool faulted_in_anon_vma = true;
89499
89500 + BUG_ON(vma->vm_mirror);
89501 +
89502 /*
89503 * If anonymous vma has not yet been faulted, update new pgoff
89504 * to match new location, to increase its chance of merging.
89505 @@ -2844,6 +3354,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89506 return NULL;
89507 }
89508
89509 +#ifdef CONFIG_PAX_SEGMEXEC
89510 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
89511 +{
89512 + struct vm_area_struct *prev_m;
89513 + struct rb_node **rb_link_m, *rb_parent_m;
89514 + struct mempolicy *pol_m;
89515 +
89516 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
89517 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
89518 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
89519 + *vma_m = *vma;
89520 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
89521 + if (anon_vma_clone(vma_m, vma))
89522 + return -ENOMEM;
89523 + pol_m = vma_policy(vma_m);
89524 + mpol_get(pol_m);
89525 + set_vma_policy(vma_m, pol_m);
89526 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
89527 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
89528 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
89529 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
89530 + if (vma_m->vm_file)
89531 + get_file(vma_m->vm_file);
89532 + if (vma_m->vm_ops && vma_m->vm_ops->open)
89533 + vma_m->vm_ops->open(vma_m);
89534 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
89535 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
89536 + vma_m->vm_mirror = vma;
89537 + vma->vm_mirror = vma_m;
89538 + return 0;
89539 +}
89540 +#endif
89541 +
89542 /*
89543 * Return true if the calling process may expand its vm space by the passed
89544 * number of pages
89545 @@ -2855,6 +3398,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
89546
89547 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
89548
89549 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
89550 if (cur + npages > lim)
89551 return 0;
89552 return 1;
89553 @@ -2925,6 +3469,22 @@ int install_special_mapping(struct mm_struct *mm,
89554 vma->vm_start = addr;
89555 vma->vm_end = addr + len;
89556
89557 +#ifdef CONFIG_PAX_MPROTECT
89558 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89559 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89560 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
89561 + return -EPERM;
89562 + if (!(vm_flags & VM_EXEC))
89563 + vm_flags &= ~VM_MAYEXEC;
89564 +#else
89565 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89566 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89567 +#endif
89568 + else
89569 + vm_flags &= ~VM_MAYWRITE;
89570 + }
89571 +#endif
89572 +
89573 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
89574 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89575
89576 diff --git a/mm/mprotect.c b/mm/mprotect.c
89577 index 412ba2b..cb41d42 100644
89578 --- a/mm/mprotect.c
89579 +++ b/mm/mprotect.c
89580 @@ -23,10 +23,18 @@
89581 #include <linux/mmu_notifier.h>
89582 #include <linux/migrate.h>
89583 #include <linux/perf_event.h>
89584 +#include <linux/sched/sysctl.h>
89585 +
89586 +#ifdef CONFIG_PAX_MPROTECT
89587 +#include <linux/elf.h>
89588 +#include <linux/binfmts.h>
89589 +#endif
89590 +
89591 #include <asm/uaccess.h>
89592 #include <asm/pgtable.h>
89593 #include <asm/cacheflush.h>
89594 #include <asm/tlbflush.h>
89595 +#include <asm/mmu_context.h>
89596
89597 #ifndef pgprot_modify
89598 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
89599 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
89600 return pages;
89601 }
89602
89603 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89604 +/* called while holding the mmap semaphor for writing except stack expansion */
89605 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
89606 +{
89607 + unsigned long oldlimit, newlimit = 0UL;
89608 +
89609 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
89610 + return;
89611 +
89612 + spin_lock(&mm->page_table_lock);
89613 + oldlimit = mm->context.user_cs_limit;
89614 + if ((prot & VM_EXEC) && oldlimit < end)
89615 + /* USER_CS limit moved up */
89616 + newlimit = end;
89617 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
89618 + /* USER_CS limit moved down */
89619 + newlimit = start;
89620 +
89621 + if (newlimit) {
89622 + mm->context.user_cs_limit = newlimit;
89623 +
89624 +#ifdef CONFIG_SMP
89625 + wmb();
89626 + cpus_clear(mm->context.cpu_user_cs_mask);
89627 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
89628 +#endif
89629 +
89630 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
89631 + }
89632 + spin_unlock(&mm->page_table_lock);
89633 + if (newlimit == end) {
89634 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
89635 +
89636 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
89637 + if (is_vm_hugetlb_page(vma))
89638 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
89639 + else
89640 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
89641 + }
89642 +}
89643 +#endif
89644 +
89645 int
89646 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89647 unsigned long start, unsigned long end, unsigned long newflags)
89648 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89649 int error;
89650 int dirty_accountable = 0;
89651
89652 +#ifdef CONFIG_PAX_SEGMEXEC
89653 + struct vm_area_struct *vma_m = NULL;
89654 + unsigned long start_m, end_m;
89655 +
89656 + start_m = start + SEGMEXEC_TASK_SIZE;
89657 + end_m = end + SEGMEXEC_TASK_SIZE;
89658 +#endif
89659 +
89660 if (newflags == oldflags) {
89661 *pprev = vma;
89662 return 0;
89663 }
89664
89665 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
89666 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
89667 +
89668 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
89669 + return -ENOMEM;
89670 +
89671 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
89672 + return -ENOMEM;
89673 + }
89674 +
89675 /*
89676 * If we make a private mapping writable we increase our commit;
89677 * but (without finer accounting) cannot reduce our commit if we
89678 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89679 }
89680 }
89681
89682 +#ifdef CONFIG_PAX_SEGMEXEC
89683 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
89684 + if (start != vma->vm_start) {
89685 + error = split_vma(mm, vma, start, 1);
89686 + if (error)
89687 + goto fail;
89688 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
89689 + *pprev = (*pprev)->vm_next;
89690 + }
89691 +
89692 + if (end != vma->vm_end) {
89693 + error = split_vma(mm, vma, end, 0);
89694 + if (error)
89695 + goto fail;
89696 + }
89697 +
89698 + if (pax_find_mirror_vma(vma)) {
89699 + error = __do_munmap(mm, start_m, end_m - start_m);
89700 + if (error)
89701 + goto fail;
89702 + } else {
89703 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89704 + if (!vma_m) {
89705 + error = -ENOMEM;
89706 + goto fail;
89707 + }
89708 + vma->vm_flags = newflags;
89709 + error = pax_mirror_vma(vma_m, vma);
89710 + if (error) {
89711 + vma->vm_flags = oldflags;
89712 + goto fail;
89713 + }
89714 + }
89715 + }
89716 +#endif
89717 +
89718 /*
89719 * First try to merge with previous and/or next vma.
89720 */
89721 @@ -299,9 +403,21 @@ success:
89722 * vm_flags and vm_page_prot are protected by the mmap_sem
89723 * held in write mode.
89724 */
89725 +
89726 +#ifdef CONFIG_PAX_SEGMEXEC
89727 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
89728 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
89729 +#endif
89730 +
89731 vma->vm_flags = newflags;
89732 +
89733 +#ifdef CONFIG_PAX_MPROTECT
89734 + if (mm->binfmt && mm->binfmt->handle_mprotect)
89735 + mm->binfmt->handle_mprotect(vma, newflags);
89736 +#endif
89737 +
89738 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
89739 - vm_get_page_prot(newflags));
89740 + vm_get_page_prot(vma->vm_flags));
89741
89742 if (vma_wants_writenotify(vma)) {
89743 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
89744 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89745 end = start + len;
89746 if (end <= start)
89747 return -ENOMEM;
89748 +
89749 +#ifdef CONFIG_PAX_SEGMEXEC
89750 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
89751 + if (end > SEGMEXEC_TASK_SIZE)
89752 + return -EINVAL;
89753 + } else
89754 +#endif
89755 +
89756 + if (end > TASK_SIZE)
89757 + return -EINVAL;
89758 +
89759 if (!arch_validate_prot(prot))
89760 return -EINVAL;
89761
89762 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89763 /*
89764 * Does the application expect PROT_READ to imply PROT_EXEC:
89765 */
89766 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89767 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89768 prot |= PROT_EXEC;
89769
89770 vm_flags = calc_vm_prot_bits(prot);
89771 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89772 if (start > vma->vm_start)
89773 prev = vma;
89774
89775 +#ifdef CONFIG_PAX_MPROTECT
89776 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
89777 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
89778 +#endif
89779 +
89780 for (nstart = start ; ; ) {
89781 unsigned long newflags;
89782
89783 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89784
89785 /* newflags >> 4 shift VM_MAY% in place of VM_% */
89786 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
89787 + if (prot & (PROT_WRITE | PROT_EXEC))
89788 + gr_log_rwxmprotect(vma);
89789 +
89790 + error = -EACCES;
89791 + goto out;
89792 + }
89793 +
89794 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
89795 error = -EACCES;
89796 goto out;
89797 }
89798 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89799 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
89800 if (error)
89801 goto out;
89802 +
89803 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
89804 +
89805 nstart = tmp;
89806
89807 if (nstart < prev->vm_end)
89808 diff --git a/mm/mremap.c b/mm/mremap.c
89809 index 0843feb..4f5b2e6 100644
89810 --- a/mm/mremap.c
89811 +++ b/mm/mremap.c
89812 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
89813 continue;
89814 pte = ptep_get_and_clear(mm, old_addr, old_pte);
89815 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
89816 +
89817 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89818 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
89819 + pte = pte_exprotect(pte);
89820 +#endif
89821 +
89822 pte = move_soft_dirty_pte(pte);
89823 set_pte_at(mm, new_addr, new_pte, pte);
89824 }
89825 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
89826 if (is_vm_hugetlb_page(vma))
89827 goto Einval;
89828
89829 +#ifdef CONFIG_PAX_SEGMEXEC
89830 + if (pax_find_mirror_vma(vma))
89831 + goto Einval;
89832 +#endif
89833 +
89834 /* We can't remap across vm area boundaries */
89835 if (old_len > vma->vm_end - addr)
89836 goto Efault;
89837 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
89838 unsigned long ret = -EINVAL;
89839 unsigned long charged = 0;
89840 unsigned long map_flags;
89841 + unsigned long pax_task_size = TASK_SIZE;
89842
89843 if (new_addr & ~PAGE_MASK)
89844 goto out;
89845
89846 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
89847 +#ifdef CONFIG_PAX_SEGMEXEC
89848 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89849 + pax_task_size = SEGMEXEC_TASK_SIZE;
89850 +#endif
89851 +
89852 + pax_task_size -= PAGE_SIZE;
89853 +
89854 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
89855 goto out;
89856
89857 /* Check if the location we're moving into overlaps the
89858 * old location at all, and fail if it does.
89859 */
89860 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
89861 - goto out;
89862 -
89863 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
89864 + if (addr + old_len > new_addr && new_addr + new_len > addr)
89865 goto out;
89866
89867 ret = do_munmap(mm, new_addr, new_len);
89868 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89869 unsigned long ret = -EINVAL;
89870 unsigned long charged = 0;
89871 bool locked = false;
89872 + unsigned long pax_task_size = TASK_SIZE;
89873
89874 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
89875 return ret;
89876 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89877 if (!new_len)
89878 return ret;
89879
89880 +#ifdef CONFIG_PAX_SEGMEXEC
89881 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89882 + pax_task_size = SEGMEXEC_TASK_SIZE;
89883 +#endif
89884 +
89885 + pax_task_size -= PAGE_SIZE;
89886 +
89887 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
89888 + old_len > pax_task_size || addr > pax_task_size-old_len)
89889 + return ret;
89890 +
89891 down_write(&current->mm->mmap_sem);
89892
89893 if (flags & MREMAP_FIXED) {
89894 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89895 new_addr = addr;
89896 }
89897 ret = addr;
89898 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
89899 goto out;
89900 }
89901 }
89902 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89903 goto out;
89904 }
89905
89906 + map_flags = vma->vm_flags;
89907 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
89908 + if (!(ret & ~PAGE_MASK)) {
89909 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
89910 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
89911 + }
89912 }
89913 out:
89914 if (ret & ~PAGE_MASK)
89915 diff --git a/mm/nommu.c b/mm/nommu.c
89916 index ecd1f15..77039bd 100644
89917 --- a/mm/nommu.c
89918 +++ b/mm/nommu.c
89919 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
89920 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
89921 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89922 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89923 -int heap_stack_gap = 0;
89924
89925 atomic_long_t mmap_pages_allocated;
89926
89927 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
89928 EXPORT_SYMBOL(find_vma);
89929
89930 /*
89931 - * find a VMA
89932 - * - we don't extend stack VMAs under NOMMU conditions
89933 - */
89934 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
89935 -{
89936 - return find_vma(mm, addr);
89937 -}
89938 -
89939 -/*
89940 * expand a stack to a given address
89941 * - not supported under NOMMU conditions
89942 */
89943 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89944
89945 /* most fields are the same, copy all, and then fixup */
89946 *new = *vma;
89947 + INIT_LIST_HEAD(&new->anon_vma_chain);
89948 *region = *vma->vm_region;
89949 new->vm_region = region;
89950
89951 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
89952 }
89953 EXPORT_SYMBOL(generic_file_remap_pages);
89954
89955 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89956 - unsigned long addr, void *buf, int len, int write)
89957 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89958 + unsigned long addr, void *buf, size_t len, int write)
89959 {
89960 struct vm_area_struct *vma;
89961
89962 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89963 *
89964 * The caller must hold a reference on @mm.
89965 */
89966 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89967 - void *buf, int len, int write)
89968 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89969 + void *buf, size_t len, int write)
89970 {
89971 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89972 }
89973 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89974 * Access another process' address space.
89975 * - source/target buffer must be kernel space
89976 */
89977 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
89978 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89979 {
89980 struct mm_struct *mm;
89981
89982 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89983 index 6380758..4064aec 100644
89984 --- a/mm/page-writeback.c
89985 +++ b/mm/page-writeback.c
89986 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
89987 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89988 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89989 */
89990 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89991 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89992 unsigned long thresh,
89993 unsigned long bg_thresh,
89994 unsigned long dirty,
89995 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89996 index dd886fa..7686339 100644
89997 --- a/mm/page_alloc.c
89998 +++ b/mm/page_alloc.c
89999 @@ -61,6 +61,7 @@
90000 #include <linux/page-debug-flags.h>
90001 #include <linux/hugetlb.h>
90002 #include <linux/sched/rt.h>
90003 +#include <linux/random.h>
90004
90005 #include <asm/sections.h>
90006 #include <asm/tlbflush.h>
90007 @@ -354,7 +355,7 @@ out:
90008 * This usage means that zero-order pages may not be compound.
90009 */
90010
90011 -static void free_compound_page(struct page *page)
90012 +void free_compound_page(struct page *page)
90013 {
90014 __free_pages_ok(page, compound_order(page));
90015 }
90016 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90017 int i;
90018 int bad = 0;
90019
90020 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90021 + unsigned long index = 1UL << order;
90022 +#endif
90023 +
90024 trace_mm_page_free(page, order);
90025 kmemcheck_free_shadow(page, order);
90026
90027 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90028 debug_check_no_obj_freed(page_address(page),
90029 PAGE_SIZE << order);
90030 }
90031 +
90032 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90033 + for (; index; --index)
90034 + sanitize_highpage(page + index - 1);
90035 +#endif
90036 +
90037 arch_free_page(page, order);
90038 kernel_map_pages(page, 1 << order, 0);
90039
90040 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90041 local_irq_restore(flags);
90042 }
90043
90044 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90045 +bool __meminitdata extra_latent_entropy;
90046 +
90047 +static int __init setup_pax_extra_latent_entropy(char *str)
90048 +{
90049 + extra_latent_entropy = true;
90050 + return 0;
90051 +}
90052 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90053 +
90054 +volatile u64 latent_entropy __latent_entropy;
90055 +EXPORT_SYMBOL(latent_entropy);
90056 +#endif
90057 +
90058 void __init __free_pages_bootmem(struct page *page, unsigned int order)
90059 {
90060 unsigned int nr_pages = 1 << order;
90061 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
90062 __ClearPageReserved(p);
90063 set_page_count(p, 0);
90064
90065 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90066 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90067 + u64 hash = 0;
90068 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90069 + const u64 *data = lowmem_page_address(page);
90070 +
90071 + for (index = 0; index < end; index++)
90072 + hash ^= hash + data[index];
90073 + latent_entropy ^= hash;
90074 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90075 + }
90076 +#endif
90077 +
90078 page_zone(page)->managed_pages += nr_pages;
90079 set_page_refcounted(page);
90080 __free_pages(page, order);
90081 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90082 arch_alloc_page(page, order);
90083 kernel_map_pages(page, 1 << order, 1);
90084
90085 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90086 if (gfp_flags & __GFP_ZERO)
90087 prep_zero_page(page, order, gfp_flags);
90088 +#endif
90089
90090 if (order && (gfp_flags & __GFP_COMP))
90091 prep_compound_page(page, order);
90092 diff --git a/mm/page_io.c b/mm/page_io.c
90093 index 8c79a47..a689e0d 100644
90094 --- a/mm/page_io.c
90095 +++ b/mm/page_io.c
90096 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90097 struct file *swap_file = sis->swap_file;
90098 struct address_space *mapping = swap_file->f_mapping;
90099 struct iovec iov = {
90100 - .iov_base = kmap(page),
90101 + .iov_base = (void __force_user *)kmap(page),
90102 .iov_len = PAGE_SIZE,
90103 };
90104
90105 diff --git a/mm/percpu.c b/mm/percpu.c
90106 index 8c8e08f..73a5cda 100644
90107 --- a/mm/percpu.c
90108 +++ b/mm/percpu.c
90109 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90110 static unsigned int pcpu_high_unit_cpu __read_mostly;
90111
90112 /* the address of the first chunk which starts with the kernel static area */
90113 -void *pcpu_base_addr __read_mostly;
90114 +void *pcpu_base_addr __read_only;
90115 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90116
90117 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90118 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90119 index fd26d04..0cea1b0 100644
90120 --- a/mm/process_vm_access.c
90121 +++ b/mm/process_vm_access.c
90122 @@ -13,6 +13,7 @@
90123 #include <linux/uio.h>
90124 #include <linux/sched.h>
90125 #include <linux/highmem.h>
90126 +#include <linux/security.h>
90127 #include <linux/ptrace.h>
90128 #include <linux/slab.h>
90129 #include <linux/syscalls.h>
90130 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90131 size_t iov_l_curr_offset = 0;
90132 ssize_t iov_len;
90133
90134 + return -ENOSYS; // PaX: until properly audited
90135 +
90136 /*
90137 * Work out how many pages of struct pages we're going to need
90138 * when eventually calling get_user_pages
90139 */
90140 for (i = 0; i < riovcnt; i++) {
90141 iov_len = rvec[i].iov_len;
90142 - if (iov_len > 0) {
90143 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90144 - + iov_len)
90145 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90146 - / PAGE_SIZE + 1;
90147 - nr_pages = max(nr_pages, nr_pages_iov);
90148 - }
90149 + if (iov_len <= 0)
90150 + continue;
90151 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90152 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90153 + nr_pages = max(nr_pages, nr_pages_iov);
90154 }
90155
90156 if (nr_pages == 0)
90157 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90158 goto free_proc_pages;
90159 }
90160
90161 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90162 + rc = -EPERM;
90163 + goto put_task_struct;
90164 + }
90165 +
90166 mm = mm_access(task, PTRACE_MODE_ATTACH);
90167 if (!mm || IS_ERR(mm)) {
90168 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90169 diff --git a/mm/rmap.c b/mm/rmap.c
90170 index fd3ee7a..3613079 100644
90171 --- a/mm/rmap.c
90172 +++ b/mm/rmap.c
90173 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90174 struct anon_vma *anon_vma = vma->anon_vma;
90175 struct anon_vma_chain *avc;
90176
90177 +#ifdef CONFIG_PAX_SEGMEXEC
90178 + struct anon_vma_chain *avc_m = NULL;
90179 +#endif
90180 +
90181 might_sleep();
90182 if (unlikely(!anon_vma)) {
90183 struct mm_struct *mm = vma->vm_mm;
90184 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90185 if (!avc)
90186 goto out_enomem;
90187
90188 +#ifdef CONFIG_PAX_SEGMEXEC
90189 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
90190 + if (!avc_m)
90191 + goto out_enomem_free_avc;
90192 +#endif
90193 +
90194 anon_vma = find_mergeable_anon_vma(vma);
90195 allocated = NULL;
90196 if (!anon_vma) {
90197 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90198 /* page_table_lock to protect against threads */
90199 spin_lock(&mm->page_table_lock);
90200 if (likely(!vma->anon_vma)) {
90201 +
90202 +#ifdef CONFIG_PAX_SEGMEXEC
90203 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
90204 +
90205 + if (vma_m) {
90206 + BUG_ON(vma_m->anon_vma);
90207 + vma_m->anon_vma = anon_vma;
90208 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
90209 + avc_m = NULL;
90210 + }
90211 +#endif
90212 +
90213 vma->anon_vma = anon_vma;
90214 anon_vma_chain_link(vma, avc, anon_vma);
90215 allocated = NULL;
90216 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90217
90218 if (unlikely(allocated))
90219 put_anon_vma(allocated);
90220 +
90221 +#ifdef CONFIG_PAX_SEGMEXEC
90222 + if (unlikely(avc_m))
90223 + anon_vma_chain_free(avc_m);
90224 +#endif
90225 +
90226 if (unlikely(avc))
90227 anon_vma_chain_free(avc);
90228 }
90229 return 0;
90230
90231 out_enomem_free_avc:
90232 +
90233 +#ifdef CONFIG_PAX_SEGMEXEC
90234 + if (avc_m)
90235 + anon_vma_chain_free(avc_m);
90236 +#endif
90237 +
90238 anon_vma_chain_free(avc);
90239 out_enomem:
90240 return -ENOMEM;
90241 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
90242 * Attach the anon_vmas from src to dst.
90243 * Returns 0 on success, -ENOMEM on failure.
90244 */
90245 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90246 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
90247 {
90248 struct anon_vma_chain *avc, *pavc;
90249 struct anon_vma *root = NULL;
90250 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90251 * the corresponding VMA in the parent process is attached to.
90252 * Returns 0 on success, non-zero on failure.
90253 */
90254 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
90255 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
90256 {
90257 struct anon_vma_chain *avc;
90258 struct anon_vma *anon_vma;
90259 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
90260 void __init anon_vma_init(void)
90261 {
90262 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
90263 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
90264 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
90265 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
90266 + anon_vma_ctor);
90267 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
90268 + SLAB_PANIC|SLAB_NO_SANITIZE);
90269 }
90270
90271 /*
90272 diff --git a/mm/shmem.c b/mm/shmem.c
90273 index 8297623..6b9dfe9 100644
90274 --- a/mm/shmem.c
90275 +++ b/mm/shmem.c
90276 @@ -33,7 +33,7 @@
90277 #include <linux/swap.h>
90278 #include <linux/aio.h>
90279
90280 -static struct vfsmount *shm_mnt;
90281 +struct vfsmount *shm_mnt;
90282
90283 #ifdef CONFIG_SHMEM
90284 /*
90285 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
90286 #define BOGO_DIRENT_SIZE 20
90287
90288 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
90289 -#define SHORT_SYMLINK_LEN 128
90290 +#define SHORT_SYMLINK_LEN 64
90291
90292 /*
90293 * shmem_fallocate and shmem_writepage communicate via inode->i_private
90294 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
90295 static int shmem_xattr_validate(const char *name)
90296 {
90297 struct { const char *prefix; size_t len; } arr[] = {
90298 +
90299 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90300 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
90301 +#endif
90302 +
90303 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
90304 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
90305 };
90306 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
90307 if (err)
90308 return err;
90309
90310 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90311 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
90312 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
90313 + return -EOPNOTSUPP;
90314 + if (size > 8)
90315 + return -EINVAL;
90316 + }
90317 +#endif
90318 +
90319 return simple_xattr_set(&info->xattrs, name, value, size, flags);
90320 }
90321
90322 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
90323 int err = -ENOMEM;
90324
90325 /* Round up to L1_CACHE_BYTES to resist false sharing */
90326 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
90327 - L1_CACHE_BYTES), GFP_KERNEL);
90328 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
90329 if (!sbinfo)
90330 return -ENOMEM;
90331
90332 diff --git a/mm/slab.c b/mm/slab.c
90333 index 2580db0..0523956 100644
90334 --- a/mm/slab.c
90335 +++ b/mm/slab.c
90336 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90337 if ((x)->max_freeable < i) \
90338 (x)->max_freeable = i; \
90339 } while (0)
90340 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
90341 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
90342 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
90343 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
90344 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
90345 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
90346 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
90347 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
90348 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
90349 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
90350 #else
90351 #define STATS_INC_ACTIVE(x) do { } while (0)
90352 #define STATS_DEC_ACTIVE(x) do { } while (0)
90353 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90354 #define STATS_INC_ALLOCMISS(x) do { } while (0)
90355 #define STATS_INC_FREEHIT(x) do { } while (0)
90356 #define STATS_INC_FREEMISS(x) do { } while (0)
90357 +#define STATS_INC_SANITIZED(x) do { } while (0)
90358 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
90359 #endif
90360
90361 #if DEBUG
90362 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
90363 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
90364 */
90365 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
90366 - const struct slab *slab, void *obj)
90367 + const struct slab *slab, const void *obj)
90368 {
90369 u32 offset = (obj - slab->s_mem);
90370 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
90371 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
90372 */
90373
90374 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
90375 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
90376 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90377
90378 if (INDEX_AC != INDEX_NODE)
90379 kmalloc_caches[INDEX_NODE] =
90380 create_kmalloc_cache("kmalloc-node",
90381 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
90382 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90383
90384 slab_early_init = 0;
90385
90386 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
90387 struct array_cache *ac = cpu_cache_get(cachep);
90388
90389 check_irq_off();
90390 +
90391 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90392 + if (pax_sanitize_slab) {
90393 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
90394 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
90395 +
90396 + if (cachep->ctor)
90397 + cachep->ctor(objp);
90398 +
90399 + STATS_INC_SANITIZED(cachep);
90400 + } else
90401 + STATS_INC_NOT_SANITIZED(cachep);
90402 + }
90403 +#endif
90404 +
90405 kmemleak_free_recursive(objp, cachep->flags);
90406 objp = cache_free_debugcheck(cachep, objp, caller);
90407
90408 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
90409
90410 if (unlikely(ZERO_OR_NULL_PTR(objp)))
90411 return;
90412 + VM_BUG_ON(!virt_addr_valid(objp));
90413 local_irq_save(flags);
90414 kfree_debugcheck(objp);
90415 c = virt_to_cache(objp);
90416 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
90417 }
90418 /* cpu stats */
90419 {
90420 - unsigned long allochit = atomic_read(&cachep->allochit);
90421 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
90422 - unsigned long freehit = atomic_read(&cachep->freehit);
90423 - unsigned long freemiss = atomic_read(&cachep->freemiss);
90424 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
90425 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
90426 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
90427 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
90428
90429 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
90430 allochit, allocmiss, freehit, freemiss);
90431 }
90432 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90433 + {
90434 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
90435 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
90436 +
90437 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
90438 + }
90439 +#endif
90440 #endif
90441 }
90442
90443 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
90444 static int __init slab_proc_init(void)
90445 {
90446 #ifdef CONFIG_DEBUG_SLAB_LEAK
90447 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
90448 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
90449 #endif
90450 return 0;
90451 }
90452 module_init(slab_proc_init);
90453 #endif
90454
90455 +bool is_usercopy_object(const void *ptr)
90456 +{
90457 + struct page *page;
90458 + struct kmem_cache *cachep;
90459 +
90460 + if (ZERO_OR_NULL_PTR(ptr))
90461 + return false;
90462 +
90463 + if (!slab_is_available())
90464 + return false;
90465 +
90466 + if (!virt_addr_valid(ptr))
90467 + return false;
90468 +
90469 + page = virt_to_head_page(ptr);
90470 +
90471 + if (!PageSlab(page))
90472 + return false;
90473 +
90474 + cachep = page->slab_cache;
90475 + return cachep->flags & SLAB_USERCOPY;
90476 +}
90477 +
90478 +#ifdef CONFIG_PAX_USERCOPY
90479 +const char *check_heap_object(const void *ptr, unsigned long n)
90480 +{
90481 + struct page *page;
90482 + struct kmem_cache *cachep;
90483 + struct slab *slabp;
90484 + unsigned int objnr;
90485 + unsigned long offset;
90486 +
90487 + if (ZERO_OR_NULL_PTR(ptr))
90488 + return "<null>";
90489 +
90490 + if (!virt_addr_valid(ptr))
90491 + return NULL;
90492 +
90493 + page = virt_to_head_page(ptr);
90494 +
90495 + if (!PageSlab(page))
90496 + return NULL;
90497 +
90498 + cachep = page->slab_cache;
90499 + if (!(cachep->flags & SLAB_USERCOPY))
90500 + return cachep->name;
90501 +
90502 + slabp = page->slab_page;
90503 + objnr = obj_to_index(cachep, slabp, ptr);
90504 + BUG_ON(objnr >= cachep->num);
90505 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
90506 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
90507 + return NULL;
90508 +
90509 + return cachep->name;
90510 +}
90511 +#endif
90512 +
90513 /**
90514 * ksize - get the actual amount of memory allocated for a given object
90515 * @objp: Pointer to the object
90516 diff --git a/mm/slab.h b/mm/slab.h
90517 index a535033..2f98fe5 100644
90518 --- a/mm/slab.h
90519 +++ b/mm/slab.h
90520 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
90521 /* The slab cache that manages slab cache information */
90522 extern struct kmem_cache *kmem_cache;
90523
90524 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90525 +#ifdef CONFIG_X86_64
90526 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
90527 +#else
90528 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
90529 +#endif
90530 +extern bool pax_sanitize_slab;
90531 +#endif
90532 +
90533 unsigned long calculate_alignment(unsigned long flags,
90534 unsigned long align, unsigned long size);
90535
90536 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90537
90538 /* Legal flag mask for kmem_cache_create(), for various configurations */
90539 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
90540 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
90541 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
90542 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
90543
90544 #if defined(CONFIG_DEBUG_SLAB)
90545 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
90546 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
90547 return s;
90548
90549 page = virt_to_head_page(x);
90550 +
90551 + BUG_ON(!PageSlab(page));
90552 +
90553 cachep = page->slab_cache;
90554 if (slab_equal_or_root(cachep, s))
90555 return cachep;
90556 diff --git a/mm/slab_common.c b/mm/slab_common.c
90557 index e2e98af..3b1a163 100644
90558 --- a/mm/slab_common.c
90559 +++ b/mm/slab_common.c
90560 @@ -23,11 +23,22 @@
90561
90562 #include "slab.h"
90563
90564 -enum slab_state slab_state;
90565 +enum slab_state slab_state __read_only;
90566 LIST_HEAD(slab_caches);
90567 DEFINE_MUTEX(slab_mutex);
90568 struct kmem_cache *kmem_cache;
90569
90570 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90571 +bool pax_sanitize_slab __read_only = true;
90572 +static int __init pax_sanitize_slab_setup(char *str)
90573 +{
90574 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
90575 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
90576 + return 1;
90577 +}
90578 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
90579 +#endif
90580 +
90581 #ifdef CONFIG_DEBUG_VM
90582 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
90583 size_t size)
90584 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
90585
90586 err = __kmem_cache_create(s, flags);
90587 if (!err) {
90588 - s->refcount = 1;
90589 + atomic_set(&s->refcount, 1);
90590 list_add(&s->list, &slab_caches);
90591 memcg_cache_list_add(memcg, s);
90592 } else {
90593 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
90594
90595 get_online_cpus();
90596 mutex_lock(&slab_mutex);
90597 - s->refcount--;
90598 - if (!s->refcount) {
90599 + if (atomic_dec_and_test(&s->refcount)) {
90600 list_del(&s->list);
90601
90602 if (!__kmem_cache_shutdown(s)) {
90603 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
90604 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
90605 name, size, err);
90606
90607 - s->refcount = -1; /* Exempt from merging for now */
90608 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
90609 }
90610
90611 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90612 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90613
90614 create_boot_cache(s, name, size, flags);
90615 list_add(&s->list, &slab_caches);
90616 - s->refcount = 1;
90617 + atomic_set(&s->refcount, 1);
90618 return s;
90619 }
90620
90621 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
90622 EXPORT_SYMBOL(kmalloc_dma_caches);
90623 #endif
90624
90625 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90626 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
90627 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
90628 +#endif
90629 +
90630 /*
90631 * Conversion table for small slabs sizes / 8 to the index in the
90632 * kmalloc array. This is necessary for slabs < 192 since we have non power
90633 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
90634 return kmalloc_dma_caches[index];
90635
90636 #endif
90637 +
90638 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90639 + if (unlikely((flags & GFP_USERCOPY)))
90640 + return kmalloc_usercopy_caches[index];
90641 +
90642 +#endif
90643 +
90644 return kmalloc_caches[index];
90645 }
90646
90647 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
90648 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
90649 if (!kmalloc_caches[i]) {
90650 kmalloc_caches[i] = create_kmalloc_cache(NULL,
90651 - 1 << i, flags);
90652 + 1 << i, SLAB_USERCOPY | flags);
90653 }
90654
90655 /*
90656 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
90657 * earlier power of two caches
90658 */
90659 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
90660 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
90661 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
90662
90663 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
90664 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
90665 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
90666 }
90667
90668 /* Kmalloc array is now usable */
90669 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
90670 }
90671 }
90672 #endif
90673 +
90674 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90675 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
90676 + struct kmem_cache *s = kmalloc_caches[i];
90677 +
90678 + if (s) {
90679 + int size = kmalloc_size(i);
90680 + char *n = kasprintf(GFP_NOWAIT,
90681 + "usercopy-kmalloc-%d", size);
90682 +
90683 + BUG_ON(!n);
90684 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
90685 + size, SLAB_USERCOPY | flags);
90686 + }
90687 + }
90688 +#endif
90689 +
90690 }
90691 #endif /* !CONFIG_SLOB */
90692
90693 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
90694 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
90695 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
90696 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
90697 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90698 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
90699 +#endif
90700 #endif
90701 seq_putc(m, '\n');
90702 }
90703 diff --git a/mm/slob.c b/mm/slob.c
90704 index 4bf8809..98a6914 100644
90705 --- a/mm/slob.c
90706 +++ b/mm/slob.c
90707 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
90708 /*
90709 * Return the size of a slob block.
90710 */
90711 -static slobidx_t slob_units(slob_t *s)
90712 +static slobidx_t slob_units(const slob_t *s)
90713 {
90714 if (s->units > 0)
90715 return s->units;
90716 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
90717 /*
90718 * Return the next free slob block pointer after this one.
90719 */
90720 -static slob_t *slob_next(slob_t *s)
90721 +static slob_t *slob_next(const slob_t *s)
90722 {
90723 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
90724 slobidx_t next;
90725 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
90726 /*
90727 * Returns true if s is the last free block in its page.
90728 */
90729 -static int slob_last(slob_t *s)
90730 +static int slob_last(const slob_t *s)
90731 {
90732 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
90733 }
90734
90735 -static void *slob_new_pages(gfp_t gfp, int order, int node)
90736 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
90737 {
90738 - void *page;
90739 + struct page *page;
90740
90741 #ifdef CONFIG_NUMA
90742 if (node != NUMA_NO_NODE)
90743 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
90744 if (!page)
90745 return NULL;
90746
90747 - return page_address(page);
90748 + __SetPageSlab(page);
90749 + return page;
90750 }
90751
90752 -static void slob_free_pages(void *b, int order)
90753 +static void slob_free_pages(struct page *sp, int order)
90754 {
90755 if (current->reclaim_state)
90756 current->reclaim_state->reclaimed_slab += 1 << order;
90757 - free_pages((unsigned long)b, order);
90758 + __ClearPageSlab(sp);
90759 + page_mapcount_reset(sp);
90760 + sp->private = 0;
90761 + __free_pages(sp, order);
90762 }
90763
90764 /*
90765 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
90766
90767 /* Not enough space: must allocate a new page */
90768 if (!b) {
90769 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90770 - if (!b)
90771 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90772 + if (!sp)
90773 return NULL;
90774 - sp = virt_to_page(b);
90775 - __SetPageSlab(sp);
90776 + b = page_address(sp);
90777
90778 spin_lock_irqsave(&slob_lock, flags);
90779 sp->units = SLOB_UNITS(PAGE_SIZE);
90780 sp->freelist = b;
90781 + sp->private = 0;
90782 INIT_LIST_HEAD(&sp->list);
90783 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
90784 set_slob_page_free(sp, slob_list);
90785 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
90786 if (slob_page_free(sp))
90787 clear_slob_page_free(sp);
90788 spin_unlock_irqrestore(&slob_lock, flags);
90789 - __ClearPageSlab(sp);
90790 - page_mapcount_reset(sp);
90791 - slob_free_pages(b, 0);
90792 + slob_free_pages(sp, 0);
90793 return;
90794 }
90795
90796 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90797 + if (pax_sanitize_slab)
90798 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
90799 +#endif
90800 +
90801 if (!slob_page_free(sp)) {
90802 /* This slob page is about to become partially free. Easy! */
90803 sp->units = units;
90804 @@ -424,11 +431,10 @@ out:
90805 */
90806
90807 static __always_inline void *
90808 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90809 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
90810 {
90811 - unsigned int *m;
90812 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90813 - void *ret;
90814 + slob_t *m;
90815 + void *ret = NULL;
90816
90817 gfp &= gfp_allowed_mask;
90818
90819 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90820
90821 if (!m)
90822 return NULL;
90823 - *m = size;
90824 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
90825 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
90826 + m[0].units = size;
90827 + m[1].units = align;
90828 ret = (void *)m + align;
90829
90830 trace_kmalloc_node(caller, ret,
90831 size, size + align, gfp, node);
90832 } else {
90833 unsigned int order = get_order(size);
90834 + struct page *page;
90835
90836 if (likely(order))
90837 gfp |= __GFP_COMP;
90838 - ret = slob_new_pages(gfp, order, node);
90839 + page = slob_new_pages(gfp, order, node);
90840 + if (page) {
90841 + ret = page_address(page);
90842 + page->private = size;
90843 + }
90844
90845 trace_kmalloc_node(caller, ret,
90846 size, PAGE_SIZE << order, gfp, node);
90847 }
90848
90849 - kmemleak_alloc(ret, size, 1, gfp);
90850 + return ret;
90851 +}
90852 +
90853 +static __always_inline void *
90854 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90855 +{
90856 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90857 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
90858 +
90859 + if (!ZERO_OR_NULL_PTR(ret))
90860 + kmemleak_alloc(ret, size, 1, gfp);
90861 return ret;
90862 }
90863
90864 @@ -493,34 +517,112 @@ void kfree(const void *block)
90865 return;
90866 kmemleak_free(block);
90867
90868 + VM_BUG_ON(!virt_addr_valid(block));
90869 sp = virt_to_page(block);
90870 - if (PageSlab(sp)) {
90871 + VM_BUG_ON(!PageSlab(sp));
90872 + if (!sp->private) {
90873 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90874 - unsigned int *m = (unsigned int *)(block - align);
90875 - slob_free(m, *m + align);
90876 - } else
90877 + slob_t *m = (slob_t *)(block - align);
90878 + slob_free(m, m[0].units + align);
90879 + } else {
90880 + __ClearPageSlab(sp);
90881 + page_mapcount_reset(sp);
90882 + sp->private = 0;
90883 __free_pages(sp, compound_order(sp));
90884 + }
90885 }
90886 EXPORT_SYMBOL(kfree);
90887
90888 +bool is_usercopy_object(const void *ptr)
90889 +{
90890 + if (!slab_is_available())
90891 + return false;
90892 +
90893 + // PAX: TODO
90894 +
90895 + return false;
90896 +}
90897 +
90898 +#ifdef CONFIG_PAX_USERCOPY
90899 +const char *check_heap_object(const void *ptr, unsigned long n)
90900 +{
90901 + struct page *page;
90902 + const slob_t *free;
90903 + const void *base;
90904 + unsigned long flags;
90905 +
90906 + if (ZERO_OR_NULL_PTR(ptr))
90907 + return "<null>";
90908 +
90909 + if (!virt_addr_valid(ptr))
90910 + return NULL;
90911 +
90912 + page = virt_to_head_page(ptr);
90913 + if (!PageSlab(page))
90914 + return NULL;
90915 +
90916 + if (page->private) {
90917 + base = page;
90918 + if (base <= ptr && n <= page->private - (ptr - base))
90919 + return NULL;
90920 + return "<slob>";
90921 + }
90922 +
90923 + /* some tricky double walking to find the chunk */
90924 + spin_lock_irqsave(&slob_lock, flags);
90925 + base = (void *)((unsigned long)ptr & PAGE_MASK);
90926 + free = page->freelist;
90927 +
90928 + while (!slob_last(free) && (void *)free <= ptr) {
90929 + base = free + slob_units(free);
90930 + free = slob_next(free);
90931 + }
90932 +
90933 + while (base < (void *)free) {
90934 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
90935 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
90936 + int offset;
90937 +
90938 + if (ptr < base + align)
90939 + break;
90940 +
90941 + offset = ptr - base - align;
90942 + if (offset >= m) {
90943 + base += size;
90944 + continue;
90945 + }
90946 +
90947 + if (n > m - offset)
90948 + break;
90949 +
90950 + spin_unlock_irqrestore(&slob_lock, flags);
90951 + return NULL;
90952 + }
90953 +
90954 + spin_unlock_irqrestore(&slob_lock, flags);
90955 + return "<slob>";
90956 +}
90957 +#endif
90958 +
90959 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90960 size_t ksize(const void *block)
90961 {
90962 struct page *sp;
90963 int align;
90964 - unsigned int *m;
90965 + slob_t *m;
90966
90967 BUG_ON(!block);
90968 if (unlikely(block == ZERO_SIZE_PTR))
90969 return 0;
90970
90971 sp = virt_to_page(block);
90972 - if (unlikely(!PageSlab(sp)))
90973 - return PAGE_SIZE << compound_order(sp);
90974 + VM_BUG_ON(!PageSlab(sp));
90975 + if (sp->private)
90976 + return sp->private;
90977
90978 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90979 - m = (unsigned int *)(block - align);
90980 - return SLOB_UNITS(*m) * SLOB_UNIT;
90981 + m = (slob_t *)(block - align);
90982 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90983 }
90984 EXPORT_SYMBOL(ksize);
90985
90986 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90987
90988 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90989 {
90990 - void *b;
90991 + void *b = NULL;
90992
90993 flags &= gfp_allowed_mask;
90994
90995 lockdep_trace_alloc(flags);
90996
90997 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90998 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90999 +#else
91000 if (c->size < PAGE_SIZE) {
91001 b = slob_alloc(c->size, flags, c->align, node);
91002 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91003 SLOB_UNITS(c->size) * SLOB_UNIT,
91004 flags, node);
91005 } else {
91006 - b = slob_new_pages(flags, get_order(c->size), node);
91007 + struct page *sp;
91008 +
91009 + sp = slob_new_pages(flags, get_order(c->size), node);
91010 + if (sp) {
91011 + b = page_address(sp);
91012 + sp->private = c->size;
91013 + }
91014 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91015 PAGE_SIZE << get_order(c->size),
91016 flags, node);
91017 }
91018 +#endif
91019
91020 if (b && c->ctor)
91021 c->ctor(b);
91022 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91023
91024 static void __kmem_cache_free(void *b, int size)
91025 {
91026 - if (size < PAGE_SIZE)
91027 + struct page *sp;
91028 +
91029 + sp = virt_to_page(b);
91030 + BUG_ON(!PageSlab(sp));
91031 + if (!sp->private)
91032 slob_free(b, size);
91033 else
91034 - slob_free_pages(b, get_order(size));
91035 + slob_free_pages(sp, get_order(size));
91036 }
91037
91038 static void kmem_rcu_free(struct rcu_head *head)
91039 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91040
91041 void kmem_cache_free(struct kmem_cache *c, void *b)
91042 {
91043 + int size = c->size;
91044 +
91045 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91046 + if (size + c->align < PAGE_SIZE) {
91047 + size += c->align;
91048 + b -= c->align;
91049 + }
91050 +#endif
91051 +
91052 kmemleak_free_recursive(b, c->flags);
91053 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91054 struct slob_rcu *slob_rcu;
91055 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91056 - slob_rcu->size = c->size;
91057 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91058 + slob_rcu->size = size;
91059 call_rcu(&slob_rcu->head, kmem_rcu_free);
91060 } else {
91061 - __kmem_cache_free(b, c->size);
91062 + __kmem_cache_free(b, size);
91063 }
91064
91065 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91066 + trace_kfree(_RET_IP_, b);
91067 +#else
91068 trace_kmem_cache_free(_RET_IP_, b);
91069 +#endif
91070 +
91071 }
91072 EXPORT_SYMBOL(kmem_cache_free);
91073
91074 diff --git a/mm/slub.c b/mm/slub.c
91075 index 96f2169..9111a59 100644
91076 --- a/mm/slub.c
91077 +++ b/mm/slub.c
91078 @@ -207,7 +207,7 @@ struct track {
91079
91080 enum track_item { TRACK_ALLOC, TRACK_FREE };
91081
91082 -#ifdef CONFIG_SYSFS
91083 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91084 static int sysfs_slab_add(struct kmem_cache *);
91085 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91086 static void sysfs_slab_remove(struct kmem_cache *);
91087 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
91088 if (!t->addr)
91089 return;
91090
91091 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91092 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91093 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91094 #ifdef CONFIG_STACKTRACE
91095 {
91096 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91097
91098 slab_free_hook(s, x);
91099
91100 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91101 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91102 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91103 + if (s->ctor)
91104 + s->ctor(x);
91105 + }
91106 +#endif
91107 +
91108 redo:
91109 /*
91110 * Determine the currently cpus per cpu slab.
91111 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
91112 * Merge control. If this is set then no merging of slab caches will occur.
91113 * (Could be removed. This was introduced to pacify the merge skeptics.)
91114 */
91115 -static int slub_nomerge;
91116 +static int slub_nomerge = 1;
91117
91118 /*
91119 * Calculate the order of allocation given an slab object size.
91120 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91121 s->inuse = size;
91122
91123 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91124 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91125 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91126 +#endif
91127 s->ctor)) {
91128 /*
91129 * Relocate free pointer after the object if it is not
91130 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91131 EXPORT_SYMBOL(__kmalloc_node);
91132 #endif
91133
91134 +bool is_usercopy_object(const void *ptr)
91135 +{
91136 + struct page *page;
91137 + struct kmem_cache *s;
91138 +
91139 + if (ZERO_OR_NULL_PTR(ptr))
91140 + return false;
91141 +
91142 + if (!slab_is_available())
91143 + return false;
91144 +
91145 + if (!virt_addr_valid(ptr))
91146 + return false;
91147 +
91148 + page = virt_to_head_page(ptr);
91149 +
91150 + if (!PageSlab(page))
91151 + return false;
91152 +
91153 + s = page->slab_cache;
91154 + return s->flags & SLAB_USERCOPY;
91155 +}
91156 +
91157 +#ifdef CONFIG_PAX_USERCOPY
91158 +const char *check_heap_object(const void *ptr, unsigned long n)
91159 +{
91160 + struct page *page;
91161 + struct kmem_cache *s;
91162 + unsigned long offset;
91163 +
91164 + if (ZERO_OR_NULL_PTR(ptr))
91165 + return "<null>";
91166 +
91167 + if (!virt_addr_valid(ptr))
91168 + return NULL;
91169 +
91170 + page = virt_to_head_page(ptr);
91171 +
91172 + if (!PageSlab(page))
91173 + return NULL;
91174 +
91175 + s = page->slab_cache;
91176 + if (!(s->flags & SLAB_USERCOPY))
91177 + return s->name;
91178 +
91179 + offset = (ptr - page_address(page)) % s->size;
91180 + if (offset <= s->object_size && n <= s->object_size - offset)
91181 + return NULL;
91182 +
91183 + return s->name;
91184 +}
91185 +#endif
91186 +
91187 size_t ksize(const void *object)
91188 {
91189 struct page *page;
91190 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
91191 if (unlikely(ZERO_OR_NULL_PTR(x)))
91192 return;
91193
91194 + VM_BUG_ON(!virt_addr_valid(x));
91195 page = virt_to_head_page(x);
91196 if (unlikely(!PageSlab(page))) {
91197 BUG_ON(!PageCompound(page));
91198 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
91199 /*
91200 * We may have set a slab to be unmergeable during bootstrap.
91201 */
91202 - if (s->refcount < 0)
91203 + if (atomic_read(&s->refcount) < 0)
91204 return 1;
91205
91206 return 0;
91207 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91208
91209 s = find_mergeable(memcg, size, align, flags, name, ctor);
91210 if (s) {
91211 - s->refcount++;
91212 + atomic_inc(&s->refcount);
91213 /*
91214 * Adjust the object sizes so that we clear
91215 * the complete object on kzalloc.
91216 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91217 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
91218
91219 if (sysfs_slab_alias(s, name)) {
91220 - s->refcount--;
91221 + atomic_dec(&s->refcount);
91222 s = NULL;
91223 }
91224 }
91225 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
91226 }
91227 #endif
91228
91229 -#ifdef CONFIG_SYSFS
91230 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91231 static int count_inuse(struct page *page)
91232 {
91233 return page->inuse;
91234 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
91235 validate_slab_cache(kmalloc_caches[9]);
91236 }
91237 #else
91238 -#ifdef CONFIG_SYSFS
91239 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91240 static void resiliency_test(void) {};
91241 #endif
91242 #endif
91243
91244 -#ifdef CONFIG_SYSFS
91245 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91246 enum slab_stat_type {
91247 SL_ALL, /* All slabs */
91248 SL_PARTIAL, /* Only partially allocated slabs */
91249 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
91250
91251 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
91252 {
91253 - return sprintf(buf, "%d\n", s->refcount - 1);
91254 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
91255 }
91256 SLAB_ATTR_RO(aliases);
91257
91258 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
91259 SLAB_ATTR_RO(cache_dma);
91260 #endif
91261
91262 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91263 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
91264 +{
91265 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
91266 +}
91267 +SLAB_ATTR_RO(usercopy);
91268 +#endif
91269 +
91270 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
91271 {
91272 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
91273 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
91274 #ifdef CONFIG_ZONE_DMA
91275 &cache_dma_attr.attr,
91276 #endif
91277 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91278 + &usercopy_attr.attr,
91279 +#endif
91280 #ifdef CONFIG_NUMA
91281 &remote_node_defrag_ratio_attr.attr,
91282 #endif
91283 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
91284 return name;
91285 }
91286
91287 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91288 static int sysfs_slab_add(struct kmem_cache *s)
91289 {
91290 int err;
91291 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
91292 }
91293
91294 s->kobj.kset = slab_kset;
91295 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
91296 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
91297 if (err) {
91298 kobject_put(&s->kobj);
91299 return err;
91300 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
91301 kobject_del(&s->kobj);
91302 kobject_put(&s->kobj);
91303 }
91304 +#endif
91305
91306 /*
91307 * Need to buffer aliases during bootup until sysfs becomes
91308 @@ -5183,6 +5261,7 @@ struct saved_alias {
91309
91310 static struct saved_alias *alias_list;
91311
91312 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91313 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91314 {
91315 struct saved_alias *al;
91316 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91317 alias_list = al;
91318 return 0;
91319 }
91320 +#endif
91321
91322 static int __init slab_sysfs_init(void)
91323 {
91324 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
91325 index 27eeab3..7c3f7f2 100644
91326 --- a/mm/sparse-vmemmap.c
91327 +++ b/mm/sparse-vmemmap.c
91328 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
91329 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91330 if (!p)
91331 return NULL;
91332 - pud_populate(&init_mm, pud, p);
91333 + pud_populate_kernel(&init_mm, pud, p);
91334 }
91335 return pud;
91336 }
91337 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
91338 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91339 if (!p)
91340 return NULL;
91341 - pgd_populate(&init_mm, pgd, p);
91342 + pgd_populate_kernel(&init_mm, pgd, p);
91343 }
91344 return pgd;
91345 }
91346 diff --git a/mm/sparse.c b/mm/sparse.c
91347 index 4ac1d7e..bbfcb1f 100644
91348 --- a/mm/sparse.c
91349 +++ b/mm/sparse.c
91350 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
91351
91352 for (i = 0; i < PAGES_PER_SECTION; i++) {
91353 if (PageHWPoison(&memmap[i])) {
91354 - atomic_long_sub(1, &num_poisoned_pages);
91355 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
91356 ClearPageHWPoison(&memmap[i]);
91357 }
91358 }
91359 diff --git a/mm/swap.c b/mm/swap.c
91360 index 759c3ca..7c1a5b4 100644
91361 --- a/mm/swap.c
91362 +++ b/mm/swap.c
91363 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
91364
91365 __page_cache_release(page);
91366 dtor = get_compound_page_dtor(page);
91367 + if (!PageHuge(page))
91368 + BUG_ON(dtor != free_compound_page);
91369 (*dtor)(page);
91370 }
91371
91372 diff --git a/mm/swapfile.c b/mm/swapfile.c
91373 index de7c904..c84bf11 100644
91374 --- a/mm/swapfile.c
91375 +++ b/mm/swapfile.c
91376 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
91377
91378 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
91379 /* Activity counter to indicate that a swapon or swapoff has occurred */
91380 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
91381 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
91382
91383 static inline unsigned char swap_count(unsigned char ent)
91384 {
91385 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
91386 }
91387 filp_close(swap_file, NULL);
91388 err = 0;
91389 - atomic_inc(&proc_poll_event);
91390 + atomic_inc_unchecked(&proc_poll_event);
91391 wake_up_interruptible(&proc_poll_wait);
91392
91393 out_dput:
91394 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
91395
91396 poll_wait(file, &proc_poll_wait, wait);
91397
91398 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
91399 - seq->poll_event = atomic_read(&proc_poll_event);
91400 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
91401 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91402 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
91403 }
91404
91405 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
91406 return ret;
91407
91408 seq = file->private_data;
91409 - seq->poll_event = atomic_read(&proc_poll_event);
91410 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91411 return 0;
91412 }
91413
91414 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
91415 (frontswap_map) ? "FS" : "");
91416
91417 mutex_unlock(&swapon_mutex);
91418 - atomic_inc(&proc_poll_event);
91419 + atomic_inc_unchecked(&proc_poll_event);
91420 wake_up_interruptible(&proc_poll_wait);
91421
91422 if (S_ISREG(inode->i_mode))
91423 diff --git a/mm/util.c b/mm/util.c
91424 index eaf63fc2..32b2629 100644
91425 --- a/mm/util.c
91426 +++ b/mm/util.c
91427 @@ -294,6 +294,12 @@ done:
91428 void arch_pick_mmap_layout(struct mm_struct *mm)
91429 {
91430 mm->mmap_base = TASK_UNMAPPED_BASE;
91431 +
91432 +#ifdef CONFIG_PAX_RANDMMAP
91433 + if (mm->pax_flags & MF_PAX_RANDMMAP)
91434 + mm->mmap_base += mm->delta_mmap;
91435 +#endif
91436 +
91437 mm->get_unmapped_area = arch_get_unmapped_area;
91438 }
91439 #endif
91440 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
91441 index 1074543..136dbe0 100644
91442 --- a/mm/vmalloc.c
91443 +++ b/mm/vmalloc.c
91444 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
91445
91446 pte = pte_offset_kernel(pmd, addr);
91447 do {
91448 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91449 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91450 +
91451 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91452 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
91453 + BUG_ON(!pte_exec(*pte));
91454 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
91455 + continue;
91456 + }
91457 +#endif
91458 +
91459 + {
91460 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91461 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91462 + }
91463 } while (pte++, addr += PAGE_SIZE, addr != end);
91464 }
91465
91466 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
91467 pte = pte_alloc_kernel(pmd, addr);
91468 if (!pte)
91469 return -ENOMEM;
91470 +
91471 + pax_open_kernel();
91472 do {
91473 struct page *page = pages[*nr];
91474
91475 - if (WARN_ON(!pte_none(*pte)))
91476 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91477 + if (pgprot_val(prot) & _PAGE_NX)
91478 +#endif
91479 +
91480 + if (!pte_none(*pte)) {
91481 + pax_close_kernel();
91482 + WARN_ON(1);
91483 return -EBUSY;
91484 - if (WARN_ON(!page))
91485 + }
91486 + if (!page) {
91487 + pax_close_kernel();
91488 + WARN_ON(1);
91489 return -ENOMEM;
91490 + }
91491 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
91492 (*nr)++;
91493 } while (pte++, addr += PAGE_SIZE, addr != end);
91494 + pax_close_kernel();
91495 return 0;
91496 }
91497
91498 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
91499 pmd_t *pmd;
91500 unsigned long next;
91501
91502 - pmd = pmd_alloc(&init_mm, pud, addr);
91503 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91504 if (!pmd)
91505 return -ENOMEM;
91506 do {
91507 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
91508 pud_t *pud;
91509 unsigned long next;
91510
91511 - pud = pud_alloc(&init_mm, pgd, addr);
91512 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91513 if (!pud)
91514 return -ENOMEM;
91515 do {
91516 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
91517 if (addr >= MODULES_VADDR && addr < MODULES_END)
91518 return 1;
91519 #endif
91520 +
91521 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91522 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
91523 + return 1;
91524 +#endif
91525 +
91526 return is_vmalloc_addr(x);
91527 }
91528
91529 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
91530
91531 if (!pgd_none(*pgd)) {
91532 pud_t *pud = pud_offset(pgd, addr);
91533 +#ifdef CONFIG_X86
91534 + if (!pud_large(*pud))
91535 +#endif
91536 if (!pud_none(*pud)) {
91537 pmd_t *pmd = pmd_offset(pud, addr);
91538 +#ifdef CONFIG_X86
91539 + if (!pmd_large(*pmd))
91540 +#endif
91541 if (!pmd_none(*pmd)) {
91542 pte_t *ptep, pte;
91543
91544 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
91545 struct vm_struct *area;
91546
91547 BUG_ON(in_interrupt());
91548 +
91549 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91550 + if (flags & VM_KERNEXEC) {
91551 + if (start != VMALLOC_START || end != VMALLOC_END)
91552 + return NULL;
91553 + start = (unsigned long)MODULES_EXEC_VADDR;
91554 + end = (unsigned long)MODULES_EXEC_END;
91555 + }
91556 +#endif
91557 +
91558 if (flags & VM_IOREMAP)
91559 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
91560
91561 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
91562 if (count > totalram_pages)
91563 return NULL;
91564
91565 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91566 + if (!(pgprot_val(prot) & _PAGE_NX))
91567 + flags |= VM_KERNEXEC;
91568 +#endif
91569 +
91570 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
91571 __builtin_return_address(0));
91572 if (!area)
91573 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
91574 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
91575 goto fail;
91576
91577 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91578 + if (!(pgprot_val(prot) & _PAGE_NX))
91579 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
91580 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
91581 + else
91582 +#endif
91583 +
91584 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
91585 start, end, node, gfp_mask, caller);
91586 if (!area)
91587 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
91588 * For tight control over page level allocator and protection flags
91589 * use __vmalloc() instead.
91590 */
91591 -
91592 void *vmalloc_exec(unsigned long size)
91593 {
91594 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
91595 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
91596 NUMA_NO_NODE, __builtin_return_address(0));
91597 }
91598
91599 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
91600 {
91601 struct vm_struct *area;
91602
91603 + BUG_ON(vma->vm_mirror);
91604 +
91605 size = PAGE_ALIGN(size);
91606
91607 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
91608 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
91609 v->addr, v->addr + v->size, v->size);
91610
91611 if (v->caller)
91612 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91613 + seq_printf(m, " %pK", v->caller);
91614 +#else
91615 seq_printf(m, " %pS", v->caller);
91616 +#endif
91617
91618 if (v->nr_pages)
91619 seq_printf(m, " pages=%d", v->nr_pages);
91620 diff --git a/mm/vmstat.c b/mm/vmstat.c
91621 index 9bb3145..98e5f68 100644
91622 --- a/mm/vmstat.c
91623 +++ b/mm/vmstat.c
91624 @@ -79,7 +79,7 @@ void vm_events_fold_cpu(int cpu)
91625 *
91626 * vm_stat contains the global counters
91627 */
91628 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91629 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91630 EXPORT_SYMBOL(vm_stat);
91631
91632 #ifdef CONFIG_SMP
91633 @@ -423,7 +423,7 @@ static inline void fold_diff(int *diff)
91634
91635 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
91636 if (diff[i])
91637 - atomic_long_add(diff[i], &vm_stat[i]);
91638 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
91639 }
91640
91641 /*
91642 @@ -455,7 +455,7 @@ static void refresh_cpu_vm_stats(void)
91643 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
91644 if (v) {
91645
91646 - atomic_long_add(v, &zone->vm_stat[i]);
91647 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91648 global_diff[i] += v;
91649 #ifdef CONFIG_NUMA
91650 /* 3 seconds idle till flush */
91651 @@ -517,7 +517,7 @@ void cpu_vm_stats_fold(int cpu)
91652
91653 v = p->vm_stat_diff[i];
91654 p->vm_stat_diff[i] = 0;
91655 - atomic_long_add(v, &zone->vm_stat[i]);
91656 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91657 global_diff[i] += v;
91658 }
91659 }
91660 @@ -537,8 +537,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
91661 if (pset->vm_stat_diff[i]) {
91662 int v = pset->vm_stat_diff[i];
91663 pset->vm_stat_diff[i] = 0;
91664 - atomic_long_add(v, &zone->vm_stat[i]);
91665 - atomic_long_add(v, &vm_stat[i]);
91666 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91667 + atomic_long_add_unchecked(v, &vm_stat[i]);
91668 }
91669 }
91670 #endif
91671 @@ -1280,10 +1280,20 @@ static int __init setup_vmstat(void)
91672 start_cpu_timer(cpu);
91673 #endif
91674 #ifdef CONFIG_PROC_FS
91675 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
91676 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
91677 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
91678 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
91679 + {
91680 + mode_t gr_mode = S_IRUGO;
91681 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
91682 + gr_mode = S_IRUSR;
91683 +#endif
91684 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
91685 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
91686 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
91687 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
91688 +#else
91689 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
91690 +#endif
91691 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
91692 + }
91693 #endif
91694 return 0;
91695 }
91696 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
91697 index 61fc573..b5e47d0 100644
91698 --- a/net/8021q/vlan.c
91699 +++ b/net/8021q/vlan.c
91700 @@ -472,7 +472,7 @@ out:
91701 return NOTIFY_DONE;
91702 }
91703
91704 -static struct notifier_block vlan_notifier_block __read_mostly = {
91705 +static struct notifier_block vlan_notifier_block = {
91706 .notifier_call = vlan_device_event,
91707 };
91708
91709 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
91710 err = -EPERM;
91711 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
91712 break;
91713 - if ((args.u.name_type >= 0) &&
91714 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
91715 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
91716 struct vlan_net *vn;
91717
91718 vn = net_generic(net, vlan_net_id);
91719 diff --git a/net/9p/mod.c b/net/9p/mod.c
91720 index 6ab36ae..6f1841b 100644
91721 --- a/net/9p/mod.c
91722 +++ b/net/9p/mod.c
91723 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
91724 void v9fs_register_trans(struct p9_trans_module *m)
91725 {
91726 spin_lock(&v9fs_trans_lock);
91727 - list_add_tail(&m->list, &v9fs_trans_list);
91728 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
91729 spin_unlock(&v9fs_trans_lock);
91730 }
91731 EXPORT_SYMBOL(v9fs_register_trans);
91732 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
91733 void v9fs_unregister_trans(struct p9_trans_module *m)
91734 {
91735 spin_lock(&v9fs_trans_lock);
91736 - list_del_init(&m->list);
91737 + pax_list_del_init((struct list_head *)&m->list);
91738 spin_unlock(&v9fs_trans_lock);
91739 }
91740 EXPORT_SYMBOL(v9fs_unregister_trans);
91741 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
91742 index 3ffda1b..fceac96 100644
91743 --- a/net/9p/trans_fd.c
91744 +++ b/net/9p/trans_fd.c
91745 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
91746 oldfs = get_fs();
91747 set_fs(get_ds());
91748 /* The cast to a user pointer is valid due to the set_fs() */
91749 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
91750 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
91751 set_fs(oldfs);
91752
91753 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
91754 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
91755 index 876fbe8..8bbea9f 100644
91756 --- a/net/atm/atm_misc.c
91757 +++ b/net/atm/atm_misc.c
91758 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
91759 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
91760 return 1;
91761 atm_return(vcc, truesize);
91762 - atomic_inc(&vcc->stats->rx_drop);
91763 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91764 return 0;
91765 }
91766 EXPORT_SYMBOL(atm_charge);
91767 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
91768 }
91769 }
91770 atm_return(vcc, guess);
91771 - atomic_inc(&vcc->stats->rx_drop);
91772 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91773 return NULL;
91774 }
91775 EXPORT_SYMBOL(atm_alloc_charge);
91776 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
91777
91778 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91779 {
91780 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91781 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91782 __SONET_ITEMS
91783 #undef __HANDLE_ITEM
91784 }
91785 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
91786
91787 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91788 {
91789 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91790 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
91791 __SONET_ITEMS
91792 #undef __HANDLE_ITEM
91793 }
91794 diff --git a/net/atm/lec.h b/net/atm/lec.h
91795 index 4149db1..f2ab682 100644
91796 --- a/net/atm/lec.h
91797 +++ b/net/atm/lec.h
91798 @@ -48,7 +48,7 @@ struct lane2_ops {
91799 const u8 *tlvs, u32 sizeoftlvs);
91800 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
91801 const u8 *tlvs, u32 sizeoftlvs);
91802 -};
91803 +} __no_const;
91804
91805 /*
91806 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
91807 diff --git a/net/atm/proc.c b/net/atm/proc.c
91808 index bbb6461..cf04016 100644
91809 --- a/net/atm/proc.c
91810 +++ b/net/atm/proc.c
91811 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
91812 const struct k_atm_aal_stats *stats)
91813 {
91814 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
91815 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
91816 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
91817 - atomic_read(&stats->rx_drop));
91818 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
91819 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
91820 + atomic_read_unchecked(&stats->rx_drop));
91821 }
91822
91823 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
91824 diff --git a/net/atm/resources.c b/net/atm/resources.c
91825 index 0447d5d..3cf4728 100644
91826 --- a/net/atm/resources.c
91827 +++ b/net/atm/resources.c
91828 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
91829 static void copy_aal_stats(struct k_atm_aal_stats *from,
91830 struct atm_aal_stats *to)
91831 {
91832 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91833 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91834 __AAL_STAT_ITEMS
91835 #undef __HANDLE_ITEM
91836 }
91837 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
91838 static void subtract_aal_stats(struct k_atm_aal_stats *from,
91839 struct atm_aal_stats *to)
91840 {
91841 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91842 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
91843 __AAL_STAT_ITEMS
91844 #undef __HANDLE_ITEM
91845 }
91846 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
91847 index 919a5ce..cc6b444 100644
91848 --- a/net/ax25/sysctl_net_ax25.c
91849 +++ b/net/ax25/sysctl_net_ax25.c
91850 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
91851 {
91852 char path[sizeof("net/ax25/") + IFNAMSIZ];
91853 int k;
91854 - struct ctl_table *table;
91855 + ctl_table_no_const *table;
91856
91857 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
91858 if (!table)
91859 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
91860 index 0a8a80c..f7e89aa 100644
91861 --- a/net/batman-adv/bat_iv_ogm.c
91862 +++ b/net/batman-adv/bat_iv_ogm.c
91863 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
91864
91865 /* randomize initial seqno to avoid collision */
91866 get_random_bytes(&random_seqno, sizeof(random_seqno));
91867 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91868 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91869
91870 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
91871 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
91872 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
91873 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
91874
91875 /* change sequence number to network order */
91876 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
91877 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
91878 batadv_ogm_packet->seqno = htonl(seqno);
91879 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
91880 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
91881
91882 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
91883 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
91884 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
91885 return;
91886
91887 /* could be changed by schedule_own_packet() */
91888 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
91889 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
91890
91891 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
91892 has_directlink_flag = 1;
91893 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
91894 index c478e6b..469fd2f 100644
91895 --- a/net/batman-adv/hard-interface.c
91896 +++ b/net/batman-adv/hard-interface.c
91897 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
91898 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
91899 dev_add_pack(&hard_iface->batman_adv_ptype);
91900
91901 - atomic_set(&hard_iface->frag_seqno, 1);
91902 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
91903 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
91904 hard_iface->net_dev->name);
91905
91906 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
91907 index 813db4e..847edac 100644
91908 --- a/net/batman-adv/soft-interface.c
91909 +++ b/net/batman-adv/soft-interface.c
91910 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
91911 primary_if->net_dev->dev_addr, ETH_ALEN);
91912
91913 /* set broadcast sequence number */
91914 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
91915 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
91916 bcast_packet->seqno = htonl(seqno);
91917
91918 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
91919 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
91920 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
91921
91922 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
91923 - atomic_set(&bat_priv->bcast_seqno, 1);
91924 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
91925 atomic_set(&bat_priv->tt.vn, 0);
91926 atomic_set(&bat_priv->tt.local_changes, 0);
91927 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
91928 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
91929 index b2c94e1..3d47e07 100644
91930 --- a/net/batman-adv/types.h
91931 +++ b/net/batman-adv/types.h
91932 @@ -51,7 +51,7 @@
91933 struct batadv_hard_iface_bat_iv {
91934 unsigned char *ogm_buff;
91935 int ogm_buff_len;
91936 - atomic_t ogm_seqno;
91937 + atomic_unchecked_t ogm_seqno;
91938 };
91939
91940 /**
91941 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
91942 int16_t if_num;
91943 char if_status;
91944 struct net_device *net_dev;
91945 - atomic_t frag_seqno;
91946 + atomic_unchecked_t frag_seqno;
91947 uint8_t num_bcasts;
91948 struct kobject *hardif_obj;
91949 atomic_t refcount;
91950 @@ -560,7 +560,7 @@ struct batadv_priv {
91951 #ifdef CONFIG_BATMAN_ADV_DEBUG
91952 atomic_t log_level;
91953 #endif
91954 - atomic_t bcast_seqno;
91955 + atomic_unchecked_t bcast_seqno;
91956 atomic_t bcast_queue_left;
91957 atomic_t batman_queue_left;
91958 char num_ifaces;
91959 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91960 index 48b31d3..62a0bcb 100644
91961 --- a/net/batman-adv/unicast.c
91962 +++ b/net/batman-adv/unicast.c
91963 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91964 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91965 frag2->flags = large_tail;
91966
91967 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91968 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91969 frag1->seqno = htons(seqno - 1);
91970 frag2->seqno = htons(seqno);
91971
91972 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91973 index 9bd7d95..6c4884f 100644
91974 --- a/net/bluetooth/hci_sock.c
91975 +++ b/net/bluetooth/hci_sock.c
91976 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91977 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91978 }
91979
91980 - len = min_t(unsigned int, len, sizeof(uf));
91981 + len = min((size_t)len, sizeof(uf));
91982 if (copy_from_user(&uf, optval, len)) {
91983 err = -EFAULT;
91984 break;
91985 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91986 index 63fa111..b166ec6 100644
91987 --- a/net/bluetooth/l2cap_core.c
91988 +++ b/net/bluetooth/l2cap_core.c
91989 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91990 break;
91991
91992 case L2CAP_CONF_RFC:
91993 - if (olen == sizeof(rfc))
91994 - memcpy(&rfc, (void *)val, olen);
91995 + if (olen != sizeof(rfc))
91996 + break;
91997 +
91998 + memcpy(&rfc, (void *)val, olen);
91999
92000 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92001 rfc.mode != chan->mode)
92002 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92003 index 0098af8..fb5a31f 100644
92004 --- a/net/bluetooth/l2cap_sock.c
92005 +++ b/net/bluetooth/l2cap_sock.c
92006 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92007 struct sock *sk = sock->sk;
92008 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92009 struct l2cap_options opts;
92010 - int len, err = 0;
92011 + int err = 0;
92012 + size_t len = optlen;
92013 u32 opt;
92014
92015 BT_DBG("sk %p", sk);
92016 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92017 opts.max_tx = chan->max_tx;
92018 opts.txwin_size = chan->tx_win;
92019
92020 - len = min_t(unsigned int, sizeof(opts), optlen);
92021 + len = min(sizeof(opts), len);
92022 if (copy_from_user((char *) &opts, optval, len)) {
92023 err = -EFAULT;
92024 break;
92025 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92026 struct bt_security sec;
92027 struct bt_power pwr;
92028 struct l2cap_conn *conn;
92029 - int len, err = 0;
92030 + int err = 0;
92031 + size_t len = optlen;
92032 u32 opt;
92033
92034 BT_DBG("sk %p", sk);
92035 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92036
92037 sec.level = BT_SECURITY_LOW;
92038
92039 - len = min_t(unsigned int, sizeof(sec), optlen);
92040 + len = min(sizeof(sec), len);
92041 if (copy_from_user((char *) &sec, optval, len)) {
92042 err = -EFAULT;
92043 break;
92044 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92045
92046 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92047
92048 - len = min_t(unsigned int, sizeof(pwr), optlen);
92049 + len = min(sizeof(pwr), len);
92050 if (copy_from_user((char *) &pwr, optval, len)) {
92051 err = -EFAULT;
92052 break;
92053 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92054 index 30b3721..c1bd0a0 100644
92055 --- a/net/bluetooth/rfcomm/sock.c
92056 +++ b/net/bluetooth/rfcomm/sock.c
92057 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92058 struct sock *sk = sock->sk;
92059 struct bt_security sec;
92060 int err = 0;
92061 - size_t len;
92062 + size_t len = optlen;
92063 u32 opt;
92064
92065 BT_DBG("sk %p", sk);
92066 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92067
92068 sec.level = BT_SECURITY_LOW;
92069
92070 - len = min_t(unsigned int, sizeof(sec), optlen);
92071 + len = min(sizeof(sec), len);
92072 if (copy_from_user((char *) &sec, optval, len)) {
92073 err = -EFAULT;
92074 break;
92075 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92076 index 84fcf9f..e389b27 100644
92077 --- a/net/bluetooth/rfcomm/tty.c
92078 +++ b/net/bluetooth/rfcomm/tty.c
92079 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92080 BT_DBG("tty %p id %d", tty, tty->index);
92081
92082 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92083 - dev->channel, dev->port.count);
92084 + dev->channel, atomic_read(&dev->port.count));
92085
92086 err = tty_port_open(&dev->port, tty, filp);
92087 if (err)
92088 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92089 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
92090
92091 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92092 - dev->port.count);
92093 + atomic_read(&dev->port.count));
92094
92095 tty_port_close(&dev->port, tty, filp);
92096 }
92097 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
92098 index 5180938..7c470c3 100644
92099 --- a/net/bridge/netfilter/ebt_ulog.c
92100 +++ b/net/bridge/netfilter/ebt_ulog.c
92101 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92102 ub->qlen++;
92103
92104 pm = nlmsg_data(nlh);
92105 + memset(pm, 0, sizeof(*pm));
92106
92107 /* Fill in the ulog data */
92108 pm->version = EBT_ULOG_VERSION;
92109 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92110 pm->hook = hooknr;
92111 if (uloginfo->prefix != NULL)
92112 strcpy(pm->prefix, uloginfo->prefix);
92113 - else
92114 - *(pm->prefix) = '\0';
92115
92116 if (in) {
92117 strcpy(pm->physindev, in->name);
92118 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92119 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
92120 else
92121 strcpy(pm->indev, in->name);
92122 - } else
92123 - pm->indev[0] = pm->physindev[0] = '\0';
92124 + }
92125
92126 if (out) {
92127 /* If out exists, then out is a bridge port */
92128 strcpy(pm->physoutdev, out->name);
92129 /* rcu_read_lock()ed by nf_hook_slow */
92130 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
92131 - } else
92132 - pm->outdev[0] = pm->physoutdev[0] = '\0';
92133 + }
92134
92135 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
92136 BUG();
92137 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92138 index ac78024..161a80c 100644
92139 --- a/net/bridge/netfilter/ebtables.c
92140 +++ b/net/bridge/netfilter/ebtables.c
92141 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92142 tmp.valid_hooks = t->table->valid_hooks;
92143 }
92144 mutex_unlock(&ebt_mutex);
92145 - if (copy_to_user(user, &tmp, *len) != 0){
92146 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92147 BUGPRINT("c2u Didn't work\n");
92148 ret = -EFAULT;
92149 break;
92150 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92151 goto out;
92152 tmp.valid_hooks = t->valid_hooks;
92153
92154 - if (copy_to_user(user, &tmp, *len) != 0) {
92155 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92156 ret = -EFAULT;
92157 break;
92158 }
92159 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92160 tmp.entries_size = t->table->entries_size;
92161 tmp.valid_hooks = t->table->valid_hooks;
92162
92163 - if (copy_to_user(user, &tmp, *len) != 0) {
92164 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92165 ret = -EFAULT;
92166 break;
92167 }
92168 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92169 index 0f45522..dab651f 100644
92170 --- a/net/caif/cfctrl.c
92171 +++ b/net/caif/cfctrl.c
92172 @@ -10,6 +10,7 @@
92173 #include <linux/spinlock.h>
92174 #include <linux/slab.h>
92175 #include <linux/pkt_sched.h>
92176 +#include <linux/sched.h>
92177 #include <net/caif/caif_layer.h>
92178 #include <net/caif/cfpkt.h>
92179 #include <net/caif/cfctrl.h>
92180 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92181 memset(&dev_info, 0, sizeof(dev_info));
92182 dev_info.id = 0xff;
92183 cfsrvl_init(&this->serv, 0, &dev_info, false);
92184 - atomic_set(&this->req_seq_no, 1);
92185 - atomic_set(&this->rsp_seq_no, 1);
92186 + atomic_set_unchecked(&this->req_seq_no, 1);
92187 + atomic_set_unchecked(&this->rsp_seq_no, 1);
92188 this->serv.layer.receive = cfctrl_recv;
92189 sprintf(this->serv.layer.name, "ctrl");
92190 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
92191 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
92192 struct cfctrl_request_info *req)
92193 {
92194 spin_lock_bh(&ctrl->info_list_lock);
92195 - atomic_inc(&ctrl->req_seq_no);
92196 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
92197 + atomic_inc_unchecked(&ctrl->req_seq_no);
92198 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
92199 list_add_tail(&req->list, &ctrl->list);
92200 spin_unlock_bh(&ctrl->info_list_lock);
92201 }
92202 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
92203 if (p != first)
92204 pr_warn("Requests are not received in order\n");
92205
92206 - atomic_set(&ctrl->rsp_seq_no,
92207 + atomic_set_unchecked(&ctrl->rsp_seq_no,
92208 p->sequence_no);
92209 list_del(&p->list);
92210 goto out;
92211 diff --git a/net/can/af_can.c b/net/can/af_can.c
92212 index 3ab8dd2..b9aef13 100644
92213 --- a/net/can/af_can.c
92214 +++ b/net/can/af_can.c
92215 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
92216 };
92217
92218 /* notifier block for netdevice event */
92219 -static struct notifier_block can_netdev_notifier __read_mostly = {
92220 +static struct notifier_block can_netdev_notifier = {
92221 .notifier_call = can_notifier,
92222 };
92223
92224 diff --git a/net/can/gw.c b/net/can/gw.c
92225 index 3f9b0f3..fc6d4fa 100644
92226 --- a/net/can/gw.c
92227 +++ b/net/can/gw.c
92228 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
92229 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
92230
92231 static HLIST_HEAD(cgw_list);
92232 -static struct notifier_block notifier;
92233
92234 static struct kmem_cache *cgw_cache __read_mostly;
92235
92236 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
92237 return err;
92238 }
92239
92240 +static struct notifier_block notifier = {
92241 + .notifier_call = cgw_notifier
92242 +};
92243 +
92244 static __init int cgw_module_init(void)
92245 {
92246 /* sanitize given module parameter */
92247 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
92248 return -ENOMEM;
92249
92250 /* set notifier */
92251 - notifier.notifier_call = cgw_notifier;
92252 register_netdevice_notifier(&notifier);
92253
92254 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
92255 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
92256 index 4a5df7b..9ad1f1d 100644
92257 --- a/net/ceph/messenger.c
92258 +++ b/net/ceph/messenger.c
92259 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
92260 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
92261
92262 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
92263 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
92264 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
92265
92266 static struct page *zero_page; /* used in certain error cases */
92267
92268 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
92269 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
92270 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
92271
92272 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92273 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92274 s = addr_str[i];
92275
92276 switch (ss->ss_family) {
92277 diff --git a/net/compat.c b/net/compat.c
92278 index 8903258..24e30e5 100644
92279 --- a/net/compat.c
92280 +++ b/net/compat.c
92281 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
92282 return -EFAULT;
92283 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
92284 return -EINVAL;
92285 - kmsg->msg_name = compat_ptr(tmp1);
92286 - kmsg->msg_iov = compat_ptr(tmp2);
92287 - kmsg->msg_control = compat_ptr(tmp3);
92288 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
92289 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
92290 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
92291 return 0;
92292 }
92293
92294 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92295
92296 if (kern_msg->msg_namelen) {
92297 if (mode == VERIFY_READ) {
92298 - int err = move_addr_to_kernel(kern_msg->msg_name,
92299 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
92300 kern_msg->msg_namelen,
92301 kern_address);
92302 if (err < 0)
92303 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92304 kern_msg->msg_name = NULL;
92305
92306 tot_len = iov_from_user_compat_to_kern(kern_iov,
92307 - (struct compat_iovec __user *)kern_msg->msg_iov,
92308 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
92309 kern_msg->msg_iovlen);
92310 if (tot_len >= 0)
92311 kern_msg->msg_iov = kern_iov;
92312 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92313
92314 #define CMSG_COMPAT_FIRSTHDR(msg) \
92315 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
92316 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
92317 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
92318 (struct compat_cmsghdr __user *)NULL)
92319
92320 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
92321 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
92322 (ucmlen) <= (unsigned long) \
92323 ((mhdr)->msg_controllen - \
92324 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
92325 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
92326
92327 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
92328 struct compat_cmsghdr __user *cmsg, int cmsg_len)
92329 {
92330 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
92331 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
92332 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
92333 msg->msg_controllen)
92334 return NULL;
92335 return (struct compat_cmsghdr __user *)ptr;
92336 @@ -221,7 +221,7 @@ Efault:
92337
92338 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
92339 {
92340 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92341 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92342 struct compat_cmsghdr cmhdr;
92343 struct compat_timeval ctv;
92344 struct compat_timespec cts[3];
92345 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
92346
92347 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
92348 {
92349 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92350 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92351 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
92352 int fdnum = scm->fp->count;
92353 struct file **fp = scm->fp->fp;
92354 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
92355 return -EFAULT;
92356 old_fs = get_fs();
92357 set_fs(KERNEL_DS);
92358 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
92359 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
92360 set_fs(old_fs);
92361
92362 return err;
92363 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
92364 len = sizeof(ktime);
92365 old_fs = get_fs();
92366 set_fs(KERNEL_DS);
92367 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
92368 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
92369 set_fs(old_fs);
92370
92371 if (!err) {
92372 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92373 case MCAST_JOIN_GROUP:
92374 case MCAST_LEAVE_GROUP:
92375 {
92376 - struct compat_group_req __user *gr32 = (void *)optval;
92377 + struct compat_group_req __user *gr32 = (void __user *)optval;
92378 struct group_req __user *kgr =
92379 compat_alloc_user_space(sizeof(struct group_req));
92380 u32 interface;
92381 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92382 case MCAST_BLOCK_SOURCE:
92383 case MCAST_UNBLOCK_SOURCE:
92384 {
92385 - struct compat_group_source_req __user *gsr32 = (void *)optval;
92386 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
92387 struct group_source_req __user *kgsr = compat_alloc_user_space(
92388 sizeof(struct group_source_req));
92389 u32 interface;
92390 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92391 }
92392 case MCAST_MSFILTER:
92393 {
92394 - struct compat_group_filter __user *gf32 = (void *)optval;
92395 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92396 struct group_filter __user *kgf;
92397 u32 interface, fmode, numsrc;
92398
92399 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
92400 char __user *optval, int __user *optlen,
92401 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
92402 {
92403 - struct compat_group_filter __user *gf32 = (void *)optval;
92404 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92405 struct group_filter __user *kgf;
92406 int __user *koptlen;
92407 u32 interface, fmode, numsrc;
92408 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
92409
92410 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
92411 return -EINVAL;
92412 - if (copy_from_user(a, args, nas[call]))
92413 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
92414 return -EFAULT;
92415 a0 = a[0];
92416 a1 = a[1];
92417 diff --git a/net/core/datagram.c b/net/core/datagram.c
92418 index af814e7..3d761de 100644
92419 --- a/net/core/datagram.c
92420 +++ b/net/core/datagram.c
92421 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
92422 }
92423
92424 kfree_skb(skb);
92425 - atomic_inc(&sk->sk_drops);
92426 + atomic_inc_unchecked(&sk->sk_drops);
92427 sk_mem_reclaim_partial(sk);
92428
92429 return err;
92430 diff --git a/net/core/dev.c b/net/core/dev.c
92431 index 3430b1e..d6453ad 100644
92432 --- a/net/core/dev.c
92433 +++ b/net/core/dev.c
92434 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
92435 {
92436 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
92437 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
92438 - atomic_long_inc(&dev->rx_dropped);
92439 + atomic_long_inc_unchecked(&dev->rx_dropped);
92440 kfree_skb(skb);
92441 return NET_RX_DROP;
92442 }
92443 }
92444
92445 if (unlikely(!is_skb_forwardable(dev, skb))) {
92446 - atomic_long_inc(&dev->rx_dropped);
92447 + atomic_long_inc_unchecked(&dev->rx_dropped);
92448 kfree_skb(skb);
92449 return NET_RX_DROP;
92450 }
92451 @@ -2432,7 +2432,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
92452
92453 struct dev_gso_cb {
92454 void (*destructor)(struct sk_buff *skb);
92455 -};
92456 +} __no_const;
92457
92458 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
92459
92460 @@ -3207,7 +3207,7 @@ enqueue:
92461
92462 local_irq_restore(flags);
92463
92464 - atomic_long_inc(&skb->dev->rx_dropped);
92465 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92466 kfree_skb(skb);
92467 return NET_RX_DROP;
92468 }
92469 @@ -3279,7 +3279,7 @@ int netif_rx_ni(struct sk_buff *skb)
92470 }
92471 EXPORT_SYMBOL(netif_rx_ni);
92472
92473 -static void net_tx_action(struct softirq_action *h)
92474 +static __latent_entropy void net_tx_action(void)
92475 {
92476 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92477
92478 @@ -3613,7 +3613,7 @@ ncls:
92479 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
92480 } else {
92481 drop:
92482 - atomic_long_inc(&skb->dev->rx_dropped);
92483 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92484 kfree_skb(skb);
92485 /* Jamal, now you will not able to escape explaining
92486 * me how you were going to use this. :-)
92487 @@ -4273,7 +4273,7 @@ void netif_napi_del(struct napi_struct *napi)
92488 }
92489 EXPORT_SYMBOL(netif_napi_del);
92490
92491 -static void net_rx_action(struct softirq_action *h)
92492 +static __latent_entropy void net_rx_action(void)
92493 {
92494 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92495 unsigned long time_limit = jiffies + 2;
92496 @@ -5977,7 +5977,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
92497 } else {
92498 netdev_stats_to_stats64(storage, &dev->stats);
92499 }
92500 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
92501 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
92502 return storage;
92503 }
92504 EXPORT_SYMBOL(dev_get_stats);
92505 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
92506 index 5b7d0e1..cb960fc 100644
92507 --- a/net/core/dev_ioctl.c
92508 +++ b/net/core/dev_ioctl.c
92509 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
92510 if (no_module && capable(CAP_NET_ADMIN))
92511 no_module = request_module("netdev-%s", name);
92512 if (no_module && capable(CAP_SYS_MODULE)) {
92513 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
92514 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
92515 +#else
92516 if (!request_module("%s", name))
92517 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
92518 name);
92519 +#endif
92520 }
92521 }
92522 EXPORT_SYMBOL(dev_load);
92523 diff --git a/net/core/flow.c b/net/core/flow.c
92524 index dfa602c..3103d88 100644
92525 --- a/net/core/flow.c
92526 +++ b/net/core/flow.c
92527 @@ -61,7 +61,7 @@ struct flow_cache {
92528 struct timer_list rnd_timer;
92529 };
92530
92531 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
92532 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
92533 EXPORT_SYMBOL(flow_cache_genid);
92534 static struct flow_cache flow_cache_global;
92535 static struct kmem_cache *flow_cachep __read_mostly;
92536 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
92537
92538 static int flow_entry_valid(struct flow_cache_entry *fle)
92539 {
92540 - if (atomic_read(&flow_cache_genid) != fle->genid)
92541 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
92542 return 0;
92543 if (fle->object && !fle->object->ops->check(fle->object))
92544 return 0;
92545 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
92546 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
92547 fcp->hash_count++;
92548 }
92549 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
92550 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
92551 flo = fle->object;
92552 if (!flo)
92553 goto ret_object;
92554 @@ -279,7 +279,7 @@ nocache:
92555 }
92556 flo = resolver(net, key, family, dir, flo, ctx);
92557 if (fle) {
92558 - fle->genid = atomic_read(&flow_cache_genid);
92559 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
92560 if (!IS_ERR(flo))
92561 fle->object = flo;
92562 else
92563 diff --git a/net/core/iovec.c b/net/core/iovec.c
92564 index b77eeec..2890aca 100644
92565 --- a/net/core/iovec.c
92566 +++ b/net/core/iovec.c
92567 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92568 if (m->msg_namelen) {
92569 if (mode == VERIFY_READ) {
92570 void __user *namep;
92571 - namep = (void __user __force *) m->msg_name;
92572 + namep = (void __force_user *) m->msg_name;
92573 err = move_addr_to_kernel(namep, m->msg_namelen,
92574 address);
92575 if (err < 0)
92576 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92577 }
92578
92579 size = m->msg_iovlen * sizeof(struct iovec);
92580 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
92581 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
92582 return -EFAULT;
92583
92584 m->msg_iov = iov;
92585 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
92586 index 6072610..7374c18 100644
92587 --- a/net/core/neighbour.c
92588 +++ b/net/core/neighbour.c
92589 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
92590 void __user *buffer, size_t *lenp, loff_t *ppos)
92591 {
92592 int size, ret;
92593 - struct ctl_table tmp = *ctl;
92594 + ctl_table_no_const tmp = *ctl;
92595
92596 tmp.extra1 = &zero;
92597 tmp.extra2 = &unres_qlen_max;
92598 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
92599 index 2bf8329..7960607 100644
92600 --- a/net/core/net-procfs.c
92601 +++ b/net/core/net-procfs.c
92602 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
92603 else
92604 seq_printf(seq, "%04x", ntohs(pt->type));
92605
92606 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92607 + seq_printf(seq, " %-8s %pf\n",
92608 + pt->dev ? pt->dev->name : "", NULL);
92609 +#else
92610 seq_printf(seq, " %-8s %pf\n",
92611 pt->dev ? pt->dev->name : "", pt->func);
92612 +#endif
92613 }
92614
92615 return 0;
92616 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
92617 index d954b56..b0a0f7a 100644
92618 --- a/net/core/net-sysfs.c
92619 +++ b/net/core/net-sysfs.c
92620 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
92621 }
92622 EXPORT_SYMBOL(netdev_class_remove_file);
92623
92624 -int netdev_kobject_init(void)
92625 +int __init netdev_kobject_init(void)
92626 {
92627 kobj_ns_type_register(&net_ns_type_operations);
92628 return class_register(&net_class);
92629 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
92630 index 81d3a9a..a0bd7a8 100644
92631 --- a/net/core/net_namespace.c
92632 +++ b/net/core/net_namespace.c
92633 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
92634 int error;
92635 LIST_HEAD(net_exit_list);
92636
92637 - list_add_tail(&ops->list, list);
92638 + pax_list_add_tail((struct list_head *)&ops->list, list);
92639 if (ops->init || (ops->id && ops->size)) {
92640 for_each_net(net) {
92641 error = ops_init(ops, net);
92642 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
92643
92644 out_undo:
92645 /* If I have an error cleanup all namespaces I initialized */
92646 - list_del(&ops->list);
92647 + pax_list_del((struct list_head *)&ops->list);
92648 ops_exit_list(ops, &net_exit_list);
92649 ops_free_list(ops, &net_exit_list);
92650 return error;
92651 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
92652 struct net *net;
92653 LIST_HEAD(net_exit_list);
92654
92655 - list_del(&ops->list);
92656 + pax_list_del((struct list_head *)&ops->list);
92657 for_each_net(net)
92658 list_add_tail(&net->exit_list, &net_exit_list);
92659 ops_exit_list(ops, &net_exit_list);
92660 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
92661 mutex_lock(&net_mutex);
92662 error = register_pernet_operations(&pernet_list, ops);
92663 if (!error && (first_device == &pernet_list))
92664 - first_device = &ops->list;
92665 + first_device = (struct list_head *)&ops->list;
92666 mutex_unlock(&net_mutex);
92667 return error;
92668 }
92669 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
92670 index fc75c9e..8c8e9be 100644
92671 --- a/net/core/netpoll.c
92672 +++ b/net/core/netpoll.c
92673 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92674 struct udphdr *udph;
92675 struct iphdr *iph;
92676 struct ethhdr *eth;
92677 - static atomic_t ip_ident;
92678 + static atomic_unchecked_t ip_ident;
92679 struct ipv6hdr *ip6h;
92680
92681 udp_len = len + sizeof(*udph);
92682 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92683 put_unaligned(0x45, (unsigned char *)iph);
92684 iph->tos = 0;
92685 put_unaligned(htons(ip_len), &(iph->tot_len));
92686 - iph->id = htons(atomic_inc_return(&ip_ident));
92687 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
92688 iph->frag_off = 0;
92689 iph->ttl = 64;
92690 iph->protocol = IPPROTO_UDP;
92691 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
92692 index 2a0e21d..6ad7642 100644
92693 --- a/net/core/rtnetlink.c
92694 +++ b/net/core/rtnetlink.c
92695 @@ -58,7 +58,7 @@ struct rtnl_link {
92696 rtnl_doit_func doit;
92697 rtnl_dumpit_func dumpit;
92698 rtnl_calcit_func calcit;
92699 -};
92700 +} __no_const;
92701
92702 static DEFINE_MUTEX(rtnl_mutex);
92703
92704 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
92705 if (rtnl_link_ops_get(ops->kind))
92706 return -EEXIST;
92707
92708 - if (!ops->dellink)
92709 - ops->dellink = unregister_netdevice_queue;
92710 + if (!ops->dellink) {
92711 + pax_open_kernel();
92712 + *(void **)&ops->dellink = unregister_netdevice_queue;
92713 + pax_close_kernel();
92714 + }
92715
92716 - list_add_tail(&ops->list, &link_ops);
92717 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
92718 return 0;
92719 }
92720 EXPORT_SYMBOL_GPL(__rtnl_link_register);
92721 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
92722 for_each_net(net) {
92723 __rtnl_kill_links(net, ops);
92724 }
92725 - list_del(&ops->list);
92726 + pax_list_del((struct list_head *)&ops->list);
92727 }
92728 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
92729
92730 diff --git a/net/core/scm.c b/net/core/scm.c
92731 index b442e7e..6f5b5a2 100644
92732 --- a/net/core/scm.c
92733 +++ b/net/core/scm.c
92734 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
92735 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92736 {
92737 struct cmsghdr __user *cm
92738 - = (__force struct cmsghdr __user *)msg->msg_control;
92739 + = (struct cmsghdr __force_user *)msg->msg_control;
92740 struct cmsghdr cmhdr;
92741 int cmlen = CMSG_LEN(len);
92742 int err;
92743 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92744 err = -EFAULT;
92745 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
92746 goto out;
92747 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
92748 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
92749 goto out;
92750 cmlen = CMSG_SPACE(len);
92751 if (msg->msg_controllen < cmlen)
92752 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
92753 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92754 {
92755 struct cmsghdr __user *cm
92756 - = (__force struct cmsghdr __user*)msg->msg_control;
92757 + = (struct cmsghdr __force_user *)msg->msg_control;
92758
92759 int fdmax = 0;
92760 int fdnum = scm->fp->count;
92761 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92762 if (fdnum < fdmax)
92763 fdmax = fdnum;
92764
92765 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
92766 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
92767 i++, cmfptr++)
92768 {
92769 struct socket *sock;
92770 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
92771 index d81cff1..e31f952 100644
92772 --- a/net/core/skbuff.c
92773 +++ b/net/core/skbuff.c
92774 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
92775 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
92776 sizeof(struct sk_buff),
92777 0,
92778 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92779 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92780 + SLAB_NO_SANITIZE,
92781 NULL);
92782 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
92783 (2*sizeof(struct sk_buff)) +
92784 sizeof(atomic_t),
92785 0,
92786 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92787 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92788 + SLAB_NO_SANITIZE,
92789 NULL);
92790 }
92791
92792 diff --git a/net/core/sock.c b/net/core/sock.c
92793 index 0b39e7a..5e9f91e 100644
92794 --- a/net/core/sock.c
92795 +++ b/net/core/sock.c
92796 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92797 struct sk_buff_head *list = &sk->sk_receive_queue;
92798
92799 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
92800 - atomic_inc(&sk->sk_drops);
92801 + atomic_inc_unchecked(&sk->sk_drops);
92802 trace_sock_rcvqueue_full(sk, skb);
92803 return -ENOMEM;
92804 }
92805 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92806 return err;
92807
92808 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
92809 - atomic_inc(&sk->sk_drops);
92810 + atomic_inc_unchecked(&sk->sk_drops);
92811 return -ENOBUFS;
92812 }
92813
92814 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92815 skb_dst_force(skb);
92816
92817 spin_lock_irqsave(&list->lock, flags);
92818 - skb->dropcount = atomic_read(&sk->sk_drops);
92819 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
92820 __skb_queue_tail(list, skb);
92821 spin_unlock_irqrestore(&list->lock, flags);
92822
92823 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92824 skb->dev = NULL;
92825
92826 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
92827 - atomic_inc(&sk->sk_drops);
92828 + atomic_inc_unchecked(&sk->sk_drops);
92829 goto discard_and_relse;
92830 }
92831 if (nested)
92832 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92833 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
92834 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
92835 bh_unlock_sock(sk);
92836 - atomic_inc(&sk->sk_drops);
92837 + atomic_inc_unchecked(&sk->sk_drops);
92838 goto discard_and_relse;
92839 }
92840
92841 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92842 struct timeval tm;
92843 } v;
92844
92845 - int lv = sizeof(int);
92846 - int len;
92847 + unsigned int lv = sizeof(int);
92848 + unsigned int len;
92849
92850 if (get_user(len, optlen))
92851 return -EFAULT;
92852 - if (len < 0)
92853 + if (len > INT_MAX)
92854 return -EINVAL;
92855
92856 memset(&v, 0, sizeof(v));
92857 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92858
92859 case SO_PEERNAME:
92860 {
92861 - char address[128];
92862 + char address[_K_SS_MAXSIZE];
92863
92864 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
92865 return -ENOTCONN;
92866 - if (lv < len)
92867 + if (lv < len || sizeof address < len)
92868 return -EINVAL;
92869 if (copy_to_user(optval, address, len))
92870 return -EFAULT;
92871 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92872
92873 if (len > lv)
92874 len = lv;
92875 - if (copy_to_user(optval, &v, len))
92876 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
92877 return -EFAULT;
92878 lenout:
92879 if (put_user(len, optlen))
92880 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
92881 */
92882 smp_wmb();
92883 atomic_set(&sk->sk_refcnt, 1);
92884 - atomic_set(&sk->sk_drops, 0);
92885 + atomic_set_unchecked(&sk->sk_drops, 0);
92886 }
92887 EXPORT_SYMBOL(sock_init_data);
92888
92889 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
92890 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
92891 int level, int type)
92892 {
92893 + struct sock_extended_err ee;
92894 struct sock_exterr_skb *serr;
92895 struct sk_buff *skb, *skb2;
92896 int copied, err;
92897 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
92898 sock_recv_timestamp(msg, sk, skb);
92899
92900 serr = SKB_EXT_ERR(skb);
92901 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
92902 + ee = serr->ee;
92903 + put_cmsg(msg, level, type, sizeof ee, &ee);
92904
92905 msg->msg_flags |= MSG_ERRQUEUE;
92906 err = copied;
92907 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
92908 index a0e9cf6..ef7f9ed 100644
92909 --- a/net/core/sock_diag.c
92910 +++ b/net/core/sock_diag.c
92911 @@ -9,26 +9,33 @@
92912 #include <linux/inet_diag.h>
92913 #include <linux/sock_diag.h>
92914
92915 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
92916 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
92917 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
92918 static DEFINE_MUTEX(sock_diag_table_mutex);
92919
92920 int sock_diag_check_cookie(void *sk, __u32 *cookie)
92921 {
92922 +#ifndef CONFIG_GRKERNSEC_HIDESYM
92923 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
92924 cookie[1] != INET_DIAG_NOCOOKIE) &&
92925 ((u32)(unsigned long)sk != cookie[0] ||
92926 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
92927 return -ESTALE;
92928 else
92929 +#endif
92930 return 0;
92931 }
92932 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
92933
92934 void sock_diag_save_cookie(void *sk, __u32 *cookie)
92935 {
92936 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92937 + cookie[0] = 0;
92938 + cookie[1] = 0;
92939 +#else
92940 cookie[0] = (u32)(unsigned long)sk;
92941 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
92942 +#endif
92943 }
92944 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
92945
92946 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
92947 mutex_lock(&sock_diag_table_mutex);
92948 if (sock_diag_handlers[hndl->family])
92949 err = -EBUSY;
92950 - else
92951 + else {
92952 + pax_open_kernel();
92953 sock_diag_handlers[hndl->family] = hndl;
92954 + pax_close_kernel();
92955 + }
92956 mutex_unlock(&sock_diag_table_mutex);
92957
92958 return err;
92959 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92960
92961 mutex_lock(&sock_diag_table_mutex);
92962 BUG_ON(sock_diag_handlers[family] != hnld);
92963 + pax_open_kernel();
92964 sock_diag_handlers[family] = NULL;
92965 + pax_close_kernel();
92966 mutex_unlock(&sock_diag_table_mutex);
92967 }
92968 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92969 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92970 index cca4441..5e616de 100644
92971 --- a/net/core/sysctl_net_core.c
92972 +++ b/net/core/sysctl_net_core.c
92973 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92974 {
92975 unsigned int orig_size, size;
92976 int ret, i;
92977 - struct ctl_table tmp = {
92978 + ctl_table_no_const tmp = {
92979 .data = &size,
92980 .maxlen = sizeof(size),
92981 .mode = table->mode
92982 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
92983 void __user *buffer, size_t *lenp, loff_t *ppos)
92984 {
92985 char id[IFNAMSIZ];
92986 - struct ctl_table tbl = {
92987 + ctl_table_no_const tbl = {
92988 .data = id,
92989 .maxlen = IFNAMSIZ,
92990 };
92991 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
92992
92993 static __net_init int sysctl_core_net_init(struct net *net)
92994 {
92995 - struct ctl_table *tbl;
92996 + ctl_table_no_const *tbl = NULL;
92997
92998 net->core.sysctl_somaxconn = SOMAXCONN;
92999
93000 - tbl = netns_core_table;
93001 if (!net_eq(net, &init_net)) {
93002 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93003 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93004 if (tbl == NULL)
93005 goto err_dup;
93006
93007 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93008 if (net->user_ns != &init_user_ns) {
93009 tbl[0].procname = NULL;
93010 }
93011 - }
93012 -
93013 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93014 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93015 + } else
93016 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93017 if (net->core.sysctl_hdr == NULL)
93018 goto err_reg;
93019
93020 return 0;
93021
93022 err_reg:
93023 - if (tbl != netns_core_table)
93024 - kfree(tbl);
93025 + kfree(tbl);
93026 err_dup:
93027 return -ENOMEM;
93028 }
93029 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93030 kfree(tbl);
93031 }
93032
93033 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93034 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93035 .init = sysctl_core_net_init,
93036 .exit = sysctl_core_net_exit,
93037 };
93038 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93039 index dd4d506..fb2fb87 100644
93040 --- a/net/decnet/af_decnet.c
93041 +++ b/net/decnet/af_decnet.c
93042 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93043 .sysctl_rmem = sysctl_decnet_rmem,
93044 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93045 .obj_size = sizeof(struct dn_sock),
93046 + .slab_flags = SLAB_USERCOPY,
93047 };
93048
93049 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93050 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93051 index 5325b54..a0d4d69 100644
93052 --- a/net/decnet/sysctl_net_decnet.c
93053 +++ b/net/decnet/sysctl_net_decnet.c
93054 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
93055
93056 if (len > *lenp) len = *lenp;
93057
93058 - if (copy_to_user(buffer, addr, len))
93059 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93060 return -EFAULT;
93061
93062 *lenp = len;
93063 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
93064
93065 if (len > *lenp) len = *lenp;
93066
93067 - if (copy_to_user(buffer, devname, len))
93068 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93069 return -EFAULT;
93070
93071 *lenp = len;
93072 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93073 index ff41b4d6..6125050 100644
93074 --- a/net/ieee802154/6lowpan.c
93075 +++ b/net/ieee802154/6lowpan.c
93076 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93077 hc06_ptr += 3;
93078 } else {
93079 /* compress nothing */
93080 - memcpy(hc06_ptr, &hdr, 4);
93081 + memcpy(hc06_ptr, hdr, 4);
93082 /* replace the top byte with new ECN | DSCP format */
93083 *hc06_ptr = tmp;
93084 hc06_ptr += 4;
93085 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93086 index cfeb85c..385989a 100644
93087 --- a/net/ipv4/af_inet.c
93088 +++ b/net/ipv4/af_inet.c
93089 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
93090
93091 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93092
93093 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93094 - if (!sysctl_local_reserved_ports)
93095 - goto out;
93096 -
93097 rc = proto_register(&tcp_prot, 1);
93098 if (rc)
93099 - goto out_free_reserved_ports;
93100 + goto out;
93101
93102 rc = proto_register(&udp_prot, 1);
93103 if (rc)
93104 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
93105 proto_unregister(&udp_prot);
93106 out_unregister_tcp_proto:
93107 proto_unregister(&tcp_prot);
93108 -out_free_reserved_ports:
93109 - kfree(sysctl_local_reserved_ports);
93110 goto out;
93111 }
93112
93113 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
93114 index b28e863..19e3637 100644
93115 --- a/net/ipv4/datagram.c
93116 +++ b/net/ipv4/datagram.c
93117 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
93118 if (IS_ERR(rt)) {
93119 err = PTR_ERR(rt);
93120 if (err == -ENETUNREACH)
93121 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
93122 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
93123 goto out;
93124 }
93125
93126 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93127 index a1b5bcb..62ec5c6 100644
93128 --- a/net/ipv4/devinet.c
93129 +++ b/net/ipv4/devinet.c
93130 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93131 idx = 0;
93132 head = &net->dev_index_head[h];
93133 rcu_read_lock();
93134 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93135 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93136 net->dev_base_seq;
93137 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93138 if (idx < s_idx)
93139 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93140 idx = 0;
93141 head = &net->dev_index_head[h];
93142 rcu_read_lock();
93143 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93144 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93145 net->dev_base_seq;
93146 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93147 if (idx < s_idx)
93148 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
93149 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93150 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93151
93152 -static struct devinet_sysctl_table {
93153 +static const struct devinet_sysctl_table {
93154 struct ctl_table_header *sysctl_header;
93155 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93156 } devinet_sysctl = {
93157 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
93158 int err;
93159 struct ipv4_devconf *all, *dflt;
93160 #ifdef CONFIG_SYSCTL
93161 - struct ctl_table *tbl = ctl_forward_entry;
93162 + ctl_table_no_const *tbl = NULL;
93163 struct ctl_table_header *forw_hdr;
93164 #endif
93165
93166 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
93167 goto err_alloc_dflt;
93168
93169 #ifdef CONFIG_SYSCTL
93170 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93171 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93172 if (tbl == NULL)
93173 goto err_alloc_ctl;
93174
93175 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
93176 goto err_reg_dflt;
93177
93178 err = -ENOMEM;
93179 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93180 + if (!net_eq(net, &init_net))
93181 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93182 + else
93183 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93184 if (forw_hdr == NULL)
93185 goto err_reg_ctl;
93186 net->ipv4.forw_hdr = forw_hdr;
93187 @@ -2245,8 +2248,7 @@ err_reg_ctl:
93188 err_reg_dflt:
93189 __devinet_sysctl_unregister(all);
93190 err_reg_all:
93191 - if (tbl != ctl_forward_entry)
93192 - kfree(tbl);
93193 + kfree(tbl);
93194 err_alloc_ctl:
93195 #endif
93196 if (dflt != &ipv4_devconf_dflt)
93197 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
93198 index b3f627a..b0f3e99 100644
93199 --- a/net/ipv4/fib_frontend.c
93200 +++ b/net/ipv4/fib_frontend.c
93201 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
93202 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93203 fib_sync_up(dev);
93204 #endif
93205 - atomic_inc(&net->ipv4.dev_addr_genid);
93206 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93207 rt_cache_flush(dev_net(dev));
93208 break;
93209 case NETDEV_DOWN:
93210 fib_del_ifaddr(ifa, NULL);
93211 - atomic_inc(&net->ipv4.dev_addr_genid);
93212 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93213 if (ifa->ifa_dev->ifa_list == NULL) {
93214 /* Last address was deleted from this interface.
93215 * Disable IP.
93216 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
93217 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93218 fib_sync_up(dev);
93219 #endif
93220 - atomic_inc(&net->ipv4.dev_addr_genid);
93221 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93222 rt_cache_flush(net);
93223 break;
93224 case NETDEV_DOWN:
93225 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
93226 index d5dbca5..6251d5f 100644
93227 --- a/net/ipv4/fib_semantics.c
93228 +++ b/net/ipv4/fib_semantics.c
93229 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
93230 nh->nh_saddr = inet_select_addr(nh->nh_dev,
93231 nh->nh_gw,
93232 nh->nh_parent->fib_scope);
93233 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
93234 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
93235
93236 return nh->nh_saddr;
93237 }
93238 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
93239 index 6acb541..9ea617d 100644
93240 --- a/net/ipv4/inet_connection_sock.c
93241 +++ b/net/ipv4/inet_connection_sock.c
93242 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
93243 .range = { 32768, 61000 },
93244 };
93245
93246 -unsigned long *sysctl_local_reserved_ports;
93247 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
93248 EXPORT_SYMBOL(sysctl_local_reserved_ports);
93249
93250 void inet_get_local_port_range(int *low, int *high)
93251 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
93252 index 96da9c7..b956690 100644
93253 --- a/net/ipv4/inet_hashtables.c
93254 +++ b/net/ipv4/inet_hashtables.c
93255 @@ -18,12 +18,15 @@
93256 #include <linux/sched.h>
93257 #include <linux/slab.h>
93258 #include <linux/wait.h>
93259 +#include <linux/security.h>
93260
93261 #include <net/inet_connection_sock.h>
93262 #include <net/inet_hashtables.h>
93263 #include <net/secure_seq.h>
93264 #include <net/ip.h>
93265
93266 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
93267 +
93268 /*
93269 * Allocate and initialize a new local port bind bucket.
93270 * The bindhash mutex for snum's hash chain must be held here.
93271 @@ -554,6 +557,8 @@ ok:
93272 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
93273 spin_unlock(&head->lock);
93274
93275 + gr_update_task_in_ip_table(current, inet_sk(sk));
93276 +
93277 if (tw) {
93278 inet_twsk_deschedule(tw, death_row);
93279 while (twrefcnt) {
93280 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
93281 index 33d5537..da337a4 100644
93282 --- a/net/ipv4/inetpeer.c
93283 +++ b/net/ipv4/inetpeer.c
93284 @@ -503,8 +503,8 @@ relookup:
93285 if (p) {
93286 p->daddr = *daddr;
93287 atomic_set(&p->refcnt, 1);
93288 - atomic_set(&p->rid, 0);
93289 - atomic_set(&p->ip_id_count,
93290 + atomic_set_unchecked(&p->rid, 0);
93291 + atomic_set_unchecked(&p->ip_id_count,
93292 (daddr->family == AF_INET) ?
93293 secure_ip_id(daddr->addr.a4) :
93294 secure_ipv6_id(daddr->addr.a6));
93295 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
93296 index b66910a..cfe416e 100644
93297 --- a/net/ipv4/ip_fragment.c
93298 +++ b/net/ipv4/ip_fragment.c
93299 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
93300 return 0;
93301
93302 start = qp->rid;
93303 - end = atomic_inc_return(&peer->rid);
93304 + end = atomic_inc_return_unchecked(&peer->rid);
93305 qp->rid = end;
93306
93307 rc = qp->q.fragments && (end - start) > max;
93308 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
93309
93310 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93311 {
93312 - struct ctl_table *table;
93313 + ctl_table_no_const *table = NULL;
93314 struct ctl_table_header *hdr;
93315
93316 - table = ip4_frags_ns_ctl_table;
93317 if (!net_eq(net, &init_net)) {
93318 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93319 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93320 if (table == NULL)
93321 goto err_alloc;
93322
93323 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93324 /* Don't export sysctls to unprivileged users */
93325 if (net->user_ns != &init_user_ns)
93326 table[0].procname = NULL;
93327 - }
93328 + hdr = register_net_sysctl(net, "net/ipv4", table);
93329 + } else
93330 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
93331
93332 - hdr = register_net_sysctl(net, "net/ipv4", table);
93333 if (hdr == NULL)
93334 goto err_reg;
93335
93336 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93337 return 0;
93338
93339 err_reg:
93340 - if (!net_eq(net, &init_net))
93341 - kfree(table);
93342 + kfree(table);
93343 err_alloc:
93344 return -ENOMEM;
93345 }
93346 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
93347 index d7aea4c..a8ee872 100644
93348 --- a/net/ipv4/ip_gre.c
93349 +++ b/net/ipv4/ip_gre.c
93350 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
93351 module_param(log_ecn_error, bool, 0644);
93352 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93353
93354 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
93355 +static struct rtnl_link_ops ipgre_link_ops;
93356 static int ipgre_tunnel_init(struct net_device *dev);
93357
93358 static int ipgre_net_id __read_mostly;
93359 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
93360 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
93361 };
93362
93363 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93364 +static struct rtnl_link_ops ipgre_link_ops = {
93365 .kind = "gre",
93366 .maxtype = IFLA_GRE_MAX,
93367 .policy = ipgre_policy,
93368 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93369 .fill_info = ipgre_fill_info,
93370 };
93371
93372 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
93373 +static struct rtnl_link_ops ipgre_tap_ops = {
93374 .kind = "gretap",
93375 .maxtype = IFLA_GRE_MAX,
93376 .policy = ipgre_policy,
93377 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
93378 index d9c4f11..02b82dbc 100644
93379 --- a/net/ipv4/ip_sockglue.c
93380 +++ b/net/ipv4/ip_sockglue.c
93381 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93382 len = min_t(unsigned int, len, opt->optlen);
93383 if (put_user(len, optlen))
93384 return -EFAULT;
93385 - if (copy_to_user(optval, opt->__data, len))
93386 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
93387 + copy_to_user(optval, opt->__data, len))
93388 return -EFAULT;
93389 return 0;
93390 }
93391 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93392 if (sk->sk_type != SOCK_STREAM)
93393 return -ENOPROTOOPT;
93394
93395 - msg.msg_control = optval;
93396 + msg.msg_control = (void __force_kernel *)optval;
93397 msg.msg_controllen = len;
93398 msg.msg_flags = flags;
93399
93400 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
93401 index 6e87f85..2c28e240 100644
93402 --- a/net/ipv4/ip_vti.c
93403 +++ b/net/ipv4/ip_vti.c
93404 @@ -44,7 +44,7 @@
93405 #include <net/net_namespace.h>
93406 #include <net/netns/generic.h>
93407
93408 -static struct rtnl_link_ops vti_link_ops __read_mostly;
93409 +static struct rtnl_link_ops vti_link_ops;
93410
93411 static int vti_net_id __read_mostly;
93412 static int vti_tunnel_init(struct net_device *dev);
93413 @@ -424,7 +424,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
93414 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
93415 };
93416
93417 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
93418 +static struct rtnl_link_ops vti_link_ops = {
93419 .kind = "vti",
93420 .maxtype = IFLA_VTI_MAX,
93421 .policy = vti_policy,
93422 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
93423 index efa1138..20dbba0 100644
93424 --- a/net/ipv4/ipconfig.c
93425 +++ b/net/ipv4/ipconfig.c
93426 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
93427
93428 mm_segment_t oldfs = get_fs();
93429 set_fs(get_ds());
93430 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93431 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93432 set_fs(oldfs);
93433 return res;
93434 }
93435 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
93436
93437 mm_segment_t oldfs = get_fs();
93438 set_fs(get_ds());
93439 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93440 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93441 set_fs(oldfs);
93442 return res;
93443 }
93444 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
93445
93446 mm_segment_t oldfs = get_fs();
93447 set_fs(get_ds());
93448 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
93449 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
93450 set_fs(oldfs);
93451 return res;
93452 }
93453 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
93454 index 7f80fb4..b0328f6 100644
93455 --- a/net/ipv4/ipip.c
93456 +++ b/net/ipv4/ipip.c
93457 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93458 static int ipip_net_id __read_mostly;
93459
93460 static int ipip_tunnel_init(struct net_device *dev);
93461 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
93462 +static struct rtnl_link_ops ipip_link_ops;
93463
93464 static int ipip_err(struct sk_buff *skb, u32 info)
93465 {
93466 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
93467 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
93468 };
93469
93470 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
93471 +static struct rtnl_link_ops ipip_link_ops = {
93472 .kind = "ipip",
93473 .maxtype = IFLA_IPTUN_MAX,
93474 .policy = ipip_policy,
93475 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
93476 index 85a4f21..1beb1f5 100644
93477 --- a/net/ipv4/netfilter/arp_tables.c
93478 +++ b/net/ipv4/netfilter/arp_tables.c
93479 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
93480 #endif
93481
93482 static int get_info(struct net *net, void __user *user,
93483 - const int *len, int compat)
93484 + int len, int compat)
93485 {
93486 char name[XT_TABLE_MAXNAMELEN];
93487 struct xt_table *t;
93488 int ret;
93489
93490 - if (*len != sizeof(struct arpt_getinfo)) {
93491 - duprintf("length %u != %Zu\n", *len,
93492 + if (len != sizeof(struct arpt_getinfo)) {
93493 + duprintf("length %u != %Zu\n", len,
93494 sizeof(struct arpt_getinfo));
93495 return -EINVAL;
93496 }
93497 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
93498 info.size = private->size;
93499 strcpy(info.name, name);
93500
93501 - if (copy_to_user(user, &info, *len) != 0)
93502 + if (copy_to_user(user, &info, len) != 0)
93503 ret = -EFAULT;
93504 else
93505 ret = 0;
93506 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
93507
93508 switch (cmd) {
93509 case ARPT_SO_GET_INFO:
93510 - ret = get_info(sock_net(sk), user, len, 1);
93511 + ret = get_info(sock_net(sk), user, *len, 1);
93512 break;
93513 case ARPT_SO_GET_ENTRIES:
93514 ret = compat_get_entries(sock_net(sk), user, len);
93515 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
93516
93517 switch (cmd) {
93518 case ARPT_SO_GET_INFO:
93519 - ret = get_info(sock_net(sk), user, len, 0);
93520 + ret = get_info(sock_net(sk), user, *len, 0);
93521 break;
93522
93523 case ARPT_SO_GET_ENTRIES:
93524 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
93525 index d23118d..6ad7277 100644
93526 --- a/net/ipv4/netfilter/ip_tables.c
93527 +++ b/net/ipv4/netfilter/ip_tables.c
93528 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
93529 #endif
93530
93531 static int get_info(struct net *net, void __user *user,
93532 - const int *len, int compat)
93533 + int len, int compat)
93534 {
93535 char name[XT_TABLE_MAXNAMELEN];
93536 struct xt_table *t;
93537 int ret;
93538
93539 - if (*len != sizeof(struct ipt_getinfo)) {
93540 - duprintf("length %u != %zu\n", *len,
93541 + if (len != sizeof(struct ipt_getinfo)) {
93542 + duprintf("length %u != %zu\n", len,
93543 sizeof(struct ipt_getinfo));
93544 return -EINVAL;
93545 }
93546 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
93547 info.size = private->size;
93548 strcpy(info.name, name);
93549
93550 - if (copy_to_user(user, &info, *len) != 0)
93551 + if (copy_to_user(user, &info, len) != 0)
93552 ret = -EFAULT;
93553 else
93554 ret = 0;
93555 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93556
93557 switch (cmd) {
93558 case IPT_SO_GET_INFO:
93559 - ret = get_info(sock_net(sk), user, len, 1);
93560 + ret = get_info(sock_net(sk), user, *len, 1);
93561 break;
93562 case IPT_SO_GET_ENTRIES:
93563 ret = compat_get_entries(sock_net(sk), user, len);
93564 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93565
93566 switch (cmd) {
93567 case IPT_SO_GET_INFO:
93568 - ret = get_info(sock_net(sk), user, len, 0);
93569 + ret = get_info(sock_net(sk), user, *len, 0);
93570 break;
93571
93572 case IPT_SO_GET_ENTRIES:
93573 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
93574 index cbc2215..9cb993c 100644
93575 --- a/net/ipv4/netfilter/ipt_ULOG.c
93576 +++ b/net/ipv4/netfilter/ipt_ULOG.c
93577 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
93578 ub->qlen++;
93579
93580 pm = nlmsg_data(nlh);
93581 + memset(pm, 0, sizeof(*pm));
93582
93583 /* We might not have a timestamp, get one */
93584 if (skb->tstamp.tv64 == 0)
93585 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
93586 }
93587 else if (loginfo->prefix[0] != '\0')
93588 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
93589 - else
93590 - *(pm->prefix) = '\0';
93591
93592 if (in && in->hard_header_len > 0 &&
93593 skb->mac_header != skb->network_header &&
93594 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
93595
93596 if (in)
93597 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
93598 - else
93599 - pm->indev_name[0] = '\0';
93600
93601 if (out)
93602 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
93603 - else
93604 - pm->outdev_name[0] = '\0';
93605
93606 /* copy_len <= skb->len, so can't fail. */
93607 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
93608 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
93609 index d7d9882..d700c68 100644
93610 --- a/net/ipv4/ping.c
93611 +++ b/net/ipv4/ping.c
93612 @@ -55,7 +55,7 @@
93613
93614
93615 struct ping_table ping_table;
93616 -struct pingv6_ops pingv6_ops;
93617 +struct pingv6_ops *pingv6_ops;
93618 EXPORT_SYMBOL_GPL(pingv6_ops);
93619
93620 static u16 ping_port_rover;
93621 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
93622 return -ENODEV;
93623 }
93624 }
93625 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
93626 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
93627 scoped);
93628 rcu_read_unlock();
93629
93630 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93631 }
93632 #if IS_ENABLED(CONFIG_IPV6)
93633 } else if (skb->protocol == htons(ETH_P_IPV6)) {
93634 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
93635 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
93636 #endif
93637 }
93638
93639 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93640 info, (u8 *)icmph);
93641 #if IS_ENABLED(CONFIG_IPV6)
93642 } else if (family == AF_INET6) {
93643 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
93644 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
93645 info, (u8 *)icmph);
93646 #endif
93647 }
93648 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93649 return ip_recv_error(sk, msg, len);
93650 #if IS_ENABLED(CONFIG_IPV6)
93651 } else if (family == AF_INET6) {
93652 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
93653 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
93654 #endif
93655 }
93656 }
93657 @@ -874,11 +874,14 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93658
93659 /* Copy the address and add cmsg data. */
93660 if (family == AF_INET) {
93661 - sin = (struct sockaddr_in *) msg->msg_name;
93662 - sin->sin_family = AF_INET;
93663 - sin->sin_port = 0 /* skb->h.uh->source */;
93664 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93665 - memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93666 + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
93667 +
93668 + if (sin) {
93669 + sin->sin_family = AF_INET;
93670 + sin->sin_port = 0 /* skb->h.uh->source */;
93671 + sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93672 + memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93673 + }
93674
93675 if (isk->cmsg_flags)
93676 ip_cmsg_recv(msg, skb);
93677 @@ -887,20 +890,23 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93678 } else if (family == AF_INET6) {
93679 struct ipv6_pinfo *np = inet6_sk(sk);
93680 struct ipv6hdr *ip6 = ipv6_hdr(skb);
93681 - sin6 = (struct sockaddr_in6 *) msg->msg_name;
93682 - sin6->sin6_family = AF_INET6;
93683 - sin6->sin6_port = 0;
93684 - sin6->sin6_addr = ip6->saddr;
93685 + struct sockaddr_in6 *sin6 =
93686 + (struct sockaddr_in6 *)msg->msg_name;
93687
93688 - sin6->sin6_flowinfo = 0;
93689 - if (np->sndflow)
93690 - sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93691 -
93692 - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
93693 - IP6CB(skb)->iif);
93694 + if (sin6) {
93695 + sin6->sin6_family = AF_INET6;
93696 + sin6->sin6_port = 0;
93697 + sin6->sin6_addr = ip6->saddr;
93698 + sin6->sin6_flowinfo = 0;
93699 + if (np->sndflow)
93700 + sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93701 + sin6->sin6_scope_id =
93702 + ipv6_iface_scope_id(&sin6->sin6_addr,
93703 + IP6CB(skb)->iif);
93704 + }
93705
93706 if (inet6_sk(sk)->rxopt.all)
93707 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
93708 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
93709 #endif
93710 } else {
93711 BUG();
93712 @@ -1090,7 +1096,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
93713 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93714 0, sock_i_ino(sp),
93715 atomic_read(&sp->sk_refcnt), sp,
93716 - atomic_read(&sp->sk_drops), len);
93717 + atomic_read_unchecked(&sp->sk_drops), len);
93718 }
93719
93720 static int ping_v4_seq_show(struct seq_file *seq, void *v)
93721 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
93722 index 193db03..05ba36c 100644
93723 --- a/net/ipv4/raw.c
93724 +++ b/net/ipv4/raw.c
93725 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
93726 int raw_rcv(struct sock *sk, struct sk_buff *skb)
93727 {
93728 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
93729 - atomic_inc(&sk->sk_drops);
93730 + atomic_inc_unchecked(&sk->sk_drops);
93731 kfree_skb(skb);
93732 return NET_RX_DROP;
93733 }
93734 @@ -748,16 +748,20 @@ static int raw_init(struct sock *sk)
93735
93736 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
93737 {
93738 + struct icmp_filter filter;
93739 +
93740 if (optlen > sizeof(struct icmp_filter))
93741 optlen = sizeof(struct icmp_filter);
93742 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
93743 + if (copy_from_user(&filter, optval, optlen))
93744 return -EFAULT;
93745 + raw_sk(sk)->filter = filter;
93746 return 0;
93747 }
93748
93749 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
93750 {
93751 int len, ret = -EFAULT;
93752 + struct icmp_filter filter;
93753
93754 if (get_user(len, optlen))
93755 goto out;
93756 @@ -767,8 +771,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
93757 if (len > sizeof(struct icmp_filter))
93758 len = sizeof(struct icmp_filter);
93759 ret = -EFAULT;
93760 - if (put_user(len, optlen) ||
93761 - copy_to_user(optval, &raw_sk(sk)->filter, len))
93762 + filter = raw_sk(sk)->filter;
93763 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
93764 goto out;
93765 ret = 0;
93766 out: return ret;
93767 @@ -997,7 +1001,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
93768 0, 0L, 0,
93769 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
93770 0, sock_i_ino(sp),
93771 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
93772 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
93773 }
93774
93775 static int raw_seq_show(struct seq_file *seq, void *v)
93776 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
93777 index 6011615..f418576 100644
93778 --- a/net/ipv4/route.c
93779 +++ b/net/ipv4/route.c
93780 @@ -2613,34 +2613,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
93781 .maxlen = sizeof(int),
93782 .mode = 0200,
93783 .proc_handler = ipv4_sysctl_rtcache_flush,
93784 + .extra1 = &init_net,
93785 },
93786 { },
93787 };
93788
93789 static __net_init int sysctl_route_net_init(struct net *net)
93790 {
93791 - struct ctl_table *tbl;
93792 + ctl_table_no_const *tbl = NULL;
93793
93794 - tbl = ipv4_route_flush_table;
93795 if (!net_eq(net, &init_net)) {
93796 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93797 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93798 if (tbl == NULL)
93799 goto err_dup;
93800
93801 /* Don't export sysctls to unprivileged users */
93802 if (net->user_ns != &init_user_ns)
93803 tbl[0].procname = NULL;
93804 - }
93805 - tbl[0].extra1 = net;
93806 + tbl[0].extra1 = net;
93807 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93808 + } else
93809 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
93810
93811 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93812 if (net->ipv4.route_hdr == NULL)
93813 goto err_reg;
93814 return 0;
93815
93816 err_reg:
93817 - if (tbl != ipv4_route_flush_table)
93818 - kfree(tbl);
93819 + kfree(tbl);
93820 err_dup:
93821 return -ENOMEM;
93822 }
93823 @@ -2663,8 +2663,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
93824
93825 static __net_init int rt_genid_init(struct net *net)
93826 {
93827 - atomic_set(&net->ipv4.rt_genid, 0);
93828 - atomic_set(&net->fnhe_genid, 0);
93829 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
93830 + atomic_set_unchecked(&net->fnhe_genid, 0);
93831 get_random_bytes(&net->ipv4.dev_addr_genid,
93832 sizeof(net->ipv4.dev_addr_genid));
93833 return 0;
93834 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
93835 index 540279f..9855b16 100644
93836 --- a/net/ipv4/sysctl_net_ipv4.c
93837 +++ b/net/ipv4/sysctl_net_ipv4.c
93838 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
93839 {
93840 int ret;
93841 int range[2];
93842 - struct ctl_table tmp = {
93843 + ctl_table_no_const tmp = {
93844 .data = &range,
93845 .maxlen = sizeof(range),
93846 .mode = table->mode,
93847 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
93848 int ret;
93849 gid_t urange[2];
93850 kgid_t low, high;
93851 - struct ctl_table tmp = {
93852 + ctl_table_no_const tmp = {
93853 .data = &urange,
93854 .maxlen = sizeof(urange),
93855 .mode = table->mode,
93856 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
93857 void __user *buffer, size_t *lenp, loff_t *ppos)
93858 {
93859 char val[TCP_CA_NAME_MAX];
93860 - struct ctl_table tbl = {
93861 + ctl_table_no_const tbl = {
93862 .data = val,
93863 .maxlen = TCP_CA_NAME_MAX,
93864 };
93865 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
93866 void __user *buffer, size_t *lenp,
93867 loff_t *ppos)
93868 {
93869 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
93870 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
93871 int ret;
93872
93873 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93874 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
93875 void __user *buffer, size_t *lenp,
93876 loff_t *ppos)
93877 {
93878 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
93879 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
93880 int ret;
93881
93882 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93883 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
93884 struct mem_cgroup *memcg;
93885 #endif
93886
93887 - struct ctl_table tmp = {
93888 + ctl_table_no_const tmp = {
93889 .data = &vec,
93890 .maxlen = sizeof(vec),
93891 .mode = ctl->mode,
93892 };
93893
93894 if (!write) {
93895 - ctl->data = &net->ipv4.sysctl_tcp_mem;
93896 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
93897 + ctl_table_no_const tcp_mem = *ctl;
93898 +
93899 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
93900 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
93901 }
93902
93903 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
93904 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
93905 void __user *buffer, size_t *lenp,
93906 loff_t *ppos)
93907 {
93908 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93909 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93910 struct tcp_fastopen_context *ctxt;
93911 int ret;
93912 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
93913 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
93914 },
93915 {
93916 .procname = "ip_local_reserved_ports",
93917 - .data = NULL, /* initialized in sysctl_ipv4_init */
93918 + .data = sysctl_local_reserved_ports,
93919 .maxlen = 65536,
93920 .mode = 0644,
93921 .proc_handler = proc_do_large_bitmap,
93922 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
93923
93924 static __net_init int ipv4_sysctl_init_net(struct net *net)
93925 {
93926 - struct ctl_table *table;
93927 + ctl_table_no_const *table = NULL;
93928
93929 - table = ipv4_net_table;
93930 if (!net_eq(net, &init_net)) {
93931 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
93932 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
93933 if (table == NULL)
93934 goto err_alloc;
93935
93936 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
93937
93938 tcp_init_mem(net);
93939
93940 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93941 + if (!net_eq(net, &init_net))
93942 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93943 + else
93944 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
93945 if (net->ipv4.ipv4_hdr == NULL)
93946 goto err_reg;
93947
93948 return 0;
93949
93950 err_reg:
93951 - if (!net_eq(net, &init_net))
93952 - kfree(table);
93953 + kfree(table);
93954 err_alloc:
93955 return -ENOMEM;
93956 }
93957 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
93958 static __init int sysctl_ipv4_init(void)
93959 {
93960 struct ctl_table_header *hdr;
93961 - struct ctl_table *i;
93962 -
93963 - for (i = ipv4_table; i->procname; i++) {
93964 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93965 - i->data = sysctl_local_reserved_ports;
93966 - break;
93967 - }
93968 - }
93969 - if (!i->procname)
93970 - return -EINVAL;
93971
93972 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
93973 if (hdr == NULL)
93974 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
93975 index 068c8fb..a755c52 100644
93976 --- a/net/ipv4/tcp_input.c
93977 +++ b/net/ipv4/tcp_input.c
93978 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
93979 * simplifies code)
93980 */
93981 static void
93982 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93983 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93984 struct sk_buff *head, struct sk_buff *tail,
93985 u32 start, u32 end)
93986 {
93987 @@ -5520,6 +5520,7 @@ discard:
93988 tcp_paws_reject(&tp->rx_opt, 0))
93989 goto discard_and_undo;
93990
93991 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
93992 if (th->syn) {
93993 /* We see SYN without ACK. It is attempt of
93994 * simultaneous connect with crossed SYNs.
93995 @@ -5570,6 +5571,7 @@ discard:
93996 goto discard;
93997 #endif
93998 }
93999 +#endif
94000 /* "fifth, if neither of the SYN or RST bits is set then
94001 * drop the segment and return."
94002 */
94003 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94004 goto discard;
94005
94006 if (th->syn) {
94007 - if (th->fin)
94008 + if (th->fin || th->urg || th->psh)
94009 goto discard;
94010 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94011 return 1;
94012 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94013 index b14266b..c5fe725 100644
94014 --- a/net/ipv4/tcp_ipv4.c
94015 +++ b/net/ipv4/tcp_ipv4.c
94016 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
94017 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94018
94019
94020 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94021 +extern int grsec_enable_blackhole;
94022 +#endif
94023 +
94024 #ifdef CONFIG_TCP_MD5SIG
94025 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94026 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94027 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94028 return 0;
94029
94030 reset:
94031 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94032 + if (!grsec_enable_blackhole)
94033 +#endif
94034 tcp_v4_send_reset(rsk, skb);
94035 discard:
94036 kfree_skb(skb);
94037 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94038 TCP_SKB_CB(skb)->sacked = 0;
94039
94040 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94041 - if (!sk)
94042 + if (!sk) {
94043 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94044 + ret = 1;
94045 +#endif
94046 goto no_tcp_socket;
94047 -
94048 + }
94049 process:
94050 - if (sk->sk_state == TCP_TIME_WAIT)
94051 + if (sk->sk_state == TCP_TIME_WAIT) {
94052 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94053 + ret = 2;
94054 +#endif
94055 goto do_time_wait;
94056 + }
94057
94058 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94059 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94060 @@ -2033,6 +2047,10 @@ csum_error:
94061 bad_packet:
94062 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94063 } else {
94064 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94065 + if (!grsec_enable_blackhole || (ret == 1 &&
94066 + (skb->dev->flags & IFF_LOOPBACK)))
94067 +#endif
94068 tcp_v4_send_reset(NULL, skb);
94069 }
94070
94071 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94072 index 58a3e69..7f0626e 100644
94073 --- a/net/ipv4/tcp_minisocks.c
94074 +++ b/net/ipv4/tcp_minisocks.c
94075 @@ -27,6 +27,10 @@
94076 #include <net/inet_common.h>
94077 #include <net/xfrm.h>
94078
94079 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94080 +extern int grsec_enable_blackhole;
94081 +#endif
94082 +
94083 int sysctl_tcp_syncookies __read_mostly = 1;
94084 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94085
94086 @@ -711,7 +715,10 @@ embryonic_reset:
94087 * avoid becoming vulnerable to outside attack aiming at
94088 * resetting legit local connections.
94089 */
94090 - req->rsk_ops->send_reset(sk, skb);
94091 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94092 + if (!grsec_enable_blackhole)
94093 +#endif
94094 + req->rsk_ops->send_reset(sk, skb);
94095 } else if (fastopen) { /* received a valid RST pkt */
94096 reqsk_fastopen_remove(sk, req, true);
94097 tcp_reset(sk);
94098 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94099 index 611beab..c4b6e1d 100644
94100 --- a/net/ipv4/tcp_probe.c
94101 +++ b/net/ipv4/tcp_probe.c
94102 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94103 if (cnt + width >= len)
94104 break;
94105
94106 - if (copy_to_user(buf + cnt, tbuf, width))
94107 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94108 return -EFAULT;
94109 cnt += width;
94110 }
94111 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94112 index 4b85e6f..22f9ac9 100644
94113 --- a/net/ipv4/tcp_timer.c
94114 +++ b/net/ipv4/tcp_timer.c
94115 @@ -22,6 +22,10 @@
94116 #include <linux/gfp.h>
94117 #include <net/tcp.h>
94118
94119 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94120 +extern int grsec_lastack_retries;
94121 +#endif
94122 +
94123 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94124 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94125 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94126 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94127 }
94128 }
94129
94130 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94131 + if ((sk->sk_state == TCP_LAST_ACK) &&
94132 + (grsec_lastack_retries > 0) &&
94133 + (grsec_lastack_retries < retry_until))
94134 + retry_until = grsec_lastack_retries;
94135 +#endif
94136 +
94137 if (retransmits_timed_out(sk, retry_until,
94138 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94139 /* Has it gone just too far? */
94140 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94141 index 0ca44df..b5e4b11 100644
94142 --- a/net/ipv4/udp.c
94143 +++ b/net/ipv4/udp.c
94144 @@ -87,6 +87,7 @@
94145 #include <linux/types.h>
94146 #include <linux/fcntl.h>
94147 #include <linux/module.h>
94148 +#include <linux/security.h>
94149 #include <linux/socket.h>
94150 #include <linux/sockios.h>
94151 #include <linux/igmp.h>
94152 @@ -112,6 +113,10 @@
94153 #include <net/busy_poll.h>
94154 #include "udp_impl.h"
94155
94156 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94157 +extern int grsec_enable_blackhole;
94158 +#endif
94159 +
94160 struct udp_table udp_table __read_mostly;
94161 EXPORT_SYMBOL(udp_table);
94162
94163 @@ -595,6 +600,9 @@ found:
94164 return s;
94165 }
94166
94167 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94168 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94169 +
94170 /*
94171 * This routine is called by the ICMP module when it gets some
94172 * sort of error condition. If err < 0 then the socket should
94173 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94174 dport = usin->sin_port;
94175 if (dport == 0)
94176 return -EINVAL;
94177 +
94178 + err = gr_search_udp_sendmsg(sk, usin);
94179 + if (err)
94180 + return err;
94181 } else {
94182 if (sk->sk_state != TCP_ESTABLISHED)
94183 return -EDESTADDRREQ;
94184 +
94185 + err = gr_search_udp_sendmsg(sk, NULL);
94186 + if (err)
94187 + return err;
94188 +
94189 daddr = inet->inet_daddr;
94190 dport = inet->inet_dport;
94191 /* Open fast path for connected socket.
94192 @@ -1138,7 +1155,7 @@ static unsigned int first_packet_length(struct sock *sk)
94193 IS_UDPLITE(sk));
94194 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94195 IS_UDPLITE(sk));
94196 - atomic_inc(&sk->sk_drops);
94197 + atomic_inc_unchecked(&sk->sk_drops);
94198 __skb_unlink(skb, rcvq);
94199 __skb_queue_tail(&list_kill, skb);
94200 }
94201 @@ -1224,6 +1241,10 @@ try_again:
94202 if (!skb)
94203 goto out;
94204
94205 + err = gr_search_udp_recvmsg(sk, skb);
94206 + if (err)
94207 + goto out_free;
94208 +
94209 ulen = skb->len - sizeof(struct udphdr);
94210 copied = len;
94211 if (copied > ulen)
94212 @@ -1257,7 +1278,7 @@ try_again:
94213 if (unlikely(err)) {
94214 trace_kfree_skb(skb, udp_recvmsg);
94215 if (!peeked) {
94216 - atomic_inc(&sk->sk_drops);
94217 + atomic_inc_unchecked(&sk->sk_drops);
94218 UDP_INC_STATS_USER(sock_net(sk),
94219 UDP_MIB_INERRORS, is_udplite);
94220 }
94221 @@ -1544,7 +1565,7 @@ csum_error:
94222 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94223 drop:
94224 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94225 - atomic_inc(&sk->sk_drops);
94226 + atomic_inc_unchecked(&sk->sk_drops);
94227 kfree_skb(skb);
94228 return -1;
94229 }
94230 @@ -1563,7 +1584,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94231 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94232
94233 if (!skb1) {
94234 - atomic_inc(&sk->sk_drops);
94235 + atomic_inc_unchecked(&sk->sk_drops);
94236 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94237 IS_UDPLITE(sk));
94238 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94239 @@ -1735,6 +1756,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94240 goto csum_error;
94241
94242 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94243 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94244 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94245 +#endif
94246 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
94247
94248 /*
94249 @@ -2167,7 +2191,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
94250 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94251 0, sock_i_ino(sp),
94252 atomic_read(&sp->sk_refcnt), sp,
94253 - atomic_read(&sp->sk_drops), len);
94254 + atomic_read_unchecked(&sp->sk_drops), len);
94255 }
94256
94257 int udp4_seq_show(struct seq_file *seq, void *v)
94258 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
94259 index ccde542..eeb5ff7 100644
94260 --- a/net/ipv4/xfrm4_policy.c
94261 +++ b/net/ipv4/xfrm4_policy.c
94262 @@ -182,11 +182,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
94263 fl4->flowi4_tos = iph->tos;
94264 }
94265
94266 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
94267 +static int xfrm4_garbage_collect(struct dst_ops *ops)
94268 {
94269 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
94270
94271 - xfrm4_policy_afinfo.garbage_collect(net);
94272 + xfrm_garbage_collect_deferred(net);
94273 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
94274 }
94275
94276 @@ -265,19 +265,18 @@ static struct ctl_table xfrm4_policy_table[] = {
94277
94278 static int __net_init xfrm4_net_init(struct net *net)
94279 {
94280 - struct ctl_table *table;
94281 + ctl_table_no_const *table = NULL;
94282 struct ctl_table_header *hdr;
94283
94284 - table = xfrm4_policy_table;
94285 if (!net_eq(net, &init_net)) {
94286 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94287 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94288 if (!table)
94289 goto err_alloc;
94290
94291 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
94292 - }
94293 -
94294 - hdr = register_net_sysctl(net, "net/ipv4", table);
94295 + hdr = register_net_sysctl(net, "net/ipv4", table);
94296 + } else
94297 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
94298 if (!hdr)
94299 goto err_reg;
94300
94301 @@ -285,8 +284,7 @@ static int __net_init xfrm4_net_init(struct net *net)
94302 return 0;
94303
94304 err_reg:
94305 - if (!net_eq(net, &init_net))
94306 - kfree(table);
94307 + kfree(table);
94308 err_alloc:
94309 return -ENOMEM;
94310 }
94311 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
94312 index cd3fb30..b7dfef7 100644
94313 --- a/net/ipv6/addrconf.c
94314 +++ b/net/ipv6/addrconf.c
94315 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
94316 idx = 0;
94317 head = &net->dev_index_head[h];
94318 rcu_read_lock();
94319 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
94320 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
94321 net->dev_base_seq;
94322 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94323 if (idx < s_idx)
94324 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
94325 p.iph.ihl = 5;
94326 p.iph.protocol = IPPROTO_IPV6;
94327 p.iph.ttl = 64;
94328 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
94329 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
94330
94331 if (ops->ndo_do_ioctl) {
94332 mm_segment_t oldfs = get_fs();
94333 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
94334 s_ip_idx = ip_idx = cb->args[2];
94335
94336 rcu_read_lock();
94337 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94338 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94339 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
94340 idx = 0;
94341 head = &net->dev_index_head[h];
94342 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94343 dst_free(&ifp->rt->dst);
94344 break;
94345 }
94346 - atomic_inc(&net->ipv6.dev_addr_genid);
94347 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
94348 rt_genid_bump_ipv6(net);
94349 }
94350
94351 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
94352 int *valp = ctl->data;
94353 int val = *valp;
94354 loff_t pos = *ppos;
94355 - struct ctl_table lctl;
94356 + ctl_table_no_const lctl;
94357 int ret;
94358
94359 /*
94360 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
94361 int *valp = ctl->data;
94362 int val = *valp;
94363 loff_t pos = *ppos;
94364 - struct ctl_table lctl;
94365 + ctl_table_no_const lctl;
94366 int ret;
94367
94368 /*
94369 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
94370 index 7c96100..bfd994a 100644
94371 --- a/net/ipv6/af_inet6.c
94372 +++ b/net/ipv6/af_inet6.c
94373 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
94374
94375 net->ipv6.sysctl.bindv6only = 0;
94376 net->ipv6.sysctl.icmpv6_time = 1*HZ;
94377 - atomic_set(&net->ipv6.rt_genid, 0);
94378 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
94379
94380 err = ipv6_init_mibs(net);
94381 if (err)
94382 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
94383 index 48b6bd2..76d3458 100644
94384 --- a/net/ipv6/datagram.c
94385 +++ b/net/ipv6/datagram.c
94386 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
94387 0,
94388 sock_i_ino(sp),
94389 atomic_read(&sp->sk_refcnt), sp,
94390 - atomic_read(&sp->sk_drops));
94391 + atomic_read_unchecked(&sp->sk_drops));
94392 }
94393 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
94394 index eef8d94..cfa1852 100644
94395 --- a/net/ipv6/icmp.c
94396 +++ b/net/ipv6/icmp.c
94397 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
94398
94399 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
94400 {
94401 - struct ctl_table *table;
94402 + ctl_table_no_const *table;
94403
94404 table = kmemdup(ipv6_icmp_table_template,
94405 sizeof(ipv6_icmp_table_template),
94406 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
94407 index bf4a9a0..e5f6ac5 100644
94408 --- a/net/ipv6/ip6_gre.c
94409 +++ b/net/ipv6/ip6_gre.c
94410 @@ -74,7 +74,7 @@ struct ip6gre_net {
94411 struct net_device *fb_tunnel_dev;
94412 };
94413
94414 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
94415 +static struct rtnl_link_ops ip6gre_link_ops;
94416 static int ip6gre_tunnel_init(struct net_device *dev);
94417 static void ip6gre_tunnel_setup(struct net_device *dev);
94418 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
94419 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
94420 }
94421
94422
94423 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
94424 +static struct inet6_protocol ip6gre_protocol = {
94425 .handler = ip6gre_rcv,
94426 .err_handler = ip6gre_err,
94427 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
94428 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
94429 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
94430 };
94431
94432 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94433 +static struct rtnl_link_ops ip6gre_link_ops = {
94434 .kind = "ip6gre",
94435 .maxtype = IFLA_GRE_MAX,
94436 .policy = ip6gre_policy,
94437 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94438 .fill_info = ip6gre_fill_info,
94439 };
94440
94441 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
94442 +static struct rtnl_link_ops ip6gre_tap_ops = {
94443 .kind = "ip6gretap",
94444 .maxtype = IFLA_GRE_MAX,
94445 .policy = ip6gre_policy,
94446 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
94447 index 583b77e..99522b8 100644
94448 --- a/net/ipv6/ip6_tunnel.c
94449 +++ b/net/ipv6/ip6_tunnel.c
94450 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
94451
94452 static int ip6_tnl_dev_init(struct net_device *dev);
94453 static void ip6_tnl_dev_setup(struct net_device *dev);
94454 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
94455 +static struct rtnl_link_ops ip6_link_ops;
94456
94457 static int ip6_tnl_net_id __read_mostly;
94458 struct ip6_tnl_net {
94459 @@ -1690,7 +1690,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
94460 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
94461 };
94462
94463 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
94464 +static struct rtnl_link_ops ip6_link_ops = {
94465 .kind = "ip6tnl",
94466 .maxtype = IFLA_IPTUN_MAX,
94467 .policy = ip6_tnl_policy,
94468 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
94469 index d1e2e8e..51c19ae 100644
94470 --- a/net/ipv6/ipv6_sockglue.c
94471 +++ b/net/ipv6/ipv6_sockglue.c
94472 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
94473 if (sk->sk_type != SOCK_STREAM)
94474 return -ENOPROTOOPT;
94475
94476 - msg.msg_control = optval;
94477 + msg.msg_control = (void __force_kernel *)optval;
94478 msg.msg_controllen = len;
94479 msg.msg_flags = flags;
94480
94481 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
94482 index 44400c2..8e11f52 100644
94483 --- a/net/ipv6/netfilter/ip6_tables.c
94484 +++ b/net/ipv6/netfilter/ip6_tables.c
94485 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
94486 #endif
94487
94488 static int get_info(struct net *net, void __user *user,
94489 - const int *len, int compat)
94490 + int len, int compat)
94491 {
94492 char name[XT_TABLE_MAXNAMELEN];
94493 struct xt_table *t;
94494 int ret;
94495
94496 - if (*len != sizeof(struct ip6t_getinfo)) {
94497 - duprintf("length %u != %zu\n", *len,
94498 + if (len != sizeof(struct ip6t_getinfo)) {
94499 + duprintf("length %u != %zu\n", len,
94500 sizeof(struct ip6t_getinfo));
94501 return -EINVAL;
94502 }
94503 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
94504 info.size = private->size;
94505 strcpy(info.name, name);
94506
94507 - if (copy_to_user(user, &info, *len) != 0)
94508 + if (copy_to_user(user, &info, len) != 0)
94509 ret = -EFAULT;
94510 else
94511 ret = 0;
94512 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94513
94514 switch (cmd) {
94515 case IP6T_SO_GET_INFO:
94516 - ret = get_info(sock_net(sk), user, len, 1);
94517 + ret = get_info(sock_net(sk), user, *len, 1);
94518 break;
94519 case IP6T_SO_GET_ENTRIES:
94520 ret = compat_get_entries(sock_net(sk), user, len);
94521 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94522
94523 switch (cmd) {
94524 case IP6T_SO_GET_INFO:
94525 - ret = get_info(sock_net(sk), user, len, 0);
94526 + ret = get_info(sock_net(sk), user, *len, 0);
94527 break;
94528
94529 case IP6T_SO_GET_ENTRIES:
94530 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
94531 index dffdc1a..ccc6678 100644
94532 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
94533 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
94534 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
94535
94536 static int nf_ct_frag6_sysctl_register(struct net *net)
94537 {
94538 - struct ctl_table *table;
94539 + ctl_table_no_const *table = NULL;
94540 struct ctl_table_header *hdr;
94541
94542 - table = nf_ct_frag6_sysctl_table;
94543 if (!net_eq(net, &init_net)) {
94544 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
94545 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
94546 GFP_KERNEL);
94547 if (table == NULL)
94548 goto err_alloc;
94549 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94550 table[0].data = &net->nf_frag.frags.timeout;
94551 table[1].data = &net->nf_frag.frags.low_thresh;
94552 table[2].data = &net->nf_frag.frags.high_thresh;
94553 - }
94554 -
94555 - hdr = register_net_sysctl(net, "net/netfilter", table);
94556 + hdr = register_net_sysctl(net, "net/netfilter", table);
94557 + } else
94558 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
94559 if (hdr == NULL)
94560 goto err_reg;
94561
94562 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94563 return 0;
94564
94565 err_reg:
94566 - if (!net_eq(net, &init_net))
94567 - kfree(table);
94568 + kfree(table);
94569 err_alloc:
94570 return -ENOMEM;
94571 }
94572 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
94573 index 827f795..7e28e82 100644
94574 --- a/net/ipv6/output_core.c
94575 +++ b/net/ipv6/output_core.c
94576 @@ -9,8 +9,8 @@
94577
94578 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94579 {
94580 - static atomic_t ipv6_fragmentation_id;
94581 - int old, new;
94582 + static atomic_unchecked_t ipv6_fragmentation_id;
94583 + int id;
94584
94585 #if IS_ENABLED(CONFIG_IPV6)
94586 if (rt && !(rt->dst.flags & DST_NOPEER)) {
94587 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94588 }
94589 }
94590 #endif
94591 - do {
94592 - old = atomic_read(&ipv6_fragmentation_id);
94593 - new = old + 1;
94594 - if (!new)
94595 - new = 1;
94596 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
94597 - fhdr->identification = htonl(new);
94598 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94599 + if (!id)
94600 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94601 + fhdr->identification = htonl(id);
94602 }
94603 EXPORT_SYMBOL(ipv6_select_ident);
94604
94605 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
94606 index 18f19df..b46ada1 100644
94607 --- a/net/ipv6/ping.c
94608 +++ b/net/ipv6/ping.c
94609 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
94610 };
94611 #endif
94612
94613 +static struct pingv6_ops real_pingv6_ops = {
94614 + .ipv6_recv_error = ipv6_recv_error,
94615 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
94616 + .icmpv6_err_convert = icmpv6_err_convert,
94617 + .ipv6_icmp_error = ipv6_icmp_error,
94618 + .ipv6_chk_addr = ipv6_chk_addr,
94619 +};
94620 +
94621 +static struct pingv6_ops dummy_pingv6_ops = {
94622 + .ipv6_recv_error = dummy_ipv6_recv_error,
94623 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
94624 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
94625 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
94626 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
94627 +};
94628 +
94629 int __init pingv6_init(void)
94630 {
94631 #ifdef CONFIG_PROC_FS
94632 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
94633 if (ret)
94634 return ret;
94635 #endif
94636 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
94637 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
94638 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
94639 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
94640 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
94641 + pingv6_ops = &real_pingv6_ops;
94642 return inet6_register_protosw(&pingv6_protosw);
94643 }
94644
94645 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
94646 */
94647 void pingv6_exit(void)
94648 {
94649 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
94650 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
94651 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
94652 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
94653 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
94654 + pingv6_ops = &dummy_pingv6_ops;
94655 #ifdef CONFIG_PROC_FS
94656 unregister_pernet_subsys(&ping_v6_net_ops);
94657 #endif
94658 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
94659 index a4ed241..8bf6277 100644
94660 --- a/net/ipv6/raw.c
94661 +++ b/net/ipv6/raw.c
94662 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
94663 {
94664 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
94665 skb_checksum_complete(skb)) {
94666 - atomic_inc(&sk->sk_drops);
94667 + atomic_inc_unchecked(&sk->sk_drops);
94668 kfree_skb(skb);
94669 return NET_RX_DROP;
94670 }
94671 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94672 struct raw6_sock *rp = raw6_sk(sk);
94673
94674 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
94675 - atomic_inc(&sk->sk_drops);
94676 + atomic_inc_unchecked(&sk->sk_drops);
94677 kfree_skb(skb);
94678 return NET_RX_DROP;
94679 }
94680 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94681
94682 if (inet->hdrincl) {
94683 if (skb_checksum_complete(skb)) {
94684 - atomic_inc(&sk->sk_drops);
94685 + atomic_inc_unchecked(&sk->sk_drops);
94686 kfree_skb(skb);
94687 return NET_RX_DROP;
94688 }
94689 @@ -609,7 +609,7 @@ out:
94690 return err;
94691 }
94692
94693 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
94694 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
94695 struct flowi6 *fl6, struct dst_entry **dstp,
94696 unsigned int flags)
94697 {
94698 @@ -922,12 +922,15 @@ do_confirm:
94699 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
94700 char __user *optval, int optlen)
94701 {
94702 + struct icmp6_filter filter;
94703 +
94704 switch (optname) {
94705 case ICMPV6_FILTER:
94706 if (optlen > sizeof(struct icmp6_filter))
94707 optlen = sizeof(struct icmp6_filter);
94708 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
94709 + if (copy_from_user(&filter, optval, optlen))
94710 return -EFAULT;
94711 + raw6_sk(sk)->filter = filter;
94712 return 0;
94713 default:
94714 return -ENOPROTOOPT;
94715 @@ -940,6 +943,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94716 char __user *optval, int __user *optlen)
94717 {
94718 int len;
94719 + struct icmp6_filter filter;
94720
94721 switch (optname) {
94722 case ICMPV6_FILTER:
94723 @@ -951,7 +955,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94724 len = sizeof(struct icmp6_filter);
94725 if (put_user(len, optlen))
94726 return -EFAULT;
94727 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
94728 + filter = raw6_sk(sk)->filter;
94729 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
94730 return -EFAULT;
94731 return 0;
94732 default:
94733 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
94734 index 1aeb473..bea761c 100644
94735 --- a/net/ipv6/reassembly.c
94736 +++ b/net/ipv6/reassembly.c
94737 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
94738
94739 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94740 {
94741 - struct ctl_table *table;
94742 + ctl_table_no_const *table = NULL;
94743 struct ctl_table_header *hdr;
94744
94745 - table = ip6_frags_ns_ctl_table;
94746 if (!net_eq(net, &init_net)) {
94747 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94748 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94749 if (table == NULL)
94750 goto err_alloc;
94751
94752 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94753 /* Don't export sysctls to unprivileged users */
94754 if (net->user_ns != &init_user_ns)
94755 table[0].procname = NULL;
94756 - }
94757 + hdr = register_net_sysctl(net, "net/ipv6", table);
94758 + } else
94759 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
94760
94761 - hdr = register_net_sysctl(net, "net/ipv6", table);
94762 if (hdr == NULL)
94763 goto err_reg;
94764
94765 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94766 return 0;
94767
94768 err_reg:
94769 - if (!net_eq(net, &init_net))
94770 - kfree(table);
94771 + kfree(table);
94772 err_alloc:
94773 return -ENOMEM;
94774 }
94775 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
94776 index 04e17b3..83502e9 100644
94777 --- a/net/ipv6/route.c
94778 +++ b/net/ipv6/route.c
94779 @@ -3006,7 +3006,7 @@ struct ctl_table ipv6_route_table_template[] = {
94780
94781 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
94782 {
94783 - struct ctl_table *table;
94784 + ctl_table_no_const *table;
94785
94786 table = kmemdup(ipv6_route_table_template,
94787 sizeof(ipv6_route_table_template),
94788 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
94789 index 1926945..30a1a57 100644
94790 --- a/net/ipv6/sit.c
94791 +++ b/net/ipv6/sit.c
94792 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
94793 static void ipip6_dev_free(struct net_device *dev);
94794 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
94795 __be32 *v4dst);
94796 -static struct rtnl_link_ops sit_link_ops __read_mostly;
94797 +static struct rtnl_link_ops sit_link_ops;
94798
94799 static int sit_net_id __read_mostly;
94800 struct sit_net {
94801 @@ -1594,7 +1594,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
94802 #endif
94803 };
94804
94805 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
94806 +static struct rtnl_link_ops sit_link_ops = {
94807 .kind = "sit",
94808 .maxtype = IFLA_IPTUN_MAX,
94809 .policy = ipip6_policy,
94810 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
94811 index 107b2f1..72741a9 100644
94812 --- a/net/ipv6/sysctl_net_ipv6.c
94813 +++ b/net/ipv6/sysctl_net_ipv6.c
94814 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
94815
94816 static int __net_init ipv6_sysctl_net_init(struct net *net)
94817 {
94818 - struct ctl_table *ipv6_table;
94819 + ctl_table_no_const *ipv6_table;
94820 struct ctl_table *ipv6_route_table;
94821 struct ctl_table *ipv6_icmp_table;
94822 int err;
94823 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
94824 index 5c71501..7e8d5d3 100644
94825 --- a/net/ipv6/tcp_ipv6.c
94826 +++ b/net/ipv6/tcp_ipv6.c
94827 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
94828 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
94829 }
94830
94831 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94832 +extern int grsec_enable_blackhole;
94833 +#endif
94834 +
94835 static void tcp_v6_hash(struct sock *sk)
94836 {
94837 if (sk->sk_state != TCP_CLOSE) {
94838 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
94839 return 0;
94840
94841 reset:
94842 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94843 + if (!grsec_enable_blackhole)
94844 +#endif
94845 tcp_v6_send_reset(sk, skb);
94846 discard:
94847 if (opt_skb)
94848 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
94849 TCP_SKB_CB(skb)->sacked = 0;
94850
94851 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94852 - if (!sk)
94853 + if (!sk) {
94854 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94855 + ret = 1;
94856 +#endif
94857 goto no_tcp_socket;
94858 + }
94859
94860 process:
94861 - if (sk->sk_state == TCP_TIME_WAIT)
94862 + if (sk->sk_state == TCP_TIME_WAIT) {
94863 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94864 + ret = 2;
94865 +#endif
94866 goto do_time_wait;
94867 + }
94868
94869 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
94870 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94871 @@ -1536,6 +1551,10 @@ csum_error:
94872 bad_packet:
94873 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94874 } else {
94875 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94876 + if (!grsec_enable_blackhole || (ret == 1 &&
94877 + (skb->dev->flags & IFF_LOOPBACK)))
94878 +#endif
94879 tcp_v6_send_reset(NULL, skb);
94880 }
94881
94882 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
94883 index 1878609..b48e1d4 100644
94884 --- a/net/ipv6/udp.c
94885 +++ b/net/ipv6/udp.c
94886 @@ -53,6 +53,10 @@
94887 #include <trace/events/skb.h>
94888 #include "udp_impl.h"
94889
94890 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94891 +extern int grsec_enable_blackhole;
94892 +#endif
94893 +
94894 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
94895 {
94896 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
94897 @@ -420,7 +424,7 @@ try_again:
94898 if (unlikely(err)) {
94899 trace_kfree_skb(skb, udpv6_recvmsg);
94900 if (!peeked) {
94901 - atomic_inc(&sk->sk_drops);
94902 + atomic_inc_unchecked(&sk->sk_drops);
94903 if (is_udp4)
94904 UDP_INC_STATS_USER(sock_net(sk),
94905 UDP_MIB_INERRORS,
94906 @@ -668,7 +672,7 @@ csum_error:
94907 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94908 drop:
94909 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94910 - atomic_inc(&sk->sk_drops);
94911 + atomic_inc_unchecked(&sk->sk_drops);
94912 kfree_skb(skb);
94913 return -1;
94914 }
94915 @@ -726,7 +730,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94916 if (likely(skb1 == NULL))
94917 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94918 if (!skb1) {
94919 - atomic_inc(&sk->sk_drops);
94920 + atomic_inc_unchecked(&sk->sk_drops);
94921 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94922 IS_UDPLITE(sk));
94923 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94924 @@ -866,6 +870,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94925 goto csum_error;
94926
94927 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94928 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94929 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94930 +#endif
94931 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
94932
94933 kfree_skb(skb);
94934 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
94935 index 08ed277..80e4bc8 100644
94936 --- a/net/ipv6/xfrm6_policy.c
94937 +++ b/net/ipv6/xfrm6_policy.c
94938 @@ -208,11 +208,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
94939 }
94940 }
94941
94942 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
94943 +static int xfrm6_garbage_collect(struct dst_ops *ops)
94944 {
94945 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94946
94947 - xfrm6_policy_afinfo.garbage_collect(net);
94948 + xfrm_garbage_collect_deferred(net);
94949 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94950 }
94951
94952 @@ -325,19 +325,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94953
94954 static int __net_init xfrm6_net_init(struct net *net)
94955 {
94956 - struct ctl_table *table;
94957 + ctl_table_no_const *table = NULL;
94958 struct ctl_table_header *hdr;
94959
94960 - table = xfrm6_policy_table;
94961 if (!net_eq(net, &init_net)) {
94962 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94963 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94964 if (!table)
94965 goto err_alloc;
94966
94967 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94968 - }
94969 + hdr = register_net_sysctl(net, "net/ipv6", table);
94970 + } else
94971 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94972
94973 - hdr = register_net_sysctl(net, "net/ipv6", table);
94974 if (!hdr)
94975 goto err_reg;
94976
94977 @@ -345,8 +345,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94978 return 0;
94979
94980 err_reg:
94981 - if (!net_eq(net, &init_net))
94982 - kfree(table);
94983 + kfree(table);
94984 err_alloc:
94985 return -ENOMEM;
94986 }
94987 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94988 index 41ac7938..75e3bb1 100644
94989 --- a/net/irda/ircomm/ircomm_tty.c
94990 +++ b/net/irda/ircomm/ircomm_tty.c
94991 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94992 add_wait_queue(&port->open_wait, &wait);
94993
94994 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94995 - __FILE__, __LINE__, tty->driver->name, port->count);
94996 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94997
94998 spin_lock_irqsave(&port->lock, flags);
94999 if (!tty_hung_up_p(filp))
95000 - port->count--;
95001 + atomic_dec(&port->count);
95002 port->blocked_open++;
95003 spin_unlock_irqrestore(&port->lock, flags);
95004
95005 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95006 }
95007
95008 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95009 - __FILE__, __LINE__, tty->driver->name, port->count);
95010 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95011
95012 schedule();
95013 }
95014 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95015
95016 spin_lock_irqsave(&port->lock, flags);
95017 if (!tty_hung_up_p(filp))
95018 - port->count++;
95019 + atomic_inc(&port->count);
95020 port->blocked_open--;
95021 spin_unlock_irqrestore(&port->lock, flags);
95022
95023 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95024 - __FILE__, __LINE__, tty->driver->name, port->count);
95025 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95026
95027 if (!retval)
95028 port->flags |= ASYNC_NORMAL_ACTIVE;
95029 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95030
95031 /* ++ is not atomic, so this should be protected - Jean II */
95032 spin_lock_irqsave(&self->port.lock, flags);
95033 - self->port.count++;
95034 + atomic_inc(&self->port.count);
95035 spin_unlock_irqrestore(&self->port.lock, flags);
95036 tty_port_tty_set(&self->port, tty);
95037
95038 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95039 - self->line, self->port.count);
95040 + self->line, atomic_read(&self->port.count));
95041
95042 /* Not really used by us, but lets do it anyway */
95043 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95044 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95045 tty_kref_put(port->tty);
95046 }
95047 port->tty = NULL;
95048 - port->count = 0;
95049 + atomic_set(&port->count, 0);
95050 spin_unlock_irqrestore(&port->lock, flags);
95051
95052 wake_up_interruptible(&port->open_wait);
95053 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95054 seq_putc(m, '\n');
95055
95056 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95057 - seq_printf(m, "Open count: %d\n", self->port.count);
95058 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95059 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95060 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95061
95062 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95063 index 168aff5..9d43132 100644
95064 --- a/net/iucv/af_iucv.c
95065 +++ b/net/iucv/af_iucv.c
95066 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95067
95068 write_lock_bh(&iucv_sk_list.lock);
95069
95070 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95071 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95072 while (__iucv_get_sock_by_name(name)) {
95073 sprintf(name, "%08x",
95074 - atomic_inc_return(&iucv_sk_list.autobind_name));
95075 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95076 }
95077
95078 write_unlock_bh(&iucv_sk_list.lock);
95079 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95080 index cd5b8ec..f205e6b 100644
95081 --- a/net/iucv/iucv.c
95082 +++ b/net/iucv/iucv.c
95083 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
95084 return NOTIFY_OK;
95085 }
95086
95087 -static struct notifier_block __refdata iucv_cpu_notifier = {
95088 +static struct notifier_block iucv_cpu_notifier = {
95089 .notifier_call = iucv_cpu_notify,
95090 };
95091
95092 diff --git a/net/key/af_key.c b/net/key/af_key.c
95093 index 911ef03..58f9c96 100644
95094 --- a/net/key/af_key.c
95095 +++ b/net/key/af_key.c
95096 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95097 static u32 get_acqseq(void)
95098 {
95099 u32 res;
95100 - static atomic_t acqseq;
95101 + static atomic_unchecked_t acqseq;
95102
95103 do {
95104 - res = atomic_inc_return(&acqseq);
95105 + res = atomic_inc_return_unchecked(&acqseq);
95106 } while (!res);
95107 return res;
95108 }
95109 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95110 index 629dee7..4bdd2c8 100644
95111 --- a/net/mac80211/cfg.c
95112 +++ b/net/mac80211/cfg.c
95113 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95114 ret = ieee80211_vif_use_channel(sdata, chandef,
95115 IEEE80211_CHANCTX_EXCLUSIVE);
95116 }
95117 - } else if (local->open_count == local->monitors) {
95118 + } else if (local_read(&local->open_count) == local->monitors) {
95119 local->_oper_chandef = *chandef;
95120 ieee80211_hw_config(local, 0);
95121 }
95122 @@ -3125,7 +3125,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95123 else
95124 local->probe_req_reg--;
95125
95126 - if (!local->open_count)
95127 + if (!local_read(&local->open_count))
95128 break;
95129
95130 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95131 @@ -3588,8 +3588,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95132 if (chanctx_conf) {
95133 *chandef = chanctx_conf->def;
95134 ret = 0;
95135 - } else if (local->open_count > 0 &&
95136 - local->open_count == local->monitors &&
95137 + } else if (local_read(&local->open_count) > 0 &&
95138 + local_read(&local->open_count) == local->monitors &&
95139 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95140 if (local->use_chanctx)
95141 *chandef = local->monitor_chandef;
95142 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95143 index 611abfc..8c2c7e4 100644
95144 --- a/net/mac80211/ieee80211_i.h
95145 +++ b/net/mac80211/ieee80211_i.h
95146 @@ -28,6 +28,7 @@
95147 #include <net/ieee80211_radiotap.h>
95148 #include <net/cfg80211.h>
95149 #include <net/mac80211.h>
95150 +#include <asm/local.h>
95151 #include "key.h"
95152 #include "sta_info.h"
95153 #include "debug.h"
95154 @@ -945,7 +946,7 @@ struct ieee80211_local {
95155 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95156 spinlock_t queue_stop_reason_lock;
95157
95158 - int open_count;
95159 + local_t open_count;
95160 int monitors, cooked_mntrs;
95161 /* number of interfaces with corresponding FIF_ flags */
95162 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95163 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95164 index fcecd63..a404454 100644
95165 --- a/net/mac80211/iface.c
95166 +++ b/net/mac80211/iface.c
95167 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95168 break;
95169 }
95170
95171 - if (local->open_count == 0) {
95172 + if (local_read(&local->open_count) == 0) {
95173 res = drv_start(local);
95174 if (res)
95175 goto err_del_bss;
95176 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95177 res = drv_add_interface(local, sdata);
95178 if (res)
95179 goto err_stop;
95180 - } else if (local->monitors == 0 && local->open_count == 0) {
95181 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95182 res = ieee80211_add_virtual_monitor(local);
95183 if (res)
95184 goto err_stop;
95185 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95186 atomic_inc(&local->iff_promiscs);
95187
95188 if (coming_up)
95189 - local->open_count++;
95190 + local_inc(&local->open_count);
95191
95192 if (hw_reconf_flags)
95193 ieee80211_hw_config(local, hw_reconf_flags);
95194 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95195 err_del_interface:
95196 drv_remove_interface(local, sdata);
95197 err_stop:
95198 - if (!local->open_count)
95199 + if (!local_read(&local->open_count))
95200 drv_stop(local);
95201 err_del_bss:
95202 sdata->bss = NULL;
95203 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95204 }
95205
95206 if (going_down)
95207 - local->open_count--;
95208 + local_dec(&local->open_count);
95209
95210 switch (sdata->vif.type) {
95211 case NL80211_IFTYPE_AP_VLAN:
95212 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95213 }
95214 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95215
95216 - if (local->open_count == 0)
95217 + if (local_read(&local->open_count) == 0)
95218 ieee80211_clear_tx_pending(local);
95219
95220 /*
95221 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95222
95223 ieee80211_recalc_ps(local, -1);
95224
95225 - if (local->open_count == 0) {
95226 + if (local_read(&local->open_count) == 0) {
95227 ieee80211_stop_device(local);
95228
95229 /* no reconfiguring after stop! */
95230 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95231 ieee80211_configure_filter(local);
95232 ieee80211_hw_config(local, hw_reconf_flags);
95233
95234 - if (local->monitors == local->open_count)
95235 + if (local->monitors == local_read(&local->open_count))
95236 ieee80211_add_virtual_monitor(local);
95237 }
95238
95239 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
95240 index 21d5d44..4fee18a 100644
95241 --- a/net/mac80211/main.c
95242 +++ b/net/mac80211/main.c
95243 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
95244 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
95245 IEEE80211_CONF_CHANGE_POWER);
95246
95247 - if (changed && local->open_count) {
95248 + if (changed && local_read(&local->open_count)) {
95249 ret = drv_config(local, changed);
95250 /*
95251 * Goal:
95252 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
95253 index 3401262..d5cd68d 100644
95254 --- a/net/mac80211/pm.c
95255 +++ b/net/mac80211/pm.c
95256 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95257 struct ieee80211_sub_if_data *sdata;
95258 struct sta_info *sta;
95259
95260 - if (!local->open_count)
95261 + if (!local_read(&local->open_count))
95262 goto suspend;
95263
95264 ieee80211_scan_cancel(local);
95265 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95266 cancel_work_sync(&local->dynamic_ps_enable_work);
95267 del_timer_sync(&local->dynamic_ps_timer);
95268
95269 - local->wowlan = wowlan && local->open_count;
95270 + local->wowlan = wowlan && local_read(&local->open_count);
95271 if (local->wowlan) {
95272 int err = drv_suspend(local, wowlan);
95273 if (err < 0) {
95274 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95275 WARN_ON(!list_empty(&local->chanctx_list));
95276
95277 /* stop hardware - this must stop RX */
95278 - if (local->open_count)
95279 + if (local_read(&local->open_count))
95280 ieee80211_stop_device(local);
95281
95282 suspend:
95283 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
95284 index e126605..73d2c39 100644
95285 --- a/net/mac80211/rate.c
95286 +++ b/net/mac80211/rate.c
95287 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
95288
95289 ASSERT_RTNL();
95290
95291 - if (local->open_count)
95292 + if (local_read(&local->open_count))
95293 return -EBUSY;
95294
95295 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
95296 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
95297 index c97a065..ff61928 100644
95298 --- a/net/mac80211/rc80211_pid_debugfs.c
95299 +++ b/net/mac80211/rc80211_pid_debugfs.c
95300 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
95301
95302 spin_unlock_irqrestore(&events->lock, status);
95303
95304 - if (copy_to_user(buf, pb, p))
95305 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
95306 return -EFAULT;
95307
95308 return p;
95309 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
95310 index 69e4ef5..e8e4b92 100644
95311 --- a/net/mac80211/util.c
95312 +++ b/net/mac80211/util.c
95313 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95314 }
95315 #endif
95316 /* everything else happens only if HW was up & running */
95317 - if (!local->open_count)
95318 + if (!local_read(&local->open_count))
95319 goto wake_up;
95320
95321 /*
95322 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95323 local->in_reconfig = false;
95324 barrier();
95325
95326 - if (local->monitors == local->open_count && local->monitors > 0)
95327 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
95328 ieee80211_add_virtual_monitor(local);
95329
95330 /*
95331 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
95332 index 6e839b6..002a233 100644
95333 --- a/net/netfilter/Kconfig
95334 +++ b/net/netfilter/Kconfig
95335 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
95336
95337 To compile it as a module, choose M here. If unsure, say N.
95338
95339 +config NETFILTER_XT_MATCH_GRADM
95340 + tristate '"gradm" match support'
95341 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
95342 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
95343 + ---help---
95344 + The gradm match allows to match on grsecurity RBAC being enabled.
95345 + It is useful when iptables rules are applied early on bootup to
95346 + prevent connections to the machine (except from a trusted host)
95347 + while the RBAC system is disabled.
95348 +
95349 config NETFILTER_XT_MATCH_HASHLIMIT
95350 tristate '"hashlimit" match support'
95351 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
95352 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
95353 index c3a0a12..90b587f 100644
95354 --- a/net/netfilter/Makefile
95355 +++ b/net/netfilter/Makefile
95356 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
95357 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
95358 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
95359 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
95360 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
95361 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
95362 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
95363 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
95364 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
95365 index f2e30fb..f131862 100644
95366 --- a/net/netfilter/ipset/ip_set_core.c
95367 +++ b/net/netfilter/ipset/ip_set_core.c
95368 @@ -1819,7 +1819,7 @@ done:
95369 return ret;
95370 }
95371
95372 -static struct nf_sockopt_ops so_set __read_mostly = {
95373 +static struct nf_sockopt_ops so_set = {
95374 .pf = PF_INET,
95375 .get_optmin = SO_IP_SET,
95376 .get_optmax = SO_IP_SET + 1,
95377 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
95378 index 4c8e5c0..5a79b4d 100644
95379 --- a/net/netfilter/ipvs/ip_vs_conn.c
95380 +++ b/net/netfilter/ipvs/ip_vs_conn.c
95381 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
95382 /* Increase the refcnt counter of the dest */
95383 ip_vs_dest_hold(dest);
95384
95385 - conn_flags = atomic_read(&dest->conn_flags);
95386 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
95387 if (cp->protocol != IPPROTO_UDP)
95388 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
95389 flags = cp->flags;
95390 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
95391
95392 cp->control = NULL;
95393 atomic_set(&cp->n_control, 0);
95394 - atomic_set(&cp->in_pkts, 0);
95395 + atomic_set_unchecked(&cp->in_pkts, 0);
95396
95397 cp->packet_xmit = NULL;
95398 cp->app = NULL;
95399 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
95400
95401 /* Don't drop the entry if its number of incoming packets is not
95402 located in [0, 8] */
95403 - i = atomic_read(&cp->in_pkts);
95404 + i = atomic_read_unchecked(&cp->in_pkts);
95405 if (i > 8 || i < 0) return 0;
95406
95407 if (!todrop_rate[i]) return 0;
95408 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
95409 index 74fd00c..06e7ac7 100644
95410 --- a/net/netfilter/ipvs/ip_vs_core.c
95411 +++ b/net/netfilter/ipvs/ip_vs_core.c
95412 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
95413 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
95414 /* do not touch skb anymore */
95415
95416 - atomic_inc(&cp->in_pkts);
95417 + atomic_inc_unchecked(&cp->in_pkts);
95418 ip_vs_conn_put(cp);
95419 return ret;
95420 }
95421 @@ -1719,7 +1719,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
95422 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
95423 pkts = sysctl_sync_threshold(ipvs);
95424 else
95425 - pkts = atomic_add_return(1, &cp->in_pkts);
95426 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95427
95428 if (ipvs->sync_state & IP_VS_STATE_MASTER)
95429 ip_vs_sync_conn(net, cp, pkts);
95430 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
95431 index a3df9bd..895ae09 100644
95432 --- a/net/netfilter/ipvs/ip_vs_ctl.c
95433 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
95434 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
95435 */
95436 ip_vs_rs_hash(ipvs, dest);
95437 }
95438 - atomic_set(&dest->conn_flags, conn_flags);
95439 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
95440
95441 /* bind the service */
95442 old_svc = rcu_dereference_protected(dest->svc, 1);
95443 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
95444 * align with netns init in ip_vs_control_net_init()
95445 */
95446
95447 -static struct ctl_table vs_vars[] = {
95448 +static ctl_table_no_const vs_vars[] __read_only = {
95449 {
95450 .procname = "amemthresh",
95451 .maxlen = sizeof(int),
95452 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95453 " %-7s %-6d %-10d %-10d\n",
95454 &dest->addr.in6,
95455 ntohs(dest->port),
95456 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95457 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95458 atomic_read(&dest->weight),
95459 atomic_read(&dest->activeconns),
95460 atomic_read(&dest->inactconns));
95461 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95462 "%-7s %-6d %-10d %-10d\n",
95463 ntohl(dest->addr.ip),
95464 ntohs(dest->port),
95465 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95466 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95467 atomic_read(&dest->weight),
95468 atomic_read(&dest->activeconns),
95469 atomic_read(&dest->inactconns));
95470 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
95471
95472 entry.addr = dest->addr.ip;
95473 entry.port = dest->port;
95474 - entry.conn_flags = atomic_read(&dest->conn_flags);
95475 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
95476 entry.weight = atomic_read(&dest->weight);
95477 entry.u_threshold = dest->u_threshold;
95478 entry.l_threshold = dest->l_threshold;
95479 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
95480 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
95481 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
95482 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
95483 - (atomic_read(&dest->conn_flags) &
95484 + (atomic_read_unchecked(&dest->conn_flags) &
95485 IP_VS_CONN_F_FWD_MASK)) ||
95486 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
95487 atomic_read(&dest->weight)) ||
95488 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
95489 {
95490 int idx;
95491 struct netns_ipvs *ipvs = net_ipvs(net);
95492 - struct ctl_table *tbl;
95493 + ctl_table_no_const *tbl;
95494
95495 atomic_set(&ipvs->dropentry, 0);
95496 spin_lock_init(&ipvs->dropentry_lock);
95497 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
95498 index eff13c9..c1aab3e 100644
95499 --- a/net/netfilter/ipvs/ip_vs_lblc.c
95500 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
95501 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
95502 * IPVS LBLC sysctl table
95503 */
95504 #ifdef CONFIG_SYSCTL
95505 -static struct ctl_table vs_vars_table[] = {
95506 +static ctl_table_no_const vs_vars_table[] __read_only = {
95507 {
95508 .procname = "lblc_expiration",
95509 .data = NULL,
95510 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
95511 index 0b85500..8513fa5 100644
95512 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
95513 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
95514 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
95515 * IPVS LBLCR sysctl table
95516 */
95517
95518 -static struct ctl_table vs_vars_table[] = {
95519 +static ctl_table_no_const vs_vars_table[] __read_only = {
95520 {
95521 .procname = "lblcr_expiration",
95522 .data = NULL,
95523 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
95524 index f448471..995f131 100644
95525 --- a/net/netfilter/ipvs/ip_vs_sync.c
95526 +++ b/net/netfilter/ipvs/ip_vs_sync.c
95527 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
95528 cp = cp->control;
95529 if (cp) {
95530 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95531 - pkts = atomic_add_return(1, &cp->in_pkts);
95532 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95533 else
95534 pkts = sysctl_sync_threshold(ipvs);
95535 ip_vs_sync_conn(net, cp->control, pkts);
95536 @@ -771,7 +771,7 @@ control:
95537 if (!cp)
95538 return;
95539 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95540 - pkts = atomic_add_return(1, &cp->in_pkts);
95541 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95542 else
95543 pkts = sysctl_sync_threshold(ipvs);
95544 goto sloop;
95545 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
95546
95547 if (opt)
95548 memcpy(&cp->in_seq, opt, sizeof(*opt));
95549 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95550 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95551 cp->state = state;
95552 cp->old_state = cp->state;
95553 /*
95554 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
95555 index c47444e..b0961c6 100644
95556 --- a/net/netfilter/ipvs/ip_vs_xmit.c
95557 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
95558 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
95559 else
95560 rc = NF_ACCEPT;
95561 /* do not touch skb anymore */
95562 - atomic_inc(&cp->in_pkts);
95563 + atomic_inc_unchecked(&cp->in_pkts);
95564 goto out;
95565 }
95566
95567 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
95568 else
95569 rc = NF_ACCEPT;
95570 /* do not touch skb anymore */
95571 - atomic_inc(&cp->in_pkts);
95572 + atomic_inc_unchecked(&cp->in_pkts);
95573 goto out;
95574 }
95575
95576 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
95577 index 2d3030a..7ba1c0a 100644
95578 --- a/net/netfilter/nf_conntrack_acct.c
95579 +++ b/net/netfilter/nf_conntrack_acct.c
95580 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
95581 #ifdef CONFIG_SYSCTL
95582 static int nf_conntrack_acct_init_sysctl(struct net *net)
95583 {
95584 - struct ctl_table *table;
95585 + ctl_table_no_const *table;
95586
95587 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
95588 GFP_KERNEL);
95589 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
95590 index 5d892fe..d2fc9d8 100644
95591 --- a/net/netfilter/nf_conntrack_core.c
95592 +++ b/net/netfilter/nf_conntrack_core.c
95593 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
95594 #define DYING_NULLS_VAL ((1<<30)+1)
95595 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
95596
95597 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95598 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
95599 +#endif
95600 +
95601 int nf_conntrack_init_net(struct net *net)
95602 {
95603 int ret;
95604 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
95605 goto err_stat;
95606 }
95607
95608 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95609 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
95610 +#else
95611 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
95612 +#endif
95613 if (!net->ct.slabname) {
95614 ret = -ENOMEM;
95615 goto err_slabname;
95616 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
95617 index 1df1761..ce8b88a 100644
95618 --- a/net/netfilter/nf_conntrack_ecache.c
95619 +++ b/net/netfilter/nf_conntrack_ecache.c
95620 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
95621 #ifdef CONFIG_SYSCTL
95622 static int nf_conntrack_event_init_sysctl(struct net *net)
95623 {
95624 - struct ctl_table *table;
95625 + ctl_table_no_const *table;
95626
95627 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
95628 GFP_KERNEL);
95629 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
95630 index 974a2a4..52cc6ff 100644
95631 --- a/net/netfilter/nf_conntrack_helper.c
95632 +++ b/net/netfilter/nf_conntrack_helper.c
95633 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
95634
95635 static int nf_conntrack_helper_init_sysctl(struct net *net)
95636 {
95637 - struct ctl_table *table;
95638 + ctl_table_no_const *table;
95639
95640 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
95641 GFP_KERNEL);
95642 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
95643 index ce30041..3861b5d 100644
95644 --- a/net/netfilter/nf_conntrack_proto.c
95645 +++ b/net/netfilter/nf_conntrack_proto.c
95646 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
95647
95648 static void
95649 nf_ct_unregister_sysctl(struct ctl_table_header **header,
95650 - struct ctl_table **table,
95651 + ctl_table_no_const **table,
95652 unsigned int users)
95653 {
95654 if (users > 0)
95655 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
95656 index a99b6c3..cb372f9 100644
95657 --- a/net/netfilter/nf_conntrack_proto_dccp.c
95658 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
95659 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95660 const char *msg;
95661 u_int8_t state;
95662
95663 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95664 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95665 BUG_ON(dh == NULL);
95666
95667 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
95668 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95669 out_invalid:
95670 if (LOG_INVALID(net, IPPROTO_DCCP))
95671 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
95672 - NULL, msg);
95673 + NULL, "%s", msg);
95674 return false;
95675 }
95676
95677 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
95678 u_int8_t type, old_state, new_state;
95679 enum ct_dccp_roles role;
95680
95681 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95682 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95683 BUG_ON(dh == NULL);
95684 type = dh->dccph_type;
95685
95686 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95687 unsigned int cscov;
95688 const char *msg;
95689
95690 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95691 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95692 if (dh == NULL) {
95693 msg = "nf_ct_dccp: short packet ";
95694 goto out_invalid;
95695 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95696
95697 out_invalid:
95698 if (LOG_INVALID(net, IPPROTO_DCCP))
95699 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
95700 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
95701 return -NF_ACCEPT;
95702 }
95703
95704 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
95705 index f641751..d3c5b51 100644
95706 --- a/net/netfilter/nf_conntrack_standalone.c
95707 +++ b/net/netfilter/nf_conntrack_standalone.c
95708 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
95709
95710 static int nf_conntrack_standalone_init_sysctl(struct net *net)
95711 {
95712 - struct ctl_table *table;
95713 + ctl_table_no_const *table;
95714
95715 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
95716 GFP_KERNEL);
95717 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
95718 index 902fb0a..87f7fdb 100644
95719 --- a/net/netfilter/nf_conntrack_timestamp.c
95720 +++ b/net/netfilter/nf_conntrack_timestamp.c
95721 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
95722 #ifdef CONFIG_SYSCTL
95723 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
95724 {
95725 - struct ctl_table *table;
95726 + ctl_table_no_const *table;
95727
95728 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
95729 GFP_KERNEL);
95730 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
95731 index 85296d4..8becdec 100644
95732 --- a/net/netfilter/nf_log.c
95733 +++ b/net/netfilter/nf_log.c
95734 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
95735
95736 #ifdef CONFIG_SYSCTL
95737 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
95738 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
95739 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
95740
95741 static int nf_log_proc_dostring(struct ctl_table *table, int write,
95742 void __user *buffer, size_t *lenp, loff_t *ppos)
95743 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
95744 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
95745 mutex_unlock(&nf_log_mutex);
95746 } else {
95747 + ctl_table_no_const nf_log_table = *table;
95748 +
95749 mutex_lock(&nf_log_mutex);
95750 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
95751 lockdep_is_held(&nf_log_mutex));
95752 if (!logger)
95753 - table->data = "NONE";
95754 + nf_log_table.data = "NONE";
95755 else
95756 - table->data = logger->name;
95757 - r = proc_dostring(table, write, buffer, lenp, ppos);
95758 + nf_log_table.data = logger->name;
95759 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
95760 mutex_unlock(&nf_log_mutex);
95761 }
95762
95763 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95764 index f042ae5..30ea486 100644
95765 --- a/net/netfilter/nf_sockopt.c
95766 +++ b/net/netfilter/nf_sockopt.c
95767 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95768 }
95769 }
95770
95771 - list_add(&reg->list, &nf_sockopts);
95772 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95773 out:
95774 mutex_unlock(&nf_sockopt_mutex);
95775 return ret;
95776 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95777 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95778 {
95779 mutex_lock(&nf_sockopt_mutex);
95780 - list_del(&reg->list);
95781 + pax_list_del((struct list_head *)&reg->list);
95782 mutex_unlock(&nf_sockopt_mutex);
95783 }
95784 EXPORT_SYMBOL(nf_unregister_sockopt);
95785 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95786 index d92cc31..e46f350 100644
95787 --- a/net/netfilter/nfnetlink_log.c
95788 +++ b/net/netfilter/nfnetlink_log.c
95789 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95790 struct nfnl_log_net {
95791 spinlock_t instances_lock;
95792 struct hlist_head instance_table[INSTANCE_BUCKETS];
95793 - atomic_t global_seq;
95794 + atomic_unchecked_t global_seq;
95795 };
95796
95797 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95798 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95799 /* global sequence number */
95800 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95801 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95802 - htonl(atomic_inc_return(&log->global_seq))))
95803 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95804 goto nla_put_failure;
95805
95806 if (data_len) {
95807 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95808 new file mode 100644
95809 index 0000000..c566332
95810 --- /dev/null
95811 +++ b/net/netfilter/xt_gradm.c
95812 @@ -0,0 +1,51 @@
95813 +/*
95814 + * gradm match for netfilter
95815 + * Copyright © Zbigniew Krzystolik, 2010
95816 + *
95817 + * This program is free software; you can redistribute it and/or modify
95818 + * it under the terms of the GNU General Public License; either version
95819 + * 2 or 3 as published by the Free Software Foundation.
95820 + */
95821 +#include <linux/module.h>
95822 +#include <linux/moduleparam.h>
95823 +#include <linux/skbuff.h>
95824 +#include <linux/netfilter/x_tables.h>
95825 +#include <linux/grsecurity.h>
95826 +#include <linux/netfilter/xt_gradm.h>
95827 +
95828 +static bool
95829 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95830 +{
95831 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95832 + bool retval = false;
95833 + if (gr_acl_is_enabled())
95834 + retval = true;
95835 + return retval ^ info->invflags;
95836 +}
95837 +
95838 +static struct xt_match gradm_mt_reg __read_mostly = {
95839 + .name = "gradm",
95840 + .revision = 0,
95841 + .family = NFPROTO_UNSPEC,
95842 + .match = gradm_mt,
95843 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
95844 + .me = THIS_MODULE,
95845 +};
95846 +
95847 +static int __init gradm_mt_init(void)
95848 +{
95849 + return xt_register_match(&gradm_mt_reg);
95850 +}
95851 +
95852 +static void __exit gradm_mt_exit(void)
95853 +{
95854 + xt_unregister_match(&gradm_mt_reg);
95855 +}
95856 +
95857 +module_init(gradm_mt_init);
95858 +module_exit(gradm_mt_exit);
95859 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95860 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95861 +MODULE_LICENSE("GPL");
95862 +MODULE_ALIAS("ipt_gradm");
95863 +MODULE_ALIAS("ip6t_gradm");
95864 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95865 index 4fe4fb4..87a89e5 100644
95866 --- a/net/netfilter/xt_statistic.c
95867 +++ b/net/netfilter/xt_statistic.c
95868 @@ -19,7 +19,7 @@
95869 #include <linux/module.h>
95870
95871 struct xt_statistic_priv {
95872 - atomic_t count;
95873 + atomic_unchecked_t count;
95874 } ____cacheline_aligned_in_smp;
95875
95876 MODULE_LICENSE("GPL");
95877 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95878 break;
95879 case XT_STATISTIC_MODE_NTH:
95880 do {
95881 - oval = atomic_read(&info->master->count);
95882 + oval = atomic_read_unchecked(&info->master->count);
95883 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95884 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95885 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95886 if (nval == 0)
95887 ret = !ret;
95888 break;
95889 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95890 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95891 if (info->master == NULL)
95892 return -ENOMEM;
95893 - atomic_set(&info->master->count, info->u.nth.count);
95894 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95895
95896 return 0;
95897 }
95898 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95899 index 8df7f64..c5d6821 100644
95900 --- a/net/netlink/af_netlink.c
95901 +++ b/net/netlink/af_netlink.c
95902 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
95903 sk->sk_error_report(sk);
95904 }
95905 }
95906 - atomic_inc(&sk->sk_drops);
95907 + atomic_inc_unchecked(&sk->sk_drops);
95908 }
95909
95910 static void netlink_rcv_wake(struct sock *sk)
95911 @@ -2942,7 +2942,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95912 sk_wmem_alloc_get(s),
95913 nlk->cb_running,
95914 atomic_read(&s->sk_refcnt),
95915 - atomic_read(&s->sk_drops),
95916 + atomic_read_unchecked(&s->sk_drops),
95917 sock_i_ino(s)
95918 );
95919
95920 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95921 index 0c741ce..f8c8ca7 100644
95922 --- a/net/netlink/genetlink.c
95923 +++ b/net/netlink/genetlink.c
95924 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95925 goto errout;
95926 }
95927
95928 + pax_open_kernel();
95929 if (ops->dumpit)
95930 - ops->flags |= GENL_CMD_CAP_DUMP;
95931 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95932 if (ops->doit)
95933 - ops->flags |= GENL_CMD_CAP_DO;
95934 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95935 if (ops->policy)
95936 - ops->flags |= GENL_CMD_CAP_HASPOL;
95937 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95938 + pax_close_kernel();
95939
95940 genl_lock_all();
95941 - list_add_tail(&ops->ops_list, &family->ops_list);
95942 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95943 genl_unlock_all();
95944
95945 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95946 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95947 err = 0;
95948 errout:
95949 return err;
95950 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95951 genl_lock_all();
95952 list_for_each_entry(rc, &family->ops_list, ops_list) {
95953 if (rc == ops) {
95954 - list_del(&ops->ops_list);
95955 + pax_list_del((struct list_head *)&ops->ops_list);
95956 genl_unlock_all();
95957 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95958 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95959 return 0;
95960 }
95961 }
95962 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95963 index 698814b..7cfde4e 100644
95964 --- a/net/netrom/af_netrom.c
95965 +++ b/net/netrom/af_netrom.c
95966 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95967 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95968 } else {
95969 sax->fsa_ax25.sax25_family = AF_NETROM;
95970 - sax->fsa_ax25.sax25_ndigis = 0;
95971 sax->fsa_ax25.sax25_call = nr->source_addr;
95972 *uaddr_len = sizeof(struct sockaddr_ax25);
95973 }
95974 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95975 index 2e8286b..b2659ee 100644
95976 --- a/net/packet/af_packet.c
95977 +++ b/net/packet/af_packet.c
95978 @@ -1692,7 +1692,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95979
95980 spin_lock(&sk->sk_receive_queue.lock);
95981 po->stats.stats1.tp_packets++;
95982 - skb->dropcount = atomic_read(&sk->sk_drops);
95983 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95984 __skb_queue_tail(&sk->sk_receive_queue, skb);
95985 spin_unlock(&sk->sk_receive_queue.lock);
95986 sk->sk_data_ready(sk, skb->len);
95987 @@ -1701,7 +1701,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95988 drop_n_acct:
95989 spin_lock(&sk->sk_receive_queue.lock);
95990 po->stats.stats1.tp_drops++;
95991 - atomic_inc(&sk->sk_drops);
95992 + atomic_inc_unchecked(&sk->sk_drops);
95993 spin_unlock(&sk->sk_receive_queue.lock);
95994
95995 drop_n_restore:
95996 @@ -3250,7 +3250,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95997 case PACKET_HDRLEN:
95998 if (len > sizeof(int))
95999 len = sizeof(int);
96000 - if (copy_from_user(&val, optval, len))
96001 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96002 return -EFAULT;
96003 switch (val) {
96004 case TPACKET_V1:
96005 @@ -3293,7 +3293,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96006 len = lv;
96007 if (put_user(len, optlen))
96008 return -EFAULT;
96009 - if (copy_to_user(optval, data, len))
96010 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96011 return -EFAULT;
96012 return 0;
96013 }
96014 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96015 index e774117..900b8b7 100644
96016 --- a/net/phonet/pep.c
96017 +++ b/net/phonet/pep.c
96018 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96019
96020 case PNS_PEP_CTRL_REQ:
96021 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96022 - atomic_inc(&sk->sk_drops);
96023 + atomic_inc_unchecked(&sk->sk_drops);
96024 break;
96025 }
96026 __skb_pull(skb, 4);
96027 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96028 }
96029
96030 if (pn->rx_credits == 0) {
96031 - atomic_inc(&sk->sk_drops);
96032 + atomic_inc_unchecked(&sk->sk_drops);
96033 err = -ENOBUFS;
96034 break;
96035 }
96036 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96037 }
96038
96039 if (pn->rx_credits == 0) {
96040 - atomic_inc(&sk->sk_drops);
96041 + atomic_inc_unchecked(&sk->sk_drops);
96042 err = NET_RX_DROP;
96043 break;
96044 }
96045 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96046 index 77e38f7..f4ef5c3 100644
96047 --- a/net/phonet/socket.c
96048 +++ b/net/phonet/socket.c
96049 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96050 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96051 sock_i_ino(sk),
96052 atomic_read(&sk->sk_refcnt), sk,
96053 - atomic_read(&sk->sk_drops), &len);
96054 + atomic_read_unchecked(&sk->sk_drops), &len);
96055 }
96056 seq_printf(seq, "%*s\n", 127 - len, "");
96057 return 0;
96058 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96059 index c02a8c4..3c5b600 100644
96060 --- a/net/phonet/sysctl.c
96061 +++ b/net/phonet/sysctl.c
96062 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
96063 {
96064 int ret;
96065 int range[2] = {local_port_range[0], local_port_range[1]};
96066 - struct ctl_table tmp = {
96067 + ctl_table_no_const tmp = {
96068 .data = &range,
96069 .maxlen = sizeof(range),
96070 .mode = table->mode,
96071 diff --git a/net/rds/cong.c b/net/rds/cong.c
96072 index e5b65ac..f3b6fb7 100644
96073 --- a/net/rds/cong.c
96074 +++ b/net/rds/cong.c
96075 @@ -78,7 +78,7 @@
96076 * finds that the saved generation number is smaller than the global generation
96077 * number, it wakes up the process.
96078 */
96079 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96080 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96081
96082 /*
96083 * Congestion monitoring
96084 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96085 rdsdebug("waking map %p for %pI4\n",
96086 map, &map->m_addr);
96087 rds_stats_inc(s_cong_update_received);
96088 - atomic_inc(&rds_cong_generation);
96089 + atomic_inc_unchecked(&rds_cong_generation);
96090 if (waitqueue_active(&map->m_waitq))
96091 wake_up(&map->m_waitq);
96092 if (waitqueue_active(&rds_poll_waitq))
96093 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96094
96095 int rds_cong_updated_since(unsigned long *recent)
96096 {
96097 - unsigned long gen = atomic_read(&rds_cong_generation);
96098 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96099
96100 if (likely(*recent == gen))
96101 return 0;
96102 diff --git a/net/rds/ib.h b/net/rds/ib.h
96103 index 7280ab8..e04f4ea 100644
96104 --- a/net/rds/ib.h
96105 +++ b/net/rds/ib.h
96106 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96107 /* sending acks */
96108 unsigned long i_ack_flags;
96109 #ifdef KERNEL_HAS_ATOMIC64
96110 - atomic64_t i_ack_next; /* next ACK to send */
96111 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96112 #else
96113 spinlock_t i_ack_lock; /* protect i_ack_next */
96114 u64 i_ack_next; /* next ACK to send */
96115 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96116 index 31b74f5..dc1fbfa 100644
96117 --- a/net/rds/ib_cm.c
96118 +++ b/net/rds/ib_cm.c
96119 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96120 /* Clear the ACK state */
96121 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96122 #ifdef KERNEL_HAS_ATOMIC64
96123 - atomic64_set(&ic->i_ack_next, 0);
96124 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96125 #else
96126 ic->i_ack_next = 0;
96127 #endif
96128 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96129 index 8eb9501..0c386ff 100644
96130 --- a/net/rds/ib_recv.c
96131 +++ b/net/rds/ib_recv.c
96132 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96133 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96134 int ack_required)
96135 {
96136 - atomic64_set(&ic->i_ack_next, seq);
96137 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96138 if (ack_required) {
96139 smp_mb__before_clear_bit();
96140 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96141 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96142 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96143 smp_mb__after_clear_bit();
96144
96145 - return atomic64_read(&ic->i_ack_next);
96146 + return atomic64_read_unchecked(&ic->i_ack_next);
96147 }
96148 #endif
96149
96150 diff --git a/net/rds/iw.h b/net/rds/iw.h
96151 index 04ce3b1..48119a6 100644
96152 --- a/net/rds/iw.h
96153 +++ b/net/rds/iw.h
96154 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96155 /* sending acks */
96156 unsigned long i_ack_flags;
96157 #ifdef KERNEL_HAS_ATOMIC64
96158 - atomic64_t i_ack_next; /* next ACK to send */
96159 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96160 #else
96161 spinlock_t i_ack_lock; /* protect i_ack_next */
96162 u64 i_ack_next; /* next ACK to send */
96163 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96164 index a91e1db..cf3053f 100644
96165 --- a/net/rds/iw_cm.c
96166 +++ b/net/rds/iw_cm.c
96167 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96168 /* Clear the ACK state */
96169 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96170 #ifdef KERNEL_HAS_ATOMIC64
96171 - atomic64_set(&ic->i_ack_next, 0);
96172 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96173 #else
96174 ic->i_ack_next = 0;
96175 #endif
96176 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96177 index 4503335..db566b4 100644
96178 --- a/net/rds/iw_recv.c
96179 +++ b/net/rds/iw_recv.c
96180 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96181 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
96182 int ack_required)
96183 {
96184 - atomic64_set(&ic->i_ack_next, seq);
96185 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96186 if (ack_required) {
96187 smp_mb__before_clear_bit();
96188 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96189 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96190 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96191 smp_mb__after_clear_bit();
96192
96193 - return atomic64_read(&ic->i_ack_next);
96194 + return atomic64_read_unchecked(&ic->i_ack_next);
96195 }
96196 #endif
96197
96198 diff --git a/net/rds/rds.h b/net/rds/rds.h
96199 index ec1d731..90a3a8d 100644
96200 --- a/net/rds/rds.h
96201 +++ b/net/rds/rds.h
96202 @@ -449,7 +449,7 @@ struct rds_transport {
96203 void (*sync_mr)(void *trans_private, int direction);
96204 void (*free_mr)(void *trans_private, int invalidate);
96205 void (*flush_mrs)(void);
96206 -};
96207 +} __do_const;
96208
96209 struct rds_sock {
96210 struct sock rs_sk;
96211 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
96212 index edac9ef..16bcb98 100644
96213 --- a/net/rds/tcp.c
96214 +++ b/net/rds/tcp.c
96215 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
96216 int val = 1;
96217
96218 set_fs(KERNEL_DS);
96219 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
96220 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
96221 sizeof(val));
96222 set_fs(oldfs);
96223 }
96224 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
96225 index 81cf5a4..b5826ff 100644
96226 --- a/net/rds/tcp_send.c
96227 +++ b/net/rds/tcp_send.c
96228 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
96229
96230 oldfs = get_fs();
96231 set_fs(KERNEL_DS);
96232 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
96233 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
96234 sizeof(val));
96235 set_fs(oldfs);
96236 }
96237 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
96238 index e61aa60..f07cc89 100644
96239 --- a/net/rxrpc/af_rxrpc.c
96240 +++ b/net/rxrpc/af_rxrpc.c
96241 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
96242 __be32 rxrpc_epoch;
96243
96244 /* current debugging ID */
96245 -atomic_t rxrpc_debug_id;
96246 +atomic_unchecked_t rxrpc_debug_id;
96247
96248 /* count of skbs currently in use */
96249 atomic_t rxrpc_n_skbs;
96250 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
96251 index e4d9cbc..b229649 100644
96252 --- a/net/rxrpc/ar-ack.c
96253 +++ b/net/rxrpc/ar-ack.c
96254 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96255
96256 _enter("{%d,%d,%d,%d},",
96257 call->acks_hard, call->acks_unacked,
96258 - atomic_read(&call->sequence),
96259 + atomic_read_unchecked(&call->sequence),
96260 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
96261
96262 stop = 0;
96263 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96264
96265 /* each Tx packet has a new serial number */
96266 sp->hdr.serial =
96267 - htonl(atomic_inc_return(&call->conn->serial));
96268 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
96269
96270 hdr = (struct rxrpc_header *) txb->head;
96271 hdr->serial = sp->hdr.serial;
96272 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
96273 */
96274 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
96275 {
96276 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
96277 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
96278 }
96279
96280 /*
96281 @@ -629,7 +629,7 @@ process_further:
96282
96283 latest = ntohl(sp->hdr.serial);
96284 hard = ntohl(ack.firstPacket);
96285 - tx = atomic_read(&call->sequence);
96286 + tx = atomic_read_unchecked(&call->sequence);
96287
96288 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96289 latest,
96290 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
96291 goto maybe_reschedule;
96292
96293 send_ACK_with_skew:
96294 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
96295 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
96296 ntohl(ack.serial));
96297 send_ACK:
96298 mtu = call->conn->trans->peer->if_mtu;
96299 @@ -1173,7 +1173,7 @@ send_ACK:
96300 ackinfo.rxMTU = htonl(5692);
96301 ackinfo.jumbo_max = htonl(4);
96302
96303 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96304 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96305 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96306 ntohl(hdr.serial),
96307 ntohs(ack.maxSkew),
96308 @@ -1191,7 +1191,7 @@ send_ACK:
96309 send_message:
96310 _debug("send message");
96311
96312 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96313 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96314 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
96315 send_message_2:
96316
96317 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
96318 index a3bbb36..3341fb9 100644
96319 --- a/net/rxrpc/ar-call.c
96320 +++ b/net/rxrpc/ar-call.c
96321 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
96322 spin_lock_init(&call->lock);
96323 rwlock_init(&call->state_lock);
96324 atomic_set(&call->usage, 1);
96325 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
96326 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96327 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
96328
96329 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
96330 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
96331 index 4106ca9..a338d7a 100644
96332 --- a/net/rxrpc/ar-connection.c
96333 +++ b/net/rxrpc/ar-connection.c
96334 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
96335 rwlock_init(&conn->lock);
96336 spin_lock_init(&conn->state_lock);
96337 atomic_set(&conn->usage, 1);
96338 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
96339 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96340 conn->avail_calls = RXRPC_MAXCALLS;
96341 conn->size_align = 4;
96342 conn->header_size = sizeof(struct rxrpc_header);
96343 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
96344 index e7ed43a..6afa140 100644
96345 --- a/net/rxrpc/ar-connevent.c
96346 +++ b/net/rxrpc/ar-connevent.c
96347 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
96348
96349 len = iov[0].iov_len + iov[1].iov_len;
96350
96351 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96352 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96353 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
96354
96355 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96356 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
96357 index 529572f..c758ca7 100644
96358 --- a/net/rxrpc/ar-input.c
96359 +++ b/net/rxrpc/ar-input.c
96360 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
96361 /* track the latest serial number on this connection for ACK packet
96362 * information */
96363 serial = ntohl(sp->hdr.serial);
96364 - hi_serial = atomic_read(&call->conn->hi_serial);
96365 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
96366 while (serial > hi_serial)
96367 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
96368 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
96369 serial);
96370
96371 /* request ACK generation for any ACK or DATA packet that requests
96372 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
96373 index a693aca..81e7293 100644
96374 --- a/net/rxrpc/ar-internal.h
96375 +++ b/net/rxrpc/ar-internal.h
96376 @@ -272,8 +272,8 @@ struct rxrpc_connection {
96377 int error; /* error code for local abort */
96378 int debug_id; /* debug ID for printks */
96379 unsigned int call_counter; /* call ID counter */
96380 - atomic_t serial; /* packet serial number counter */
96381 - atomic_t hi_serial; /* highest serial number received */
96382 + atomic_unchecked_t serial; /* packet serial number counter */
96383 + atomic_unchecked_t hi_serial; /* highest serial number received */
96384 u8 avail_calls; /* number of calls available */
96385 u8 size_align; /* data size alignment (for security) */
96386 u8 header_size; /* rxrpc + security header size */
96387 @@ -346,7 +346,7 @@ struct rxrpc_call {
96388 spinlock_t lock;
96389 rwlock_t state_lock; /* lock for state transition */
96390 atomic_t usage;
96391 - atomic_t sequence; /* Tx data packet sequence counter */
96392 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
96393 u32 abort_code; /* local/remote abort code */
96394 enum { /* current state of call */
96395 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
96396 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
96397 */
96398 extern atomic_t rxrpc_n_skbs;
96399 extern __be32 rxrpc_epoch;
96400 -extern atomic_t rxrpc_debug_id;
96401 +extern atomic_unchecked_t rxrpc_debug_id;
96402 extern struct workqueue_struct *rxrpc_workqueue;
96403
96404 /*
96405 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
96406 index 87f7135..74d3703 100644
96407 --- a/net/rxrpc/ar-local.c
96408 +++ b/net/rxrpc/ar-local.c
96409 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
96410 spin_lock_init(&local->lock);
96411 rwlock_init(&local->services_lock);
96412 atomic_set(&local->usage, 1);
96413 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
96414 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96415 memcpy(&local->srx, srx, sizeof(*srx));
96416 }
96417
96418 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
96419 index e1ac183..b43e10e 100644
96420 --- a/net/rxrpc/ar-output.c
96421 +++ b/net/rxrpc/ar-output.c
96422 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
96423 sp->hdr.cid = call->cid;
96424 sp->hdr.callNumber = call->call_id;
96425 sp->hdr.seq =
96426 - htonl(atomic_inc_return(&call->sequence));
96427 + htonl(atomic_inc_return_unchecked(&call->sequence));
96428 sp->hdr.serial =
96429 - htonl(atomic_inc_return(&conn->serial));
96430 + htonl(atomic_inc_return_unchecked(&conn->serial));
96431 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
96432 sp->hdr.userStatus = 0;
96433 sp->hdr.securityIndex = conn->security_ix;
96434 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
96435 index bebaa43..2644591 100644
96436 --- a/net/rxrpc/ar-peer.c
96437 +++ b/net/rxrpc/ar-peer.c
96438 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
96439 INIT_LIST_HEAD(&peer->error_targets);
96440 spin_lock_init(&peer->lock);
96441 atomic_set(&peer->usage, 1);
96442 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
96443 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96444 memcpy(&peer->srx, srx, sizeof(*srx));
96445
96446 rxrpc_assess_MTU_size(peer);
96447 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
96448 index 38047f7..9f48511 100644
96449 --- a/net/rxrpc/ar-proc.c
96450 +++ b/net/rxrpc/ar-proc.c
96451 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
96452 atomic_read(&conn->usage),
96453 rxrpc_conn_states[conn->state],
96454 key_serial(conn->key),
96455 - atomic_read(&conn->serial),
96456 - atomic_read(&conn->hi_serial));
96457 + atomic_read_unchecked(&conn->serial),
96458 + atomic_read_unchecked(&conn->hi_serial));
96459
96460 return 0;
96461 }
96462 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
96463 index 92df566..87ec1bf 100644
96464 --- a/net/rxrpc/ar-transport.c
96465 +++ b/net/rxrpc/ar-transport.c
96466 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
96467 spin_lock_init(&trans->client_lock);
96468 rwlock_init(&trans->conn_lock);
96469 atomic_set(&trans->usage, 1);
96470 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
96471 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96472
96473 if (peer->srx.transport.family == AF_INET) {
96474 switch (peer->srx.transport_type) {
96475 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
96476 index f226709..0e735a8 100644
96477 --- a/net/rxrpc/rxkad.c
96478 +++ b/net/rxrpc/rxkad.c
96479 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
96480
96481 len = iov[0].iov_len + iov[1].iov_len;
96482
96483 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96484 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96485 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
96486
96487 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96488 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
96489
96490 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
96491
96492 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
96493 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96494 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
96495
96496 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
96497 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
96498 index e7b2d4f..bb1efd0 100644
96499 --- a/net/sctp/ipv6.c
96500 +++ b/net/sctp/ipv6.c
96501 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
96502 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
96503 };
96504
96505 -static struct sctp_af sctp_af_inet6 = {
96506 +static struct sctp_af sctp_af_inet6 __read_only = {
96507 .sa_family = AF_INET6,
96508 .sctp_xmit = sctp_v6_xmit,
96509 .setsockopt = ipv6_setsockopt,
96510 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
96511 #endif
96512 };
96513
96514 -static struct sctp_pf sctp_pf_inet6 = {
96515 +static struct sctp_pf sctp_pf_inet6 __read_only = {
96516 .event_msgname = sctp_inet6_event_msgname,
96517 .skb_msgname = sctp_inet6_skb_msgname,
96518 .af_supported = sctp_inet6_af_supported,
96519 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
96520
96521 void sctp_v6_pf_exit(void)
96522 {
96523 - list_del(&sctp_af_inet6.list);
96524 + pax_list_del(&sctp_af_inet6.list);
96525 }
96526
96527 /* Initialize IPv6 support and register with socket layer. */
96528 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
96529 index 5e17092..19be1d4 100644
96530 --- a/net/sctp/protocol.c
96531 +++ b/net/sctp/protocol.c
96532 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
96533 return 0;
96534 }
96535
96536 + pax_open_kernel();
96537 INIT_LIST_HEAD(&af->list);
96538 - list_add_tail(&af->list, &sctp_address_families);
96539 + pax_close_kernel();
96540 + pax_list_add_tail(&af->list, &sctp_address_families);
96541 return 1;
96542 }
96543
96544 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
96545
96546 static struct sctp_af sctp_af_inet;
96547
96548 -static struct sctp_pf sctp_pf_inet = {
96549 +static struct sctp_pf sctp_pf_inet __read_only = {
96550 .event_msgname = sctp_inet_event_msgname,
96551 .skb_msgname = sctp_inet_skb_msgname,
96552 .af_supported = sctp_inet_af_supported,
96553 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
96554 };
96555
96556 /* IPv4 address related functions. */
96557 -static struct sctp_af sctp_af_inet = {
96558 +static struct sctp_af sctp_af_inet __read_only = {
96559 .sa_family = AF_INET,
96560 .sctp_xmit = sctp_v4_xmit,
96561 .setsockopt = ip_setsockopt,
96562 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
96563
96564 static void sctp_v4_pf_exit(void)
96565 {
96566 - list_del(&sctp_af_inet.list);
96567 + pax_list_del(&sctp_af_inet.list);
96568 }
96569
96570 static int sctp_v4_protosw_init(void)
96571 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
96572 index 1a6eef3..17e898f 100644
96573 --- a/net/sctp/sm_sideeffect.c
96574 +++ b/net/sctp/sm_sideeffect.c
96575 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
96576 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
96577 }
96578
96579 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96580 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96581 NULL,
96582 sctp_generate_t1_cookie_event,
96583 sctp_generate_t1_init_event,
96584 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
96585 index 911b71b..90ade0a 100644
96586 --- a/net/sctp/socket.c
96587 +++ b/net/sctp/socket.c
96588 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
96589 {
96590 struct sctp_association *asoc;
96591 struct sctp_ulpevent *event;
96592 + struct sctp_event_subscribe subscribe;
96593
96594 if (optlen > sizeof(struct sctp_event_subscribe))
96595 return -EINVAL;
96596 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
96597 + if (copy_from_user(&subscribe, optval, optlen))
96598 return -EFAULT;
96599 + sctp_sk(sk)->subscribe = subscribe;
96600
96601 /*
96602 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
96603 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
96604 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96605 int __user *optlen)
96606 {
96607 + struct sctp_event_subscribe subscribe;
96608 +
96609 if (len <= 0)
96610 return -EINVAL;
96611 if (len > sizeof(struct sctp_event_subscribe))
96612 len = sizeof(struct sctp_event_subscribe);
96613 if (put_user(len, optlen))
96614 return -EFAULT;
96615 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
96616 + subscribe = sctp_sk(sk)->subscribe;
96617 + if (copy_to_user(optval, &subscribe, len))
96618 return -EFAULT;
96619 return 0;
96620 }
96621 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96622 */
96623 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
96624 {
96625 + __u32 autoclose;
96626 +
96627 /* Applicable to UDP-style socket only */
96628 if (sctp_style(sk, TCP))
96629 return -EOPNOTSUPP;
96630 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
96631 len = sizeof(int);
96632 if (put_user(len, optlen))
96633 return -EFAULT;
96634 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
96635 + autoclose = sctp_sk(sk)->autoclose;
96636 + if (copy_to_user(optval, &autoclose, sizeof(int)))
96637 return -EFAULT;
96638 return 0;
96639 }
96640 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
96641 */
96642 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
96643 {
96644 + struct sctp_initmsg initmsg;
96645 +
96646 if (len < sizeof(struct sctp_initmsg))
96647 return -EINVAL;
96648 len = sizeof(struct sctp_initmsg);
96649 if (put_user(len, optlen))
96650 return -EFAULT;
96651 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
96652 + initmsg = sctp_sk(sk)->initmsg;
96653 + if (copy_to_user(optval, &initmsg, len))
96654 return -EFAULT;
96655 return 0;
96656 }
96657 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
96658 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
96659 if (space_left < addrlen)
96660 return -ENOMEM;
96661 + if (addrlen > sizeof(temp) || addrlen < 0)
96662 + return -EFAULT;
96663 if (copy_to_user(to, &temp, addrlen))
96664 return -EFAULT;
96665 to += addrlen;
96666 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
96667 index 6b36561..4f21064 100644
96668 --- a/net/sctp/sysctl.c
96669 +++ b/net/sctp/sysctl.c
96670 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96671 {
96672 struct net *net = current->nsproxy->net_ns;
96673 char tmp[8];
96674 - struct ctl_table tbl;
96675 + ctl_table_no_const tbl;
96676 int ret;
96677 int changed = 0;
96678 char *none = "none";
96679 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96680
96681 int sctp_sysctl_net_register(struct net *net)
96682 {
96683 - struct ctl_table *table;
96684 + ctl_table_no_const *table;
96685 int i;
96686
96687 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
96688 diff --git a/net/socket.c b/net/socket.c
96689 index c226ace..561e8f7 100644
96690 --- a/net/socket.c
96691 +++ b/net/socket.c
96692 @@ -88,6 +88,7 @@
96693 #include <linux/magic.h>
96694 #include <linux/slab.h>
96695 #include <linux/xattr.h>
96696 +#include <linux/in.h>
96697
96698 #include <asm/uaccess.h>
96699 #include <asm/unistd.h>
96700 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
96701 unsigned int sysctl_net_busy_poll __read_mostly;
96702 #endif
96703
96704 +#include <linux/grsock.h>
96705 +
96706 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
96707 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
96708 unsigned long nr_segs, loff_t pos);
96709 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96710 */
96711
96712 static DEFINE_SPINLOCK(net_family_lock);
96713 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96714 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96715
96716 /*
96717 * Statistics counters of the socket lists
96718 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96719 &sockfs_dentry_operations, SOCKFS_MAGIC);
96720 }
96721
96722 -static struct vfsmount *sock_mnt __read_mostly;
96723 +struct vfsmount *sock_mnt __read_mostly;
96724
96725 static struct file_system_type sock_fs_type = {
96726 .name = "sockfs",
96727 @@ -1254,6 +1257,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96728 return -EAFNOSUPPORT;
96729 if (type < 0 || type >= SOCK_MAX)
96730 return -EINVAL;
96731 + if (protocol < 0)
96732 + return -EINVAL;
96733
96734 /* Compatibility.
96735
96736 @@ -1274,6 +1279,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96737 if (err)
96738 return err;
96739
96740 + if(!kern && !gr_search_socket(family, type, protocol)) {
96741 + if (rcu_access_pointer(net_families[family]) == NULL)
96742 + return -EAFNOSUPPORT;
96743 + else
96744 + return -EACCES;
96745 + }
96746 +
96747 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96748 + if (rcu_access_pointer(net_families[family]) == NULL)
96749 + return -EAFNOSUPPORT;
96750 + else
96751 + return -EACCES;
96752 + }
96753 +
96754 /*
96755 * Allocate the socket and allow the family to set things up. if
96756 * the protocol is 0, the family is instructed to select an appropriate
96757 @@ -1512,6 +1531,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96758 if (sock) {
96759 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96760 if (err >= 0) {
96761 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96762 + err = -EACCES;
96763 + goto error;
96764 + }
96765 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96766 + if (err)
96767 + goto error;
96768 +
96769 err = security_socket_bind(sock,
96770 (struct sockaddr *)&address,
96771 addrlen);
96772 @@ -1520,6 +1547,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96773 (struct sockaddr *)
96774 &address, addrlen);
96775 }
96776 +error:
96777 fput_light(sock->file, fput_needed);
96778 }
96779 return err;
96780 @@ -1543,10 +1571,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96781 if ((unsigned int)backlog > somaxconn)
96782 backlog = somaxconn;
96783
96784 + if (gr_handle_sock_server_other(sock->sk)) {
96785 + err = -EPERM;
96786 + goto error;
96787 + }
96788 +
96789 + err = gr_search_listen(sock);
96790 + if (err)
96791 + goto error;
96792 +
96793 err = security_socket_listen(sock, backlog);
96794 if (!err)
96795 err = sock->ops->listen(sock, backlog);
96796
96797 +error:
96798 fput_light(sock->file, fput_needed);
96799 }
96800 return err;
96801 @@ -1590,6 +1628,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96802 newsock->type = sock->type;
96803 newsock->ops = sock->ops;
96804
96805 + if (gr_handle_sock_server_other(sock->sk)) {
96806 + err = -EPERM;
96807 + sock_release(newsock);
96808 + goto out_put;
96809 + }
96810 +
96811 + err = gr_search_accept(sock);
96812 + if (err) {
96813 + sock_release(newsock);
96814 + goto out_put;
96815 + }
96816 +
96817 /*
96818 * We don't need try_module_get here, as the listening socket (sock)
96819 * has the protocol module (sock->ops->owner) held.
96820 @@ -1635,6 +1685,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96821 fd_install(newfd, newfile);
96822 err = newfd;
96823
96824 + gr_attach_curr_ip(newsock->sk);
96825 +
96826 out_put:
96827 fput_light(sock->file, fput_needed);
96828 out:
96829 @@ -1667,6 +1719,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96830 int, addrlen)
96831 {
96832 struct socket *sock;
96833 + struct sockaddr *sck;
96834 struct sockaddr_storage address;
96835 int err, fput_needed;
96836
96837 @@ -1677,6 +1730,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96838 if (err < 0)
96839 goto out_put;
96840
96841 + sck = (struct sockaddr *)&address;
96842 +
96843 + if (gr_handle_sock_client(sck)) {
96844 + err = -EACCES;
96845 + goto out_put;
96846 + }
96847 +
96848 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96849 + if (err)
96850 + goto out_put;
96851 +
96852 err =
96853 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96854 if (err)
96855 @@ -1758,6 +1822,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96856 * the protocol.
96857 */
96858
96859 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96860 +
96861 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96862 unsigned int, flags, struct sockaddr __user *, addr,
96863 int, addr_len)
96864 @@ -1824,7 +1890,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96865 struct socket *sock;
96866 struct iovec iov;
96867 struct msghdr msg;
96868 - struct sockaddr_storage address;
96869 + struct sockaddr_storage address = { };
96870 int err, err2;
96871 int fput_needed;
96872
96873 @@ -2044,7 +2110,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96874 * checking falls down on this.
96875 */
96876 if (copy_from_user(ctl_buf,
96877 - (void __user __force *)msg_sys->msg_control,
96878 + (void __force_user *)msg_sys->msg_control,
96879 ctl_len))
96880 goto out_freectl;
96881 msg_sys->msg_control = ctl_buf;
96882 @@ -2195,7 +2261,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96883 int err, total_len, len;
96884
96885 /* kernel mode address */
96886 - struct sockaddr_storage addr;
96887 + struct sockaddr_storage addr = { };
96888
96889 /* user mode address pointers */
96890 struct sockaddr __user *uaddr;
96891 @@ -2226,7 +2292,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96892 * kernel msghdr to use the kernel address space)
96893 */
96894
96895 - uaddr = (__force void __user *)msg_sys->msg_name;
96896 + uaddr = (void __force_user *)msg_sys->msg_name;
96897 uaddr_len = COMPAT_NAMELEN(msg);
96898 if (MSG_CMSG_COMPAT & flags) {
96899 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96900 @@ -2981,7 +3047,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96901 old_fs = get_fs();
96902 set_fs(KERNEL_DS);
96903 err = dev_ioctl(net, cmd,
96904 - (struct ifreq __user __force *) &kifr);
96905 + (struct ifreq __force_user *) &kifr);
96906 set_fs(old_fs);
96907
96908 return err;
96909 @@ -3090,7 +3156,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96910
96911 old_fs = get_fs();
96912 set_fs(KERNEL_DS);
96913 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96914 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96915 set_fs(old_fs);
96916
96917 if (cmd == SIOCGIFMAP && !err) {
96918 @@ -3195,7 +3261,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96919 ret |= get_user(rtdev, &(ur4->rt_dev));
96920 if (rtdev) {
96921 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96922 - r4.rt_dev = (char __user __force *)devname;
96923 + r4.rt_dev = (char __force_user *)devname;
96924 devname[15] = 0;
96925 } else
96926 r4.rt_dev = NULL;
96927 @@ -3421,8 +3487,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96928 int __user *uoptlen;
96929 int err;
96930
96931 - uoptval = (char __user __force *) optval;
96932 - uoptlen = (int __user __force *) optlen;
96933 + uoptval = (char __force_user *) optval;
96934 + uoptlen = (int __force_user *) optlen;
96935
96936 set_fs(KERNEL_DS);
96937 if (level == SOL_SOCKET)
96938 @@ -3442,7 +3508,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96939 char __user *uoptval;
96940 int err;
96941
96942 - uoptval = (char __user __force *) optval;
96943 + uoptval = (char __force_user *) optval;
96944
96945 set_fs(KERNEL_DS);
96946 if (level == SOL_SOCKET)
96947 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96948 index 09fb638..2e6a5c5 100644
96949 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96950 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96951 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96952 uint64_t *handle)
96953 {
96954 struct rsc rsci, *rscp = NULL;
96955 - static atomic64_t ctxhctr;
96956 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96957 long long ctxh;
96958 struct gss_api_mech *gm = NULL;
96959 time_t expiry;
96960 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96961 status = -ENOMEM;
96962 /* the handle needs to be just a unique id,
96963 * use a static counter */
96964 - ctxh = atomic64_inc_return(&ctxhctr);
96965 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96966
96967 /* make a copy for the caller */
96968 *handle = ctxh;
96969 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96970 index 941d19f..c85ff07 100644
96971 --- a/net/sunrpc/clnt.c
96972 +++ b/net/sunrpc/clnt.c
96973 @@ -1319,7 +1319,9 @@ call_start(struct rpc_task *task)
96974 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96975
96976 /* Increment call count */
96977 - task->tk_msg.rpc_proc->p_count++;
96978 + pax_open_kernel();
96979 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96980 + pax_close_kernel();
96981 clnt->cl_stats->rpccnt++;
96982 task->tk_action = call_reserve;
96983 }
96984 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96985 index ff3cc4b..7612a9e 100644
96986 --- a/net/sunrpc/sched.c
96987 +++ b/net/sunrpc/sched.c
96988 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96989 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
96990 static void rpc_task_set_debuginfo(struct rpc_task *task)
96991 {
96992 - static atomic_t rpc_pid;
96993 + static atomic_unchecked_t rpc_pid;
96994
96995 - task->tk_pid = atomic_inc_return(&rpc_pid);
96996 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96997 }
96998 #else
96999 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97000 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97001 index b974571..678ed90 100644
97002 --- a/net/sunrpc/svc.c
97003 +++ b/net/sunrpc/svc.c
97004 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97005 svc_putnl(resv, RPC_SUCCESS);
97006
97007 /* Bump per-procedure stats counter */
97008 - procp->pc_count++;
97009 + pax_open_kernel();
97010 + (*(unsigned int *)&procp->pc_count)++;
97011 + pax_close_kernel();
97012
97013 /* Initialize storage for argp and resp */
97014 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97015 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
97016 index 621ca7b..59421dd 100644
97017 --- a/net/sunrpc/svcauth_unix.c
97018 +++ b/net/sunrpc/svcauth_unix.c
97019 @@ -414,7 +414,7 @@ struct unix_gid {
97020 struct group_info *gi;
97021 };
97022
97023 -static int unix_gid_hash(kuid_t uid)
97024 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
97025 {
97026 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
97027 }
97028 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
97029 (*bpp)[-1] = '\n';
97030 }
97031
97032 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97033 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97034
97035 static int unix_gid_parse(struct cache_detail *cd,
97036 char *mesg, int mlen)
97037 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97038 index c1b6270..05089c1 100644
97039 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97040 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97041 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97042 static unsigned int min_max_inline = 4096;
97043 static unsigned int max_max_inline = 65536;
97044
97045 -atomic_t rdma_stat_recv;
97046 -atomic_t rdma_stat_read;
97047 -atomic_t rdma_stat_write;
97048 -atomic_t rdma_stat_sq_starve;
97049 -atomic_t rdma_stat_rq_starve;
97050 -atomic_t rdma_stat_rq_poll;
97051 -atomic_t rdma_stat_rq_prod;
97052 -atomic_t rdma_stat_sq_poll;
97053 -atomic_t rdma_stat_sq_prod;
97054 +atomic_unchecked_t rdma_stat_recv;
97055 +atomic_unchecked_t rdma_stat_read;
97056 +atomic_unchecked_t rdma_stat_write;
97057 +atomic_unchecked_t rdma_stat_sq_starve;
97058 +atomic_unchecked_t rdma_stat_rq_starve;
97059 +atomic_unchecked_t rdma_stat_rq_poll;
97060 +atomic_unchecked_t rdma_stat_rq_prod;
97061 +atomic_unchecked_t rdma_stat_sq_poll;
97062 +atomic_unchecked_t rdma_stat_sq_prod;
97063
97064 /* Temporary NFS request map and context caches */
97065 struct kmem_cache *svc_rdma_map_cachep;
97066 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
97067 len -= *ppos;
97068 if (len > *lenp)
97069 len = *lenp;
97070 - if (len && copy_to_user(buffer, str_buf, len))
97071 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97072 return -EFAULT;
97073 *lenp = len;
97074 *ppos += len;
97075 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
97076 {
97077 .procname = "rdma_stat_read",
97078 .data = &rdma_stat_read,
97079 - .maxlen = sizeof(atomic_t),
97080 + .maxlen = sizeof(atomic_unchecked_t),
97081 .mode = 0644,
97082 .proc_handler = read_reset_stat,
97083 },
97084 {
97085 .procname = "rdma_stat_recv",
97086 .data = &rdma_stat_recv,
97087 - .maxlen = sizeof(atomic_t),
97088 + .maxlen = sizeof(atomic_unchecked_t),
97089 .mode = 0644,
97090 .proc_handler = read_reset_stat,
97091 },
97092 {
97093 .procname = "rdma_stat_write",
97094 .data = &rdma_stat_write,
97095 - .maxlen = sizeof(atomic_t),
97096 + .maxlen = sizeof(atomic_unchecked_t),
97097 .mode = 0644,
97098 .proc_handler = read_reset_stat,
97099 },
97100 {
97101 .procname = "rdma_stat_sq_starve",
97102 .data = &rdma_stat_sq_starve,
97103 - .maxlen = sizeof(atomic_t),
97104 + .maxlen = sizeof(atomic_unchecked_t),
97105 .mode = 0644,
97106 .proc_handler = read_reset_stat,
97107 },
97108 {
97109 .procname = "rdma_stat_rq_starve",
97110 .data = &rdma_stat_rq_starve,
97111 - .maxlen = sizeof(atomic_t),
97112 + .maxlen = sizeof(atomic_unchecked_t),
97113 .mode = 0644,
97114 .proc_handler = read_reset_stat,
97115 },
97116 {
97117 .procname = "rdma_stat_rq_poll",
97118 .data = &rdma_stat_rq_poll,
97119 - .maxlen = sizeof(atomic_t),
97120 + .maxlen = sizeof(atomic_unchecked_t),
97121 .mode = 0644,
97122 .proc_handler = read_reset_stat,
97123 },
97124 {
97125 .procname = "rdma_stat_rq_prod",
97126 .data = &rdma_stat_rq_prod,
97127 - .maxlen = sizeof(atomic_t),
97128 + .maxlen = sizeof(atomic_unchecked_t),
97129 .mode = 0644,
97130 .proc_handler = read_reset_stat,
97131 },
97132 {
97133 .procname = "rdma_stat_sq_poll",
97134 .data = &rdma_stat_sq_poll,
97135 - .maxlen = sizeof(atomic_t),
97136 + .maxlen = sizeof(atomic_unchecked_t),
97137 .mode = 0644,
97138 .proc_handler = read_reset_stat,
97139 },
97140 {
97141 .procname = "rdma_stat_sq_prod",
97142 .data = &rdma_stat_sq_prod,
97143 - .maxlen = sizeof(atomic_t),
97144 + .maxlen = sizeof(atomic_unchecked_t),
97145 .mode = 0644,
97146 .proc_handler = read_reset_stat,
97147 },
97148 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97149 index 0ce7552..d074459 100644
97150 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97151 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97152 @@ -501,7 +501,7 @@ next_sge:
97153 svc_rdma_put_context(ctxt, 0);
97154 goto out;
97155 }
97156 - atomic_inc(&rdma_stat_read);
97157 + atomic_inc_unchecked(&rdma_stat_read);
97158
97159 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97160 chl_map->ch[ch_no].count -= read_wr.num_sge;
97161 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97162 dto_q);
97163 list_del_init(&ctxt->dto_q);
97164 } else {
97165 - atomic_inc(&rdma_stat_rq_starve);
97166 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97167 clear_bit(XPT_DATA, &xprt->xpt_flags);
97168 ctxt = NULL;
97169 }
97170 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97171 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
97172 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
97173 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
97174 - atomic_inc(&rdma_stat_recv);
97175 + atomic_inc_unchecked(&rdma_stat_recv);
97176
97177 /* Build up the XDR from the receive buffers. */
97178 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
97179 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97180 index c1d124d..acfc59e 100644
97181 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97182 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97183 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
97184 write_wr.wr.rdma.remote_addr = to;
97185
97186 /* Post It */
97187 - atomic_inc(&rdma_stat_write);
97188 + atomic_inc_unchecked(&rdma_stat_write);
97189 if (svc_rdma_send(xprt, &write_wr))
97190 goto err;
97191 return 0;
97192 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97193 index 62e4f9b..dd3f2d7 100644
97194 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
97195 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97196 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97197 return;
97198
97199 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
97200 - atomic_inc(&rdma_stat_rq_poll);
97201 + atomic_inc_unchecked(&rdma_stat_rq_poll);
97202
97203 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
97204 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
97205 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97206 }
97207
97208 if (ctxt)
97209 - atomic_inc(&rdma_stat_rq_prod);
97210 + atomic_inc_unchecked(&rdma_stat_rq_prod);
97211
97212 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
97213 /*
97214 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97215 return;
97216
97217 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
97218 - atomic_inc(&rdma_stat_sq_poll);
97219 + atomic_inc_unchecked(&rdma_stat_sq_poll);
97220 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
97221 if (wc.status != IB_WC_SUCCESS)
97222 /* Close the transport */
97223 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97224 }
97225
97226 if (ctxt)
97227 - atomic_inc(&rdma_stat_sq_prod);
97228 + atomic_inc_unchecked(&rdma_stat_sq_prod);
97229 }
97230
97231 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
97232 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
97233 spin_lock_bh(&xprt->sc_lock);
97234 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
97235 spin_unlock_bh(&xprt->sc_lock);
97236 - atomic_inc(&rdma_stat_sq_starve);
97237 + atomic_inc_unchecked(&rdma_stat_sq_starve);
97238
97239 /* See if we can opportunistically reap SQ WR to make room */
97240 sq_cq_reap(xprt);
97241 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
97242 index e7000be..e3b0ba7 100644
97243 --- a/net/sysctl_net.c
97244 +++ b/net/sysctl_net.c
97245 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
97246 kgid_t root_gid = make_kgid(net->user_ns, 0);
97247
97248 /* Allow network administrator to have same access as root. */
97249 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
97250 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
97251 uid_eq(root_uid, current_euid())) {
97252 int mode = (table->mode >> 6) & 7;
97253 return (mode << 6) | (mode << 3) | mode;
97254 diff --git a/net/tipc/link.c b/net/tipc/link.c
97255 index 0cc3d90..cc42021 100644
97256 --- a/net/tipc/link.c
97257 +++ b/net/tipc/link.c
97258 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
97259 struct tipc_msg fragm_hdr;
97260 struct sk_buff *buf, *buf_chain, *prev;
97261 u32 fragm_crs, fragm_rest, hsz, sect_rest;
97262 - const unchar *sect_crs;
97263 + const unchar __user *sect_crs;
97264 int curr_sect;
97265 u32 fragm_no;
97266 int res = 0;
97267 @@ -1207,7 +1207,7 @@ again:
97268
97269 if (!sect_rest) {
97270 sect_rest = msg_sect[++curr_sect].iov_len;
97271 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
97272 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
97273 }
97274
97275 if (sect_rest < fragm_rest)
97276 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
97277 index ced60e2..54eab6c 100644
97278 --- a/net/tipc/msg.c
97279 +++ b/net/tipc/msg.c
97280 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
97281 skb_copy_to_linear_data(*buf, hdr, hsz);
97282 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
97283 skb_copy_to_linear_data_offset(*buf, pos,
97284 - msg_sect[cnt].iov_base,
97285 + (const void __force_kernel *)msg_sect[cnt].iov_base,
97286 msg_sect[cnt].iov_len);
97287 pos += msg_sect[cnt].iov_len;
97288 }
97289 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
97290 index d38bb45..4fd6ac6 100644
97291 --- a/net/tipc/subscr.c
97292 +++ b/net/tipc/subscr.c
97293 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
97294 struct kvec msg_sect;
97295 int ret;
97296
97297 - msg_sect.iov_base = (void *)&sub->evt;
97298 + msg_sect.iov_base = (void __force_user *)&sub->evt;
97299 msg_sect.iov_len = sizeof(struct tipc_event);
97300
97301 sub->evt.event = htohl(event, sub->swap);
97302 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
97303 index c1f403b..b246d87 100644
97304 --- a/net/unix/af_unix.c
97305 +++ b/net/unix/af_unix.c
97306 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
97307 err = -ECONNREFUSED;
97308 if (!S_ISSOCK(inode->i_mode))
97309 goto put_fail;
97310 +
97311 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
97312 + err = -EACCES;
97313 + goto put_fail;
97314 + }
97315 +
97316 u = unix_find_socket_byinode(inode);
97317 if (!u)
97318 goto put_fail;
97319 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
97320 if (u) {
97321 struct dentry *dentry;
97322 dentry = unix_sk(u)->path.dentry;
97323 +
97324 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
97325 + err = -EPERM;
97326 + sock_put(u);
97327 + goto fail;
97328 + }
97329 +
97330 if (dentry)
97331 touch_atime(&unix_sk(u)->path);
97332 } else
97333 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
97334 */
97335 err = security_path_mknod(&path, dentry, mode, 0);
97336 if (!err) {
97337 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
97338 + err = -EACCES;
97339 + goto out;
97340 + }
97341 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
97342 if (!err) {
97343 res->mnt = mntget(path.mnt);
97344 res->dentry = dget(dentry);
97345 + gr_handle_create(dentry, path.mnt);
97346 }
97347 }
97348 +out:
97349 done_path_create(&path, dentry);
97350 return err;
97351 }
97352 @@ -2333,9 +2352,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97353 seq_puts(seq, "Num RefCount Protocol Flags Type St "
97354 "Inode Path\n");
97355 else {
97356 - struct sock *s = v;
97357 + struct sock *s = v, *peer;
97358 struct unix_sock *u = unix_sk(s);
97359 unix_state_lock(s);
97360 + peer = unix_peer(s);
97361 + unix_state_unlock(s);
97362 +
97363 + unix_state_double_lock(s, peer);
97364
97365 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
97366 s,
97367 @@ -2362,8 +2385,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97368 }
97369 for ( ; i < len; i++)
97370 seq_putc(seq, u->addr->name->sun_path[i]);
97371 - }
97372 - unix_state_unlock(s);
97373 + } else if (peer)
97374 + seq_printf(seq, " P%lu", sock_i_ino(peer));
97375 +
97376 + unix_state_double_unlock(s, peer);
97377 seq_putc(seq, '\n');
97378 }
97379
97380 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
97381 index b3d5150..ff3a837 100644
97382 --- a/net/unix/sysctl_net_unix.c
97383 +++ b/net/unix/sysctl_net_unix.c
97384 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
97385
97386 int __net_init unix_sysctl_register(struct net *net)
97387 {
97388 - struct ctl_table *table;
97389 + ctl_table_no_const *table;
97390
97391 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
97392 if (table == NULL)
97393 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
97394 index c8717c1..08539f5 100644
97395 --- a/net/wireless/wext-core.c
97396 +++ b/net/wireless/wext-core.c
97397 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97398 */
97399
97400 /* Support for very large requests */
97401 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
97402 - (user_length > descr->max_tokens)) {
97403 + if (user_length > descr->max_tokens) {
97404 /* Allow userspace to GET more than max so
97405 * we can support any size GET requests.
97406 * There is still a limit : -ENOMEM.
97407 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97408 }
97409 }
97410
97411 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
97412 - /*
97413 - * If this is a GET, but not NOMAX, it means that the extra
97414 - * data is not bounded by userspace, but by max_tokens. Thus
97415 - * set the length to max_tokens. This matches the extra data
97416 - * allocation.
97417 - * The driver should fill it with the number of tokens it
97418 - * provided, and it may check iwp->length rather than having
97419 - * knowledge of max_tokens. If the driver doesn't change the
97420 - * iwp->length, this ioctl just copies back max_token tokens
97421 - * filled with zeroes. Hopefully the driver isn't claiming
97422 - * them to be valid data.
97423 - */
97424 - iwp->length = descr->max_tokens;
97425 - }
97426 -
97427 err = handler(dev, info, (union iwreq_data *) iwp, extra);
97428
97429 iwp->length += essid_compat;
97430 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
97431 index 76e1873..4a12664 100644
97432 --- a/net/xfrm/xfrm_policy.c
97433 +++ b/net/xfrm/xfrm_policy.c
97434 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
97435 {
97436 policy->walk.dead = 1;
97437
97438 - atomic_inc(&policy->genid);
97439 + atomic_inc_unchecked(&policy->genid);
97440
97441 if (del_timer(&policy->polq.hold_timer))
97442 xfrm_pol_put(policy);
97443 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
97444 hlist_add_head(&policy->bydst, chain);
97445 xfrm_pol_hold(policy);
97446 net->xfrm.policy_count[dir]++;
97447 - atomic_inc(&flow_cache_genid);
97448 + atomic_inc_unchecked(&flow_cache_genid);
97449
97450 /* After previous checking, family can either be AF_INET or AF_INET6 */
97451 if (policy->family == AF_INET)
97452 @@ -1636,7 +1636,7 @@ free_dst:
97453 goto out;
97454 }
97455
97456 -static int inline
97457 +static inline int
97458 xfrm_dst_alloc_copy(void **target, const void *src, int size)
97459 {
97460 if (!*target) {
97461 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
97462 return 0;
97463 }
97464
97465 -static int inline
97466 +static inline int
97467 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97468 {
97469 #ifdef CONFIG_XFRM_SUB_POLICY
97470 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97471 #endif
97472 }
97473
97474 -static int inline
97475 +static inline int
97476 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
97477 {
97478 #ifdef CONFIG_XFRM_SUB_POLICY
97479 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
97480
97481 xdst->num_pols = num_pols;
97482 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
97483 - xdst->policy_genid = atomic_read(&pols[0]->genid);
97484 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
97485
97486 return xdst;
97487 }
97488 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
97489 }
97490 EXPORT_SYMBOL(xfrm_garbage_collect);
97491
97492 -static void xfrm_garbage_collect_deferred(struct net *net)
97493 +void xfrm_garbage_collect_deferred(struct net *net)
97494 {
97495 flow_cache_flush_deferred();
97496 __xfrm_garbage_collect(net);
97497 }
97498 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
97499
97500 static void xfrm_init_pmtu(struct dst_entry *dst)
97501 {
97502 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
97503 if (xdst->xfrm_genid != dst->xfrm->genid)
97504 return 0;
97505 if (xdst->num_pols > 0 &&
97506 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
97507 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
97508 return 0;
97509
97510 mtu = dst_mtu(dst->child);
97511 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
97512 dst_ops->link_failure = xfrm_link_failure;
97513 if (likely(dst_ops->neigh_lookup == NULL))
97514 dst_ops->neigh_lookup = xfrm_neigh_lookup;
97515 - if (likely(afinfo->garbage_collect == NULL))
97516 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
97517 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
97518 }
97519 spin_unlock(&xfrm_policy_afinfo_lock);
97520 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
97521 dst_ops->check = NULL;
97522 dst_ops->negative_advice = NULL;
97523 dst_ops->link_failure = NULL;
97524 - afinfo->garbage_collect = NULL;
97525 }
97526 return err;
97527 }
97528 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
97529 sizeof(pol->xfrm_vec[i].saddr));
97530 pol->xfrm_vec[i].encap_family = mp->new_family;
97531 /* flush bundles */
97532 - atomic_inc(&pol->genid);
97533 + atomic_inc_unchecked(&pol->genid);
97534 }
97535 }
97536
97537 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97538 index b9c3f9e..4767526 100644
97539 --- a/net/xfrm/xfrm_state.c
97540 +++ b/net/xfrm/xfrm_state.c
97541 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97542
97543 if (unlikely(afinfo == NULL))
97544 return -EAFNOSUPPORT;
97545 - typemap = afinfo->type_map;
97546 + typemap = (const struct xfrm_type **)afinfo->type_map;
97547 spin_lock_bh(&xfrm_type_lock);
97548
97549 - if (likely(typemap[type->proto] == NULL))
97550 + if (likely(typemap[type->proto] == NULL)) {
97551 + pax_open_kernel();
97552 typemap[type->proto] = type;
97553 - else
97554 + pax_close_kernel();
97555 + } else
97556 err = -EEXIST;
97557 spin_unlock_bh(&xfrm_type_lock);
97558 xfrm_state_put_afinfo(afinfo);
97559 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97560
97561 if (unlikely(afinfo == NULL))
97562 return -EAFNOSUPPORT;
97563 - typemap = afinfo->type_map;
97564 + typemap = (const struct xfrm_type **)afinfo->type_map;
97565 spin_lock_bh(&xfrm_type_lock);
97566
97567 if (unlikely(typemap[type->proto] != type))
97568 err = -ENOENT;
97569 - else
97570 + else {
97571 + pax_open_kernel();
97572 typemap[type->proto] = NULL;
97573 + pax_close_kernel();
97574 + }
97575 spin_unlock_bh(&xfrm_type_lock);
97576 xfrm_state_put_afinfo(afinfo);
97577 return err;
97578 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97579 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97580 {
97581 struct xfrm_state_afinfo *afinfo;
97582 - const struct xfrm_type **typemap;
97583 const struct xfrm_type *type;
97584 int modload_attempted = 0;
97585
97586 @@ -219,9 +223,8 @@ retry:
97587 afinfo = xfrm_state_get_afinfo(family);
97588 if (unlikely(afinfo == NULL))
97589 return NULL;
97590 - typemap = afinfo->type_map;
97591
97592 - type = typemap[proto];
97593 + type = afinfo->type_map[proto];
97594 if (unlikely(type && !try_module_get(type->owner)))
97595 type = NULL;
97596 if (!type && !modload_attempted) {
97597 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97598 return -EAFNOSUPPORT;
97599
97600 err = -EEXIST;
97601 - modemap = afinfo->mode_map;
97602 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97603 spin_lock_bh(&xfrm_mode_lock);
97604 if (modemap[mode->encap])
97605 goto out;
97606 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97607 if (!try_module_get(afinfo->owner))
97608 goto out;
97609
97610 - mode->afinfo = afinfo;
97611 + pax_open_kernel();
97612 + *(const void **)&mode->afinfo = afinfo;
97613 modemap[mode->encap] = mode;
97614 + pax_close_kernel();
97615 err = 0;
97616
97617 out:
97618 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97619 return -EAFNOSUPPORT;
97620
97621 err = -ENOENT;
97622 - modemap = afinfo->mode_map;
97623 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97624 spin_lock_bh(&xfrm_mode_lock);
97625 if (likely(modemap[mode->encap] == mode)) {
97626 + pax_open_kernel();
97627 modemap[mode->encap] = NULL;
97628 + pax_close_kernel();
97629 module_put(mode->afinfo->owner);
97630 err = 0;
97631 }
97632 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97633 u32 xfrm_get_acqseq(void)
97634 {
97635 u32 res;
97636 - static atomic_t acqseq;
97637 + static atomic_unchecked_t acqseq;
97638
97639 do {
97640 - res = atomic_inc_return(&acqseq);
97641 + res = atomic_inc_return_unchecked(&acqseq);
97642 } while (!res);
97643
97644 return res;
97645 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97646 index 05a6e3d..6716ec9 100644
97647 --- a/net/xfrm/xfrm_sysctl.c
97648 +++ b/net/xfrm/xfrm_sysctl.c
97649 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97650
97651 int __net_init xfrm_sysctl_init(struct net *net)
97652 {
97653 - struct ctl_table *table;
97654 + ctl_table_no_const *table;
97655
97656 __xfrm_sysctl_init(net);
97657
97658 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97659 index d5d859c..781cbcb 100644
97660 --- a/scripts/Makefile.build
97661 +++ b/scripts/Makefile.build
97662 @@ -111,7 +111,7 @@ endif
97663 endif
97664
97665 # Do not include host rules unless needed
97666 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97667 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97668 include scripts/Makefile.host
97669 endif
97670
97671 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97672 index 686cb0d..9d653bf 100644
97673 --- a/scripts/Makefile.clean
97674 +++ b/scripts/Makefile.clean
97675 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97676 __clean-files := $(extra-y) $(always) \
97677 $(targets) $(clean-files) \
97678 $(host-progs) \
97679 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97680 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97681 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97682
97683 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97684
97685 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97686 index 1ac414f..38575f7 100644
97687 --- a/scripts/Makefile.host
97688 +++ b/scripts/Makefile.host
97689 @@ -31,6 +31,8 @@
97690 # Note: Shared libraries consisting of C++ files are not supported
97691
97692 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97693 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97694 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97695
97696 # C code
97697 # Executables compiled from a single .c file
97698 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97699 # Shared libaries (only .c supported)
97700 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97701 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97702 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97703 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97704 # Remove .so files from "xxx-objs"
97705 host-cobjs := $(filter-out %.so,$(host-cobjs))
97706 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97707
97708 -#Object (.o) files used by the shared libaries
97709 +# Object (.o) files used by the shared libaries
97710 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97711 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97712
97713 # output directory for programs/.o files
97714 # hostprogs-y := tools/build may have been specified. Retrieve directory
97715 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97716 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97717 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97718 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97719 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97720 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97721 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97722 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97723
97724 obj-dirs += $(host-objdirs)
97725 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97726 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97727 $(call if_changed_dep,host-cshobjs)
97728
97729 +# Compile .c file, create position independent .o file
97730 +# host-cxxshobjs -> .o
97731 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97732 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97733 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97734 + $(call if_changed_dep,host-cxxshobjs)
97735 +
97736 # Link a shared library, based on position independent .o files
97737 # *.o -> .so shared library (host-cshlib)
97738 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97739 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97740 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97741 $(call if_changed,host-cshlib)
97742
97743 +# Link a shared library, based on position independent .o files
97744 +# *.o -> .so shared library (host-cxxshlib)
97745 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97746 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97747 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97748 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97749 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97750 + $(call if_changed,host-cxxshlib)
97751 +
97752 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97753 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97754 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97755
97756 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97757 index 078fe1d..fbdb363 100644
97758 --- a/scripts/basic/fixdep.c
97759 +++ b/scripts/basic/fixdep.c
97760 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97761 /*
97762 * Lookup a value in the configuration string.
97763 */
97764 -static int is_defined_config(const char *name, int len, unsigned int hash)
97765 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97766 {
97767 struct item *aux;
97768
97769 @@ -211,10 +211,10 @@ static void clear_config(void)
97770 /*
97771 * Record the use of a CONFIG_* word.
97772 */
97773 -static void use_config(const char *m, int slen)
97774 +static void use_config(const char *m, unsigned int slen)
97775 {
97776 unsigned int hash = strhash(m, slen);
97777 - int c, i;
97778 + unsigned int c, i;
97779
97780 if (is_defined_config(m, slen, hash))
97781 return;
97782 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97783
97784 static void parse_config_file(const char *map, size_t len)
97785 {
97786 - const int *end = (const int *) (map + len);
97787 + const unsigned int *end = (const unsigned int *) (map + len);
97788 /* start at +1, so that p can never be < map */
97789 - const int *m = (const int *) map + 1;
97790 + const unsigned int *m = (const unsigned int *) map + 1;
97791 const char *p, *q;
97792
97793 for (; m < end; m++) {
97794 @@ -435,7 +435,7 @@ static void print_deps(void)
97795 static void traps(void)
97796 {
97797 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97798 - int *p = (int *)test;
97799 + unsigned int *p = (unsigned int *)test;
97800
97801 if (*p != INT_CONF) {
97802 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97803 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97804 new file mode 100644
97805 index 0000000..5e0222d
97806 --- /dev/null
97807 +++ b/scripts/gcc-plugin.sh
97808 @@ -0,0 +1,17 @@
97809 +#!/bin/bash
97810 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97811 +#include "gcc-plugin.h"
97812 +#include "tree.h"
97813 +#include "tm.h"
97814 +#include "rtl.h"
97815 +#ifdef ENABLE_BUILD_WITH_CXX
97816 +#warning $2
97817 +#else
97818 +#warning $1
97819 +#endif
97820 +EOF`
97821 +if [ $? -eq 0 ]
97822 +then
97823 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97824 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97825 +fi
97826 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97827 index 5de5660..d3deb89 100644
97828 --- a/scripts/headers_install.sh
97829 +++ b/scripts/headers_install.sh
97830 @@ -32,6 +32,7 @@ do
97831 FILE="$(basename "$i")"
97832 sed -r \
97833 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97834 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97835 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97836 -e 's@^#include <linux/compiler.h>@@' \
97837 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97838 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97839 index 32b10f5..64eeb30 100644
97840 --- a/scripts/link-vmlinux.sh
97841 +++ b/scripts/link-vmlinux.sh
97842 @@ -82,7 +82,9 @@ kallsyms()
97843 kallsymopt="${kallsymopt} --all-symbols"
97844 fi
97845
97846 - kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
97847 + if [ -z "${CONFIG_X86_32}" ] || [ -z "${CONFIG_PAX_KERNEXEC}" ]; then
97848 + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
97849 + fi
97850
97851 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
97852 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
97853 @@ -160,7 +162,7 @@ else
97854 fi;
97855
97856 # final build of init/
97857 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97858 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97859
97860 kallsymso=""
97861 kallsyms_vmlinux=""
97862 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97863 index 2370863..212fbca 100644
97864 --- a/scripts/mod/file2alias.c
97865 +++ b/scripts/mod/file2alias.c
97866 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97867 unsigned long size, unsigned long id_size,
97868 void *symval)
97869 {
97870 - int i;
97871 + unsigned int i;
97872
97873 if (size % id_size || size < id_size) {
97874 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97875 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97876 /* USB is special because the bcdDevice can be matched against a numeric range */
97877 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97878 static void do_usb_entry(void *symval,
97879 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97880 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97881 unsigned char range_lo, unsigned char range_hi,
97882 unsigned char max, struct module *mod)
97883 {
97884 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97885 {
97886 unsigned int devlo, devhi;
97887 unsigned char chi, clo, max;
97888 - int ndigits;
97889 + unsigned int ndigits;
97890
97891 DEF_FIELD(symval, usb_device_id, match_flags);
97892 DEF_FIELD(symval, usb_device_id, idVendor);
97893 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97894 for (i = 0; i < count; i++) {
97895 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97896 char acpi_id[sizeof(*id)];
97897 - int j;
97898 + unsigned int j;
97899
97900 buf_printf(&mod->dev_table_buf,
97901 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97902 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97903
97904 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97905 const char *id = (char *)(*devs)[j].id;
97906 - int i2, j2;
97907 + unsigned int i2, j2;
97908 int dup = 0;
97909
97910 if (!id[0])
97911 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97912 /* add an individual alias for every device entry */
97913 if (!dup) {
97914 char acpi_id[PNP_ID_LEN];
97915 - int k;
97916 + unsigned int k;
97917
97918 buf_printf(&mod->dev_table_buf,
97919 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97920 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97921 static int do_dmi_entry(const char *filename, void *symval,
97922 char *alias)
97923 {
97924 - int i, j;
97925 + unsigned int i, j;
97926 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97927 sprintf(alias, "dmi*");
97928
97929 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97930 index 8247979..815ec76 100644
97931 --- a/scripts/mod/modpost.c
97932 +++ b/scripts/mod/modpost.c
97933 @@ -931,6 +931,7 @@ enum mismatch {
97934 ANY_INIT_TO_ANY_EXIT,
97935 ANY_EXIT_TO_ANY_INIT,
97936 EXPORT_TO_INIT_EXIT,
97937 + DATA_TO_TEXT
97938 };
97939
97940 struct sectioncheck {
97941 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
97942 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97943 .mismatch = EXPORT_TO_INIT_EXIT,
97944 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97945 +},
97946 +/* Do not reference code from writable data */
97947 +{
97948 + .fromsec = { DATA_SECTIONS, NULL },
97949 + .tosec = { TEXT_SECTIONS, NULL },
97950 + .mismatch = DATA_TO_TEXT
97951 }
97952 };
97953
97954 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97955 continue;
97956 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97957 continue;
97958 - if (sym->st_value == addr)
97959 - return sym;
97960 /* Find a symbol nearby - addr are maybe negative */
97961 d = sym->st_value - addr;
97962 + if (d == 0)
97963 + return sym;
97964 if (d < 0)
97965 d = addr - sym->st_value;
97966 if (d < distance) {
97967 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
97968 tosym, prl_to, prl_to, tosym);
97969 free(prl_to);
97970 break;
97971 + case DATA_TO_TEXT:
97972 +#if 0
97973 + fprintf(stderr,
97974 + "The %s %s:%s references\n"
97975 + "the %s %s:%s%s\n",
97976 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97977 +#endif
97978 + break;
97979 }
97980 fprintf(stderr, "\n");
97981 }
97982 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97983 static void check_sec_ref(struct module *mod, const char *modname,
97984 struct elf_info *elf)
97985 {
97986 - int i;
97987 + unsigned int i;
97988 Elf_Shdr *sechdrs = elf->sechdrs;
97989
97990 /* Walk through all sections */
97991 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97992 va_end(ap);
97993 }
97994
97995 -void buf_write(struct buffer *buf, const char *s, int len)
97996 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97997 {
97998 if (buf->size - buf->pos < len) {
97999 buf->size += len + SZ;
98000 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98001 if (fstat(fileno(file), &st) < 0)
98002 goto close_write;
98003
98004 - if (st.st_size != b->pos)
98005 + if (st.st_size != (off_t)b->pos)
98006 goto close_write;
98007
98008 tmp = NOFAIL(malloc(b->pos));
98009 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98010 index 51207e4..f7d603d 100644
98011 --- a/scripts/mod/modpost.h
98012 +++ b/scripts/mod/modpost.h
98013 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98014
98015 struct buffer {
98016 char *p;
98017 - int pos;
98018 - int size;
98019 + unsigned int pos;
98020 + unsigned int size;
98021 };
98022
98023 void __attribute__((format(printf, 2, 3)))
98024 buf_printf(struct buffer *buf, const char *fmt, ...);
98025
98026 void
98027 -buf_write(struct buffer *buf, const char *s, int len);
98028 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98029
98030 struct module {
98031 struct module *next;
98032 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98033 index 9dfcd6d..099068e 100644
98034 --- a/scripts/mod/sumversion.c
98035 +++ b/scripts/mod/sumversion.c
98036 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98037 goto out;
98038 }
98039
98040 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98041 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98042 warn("writing sum in %s failed: %s\n",
98043 filename, strerror(errno));
98044 goto out;
98045 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
98046 index 0865b3e..7235dd4 100644
98047 --- a/scripts/module-common.lds
98048 +++ b/scripts/module-common.lds
98049 @@ -6,6 +6,10 @@
98050 SECTIONS {
98051 /DISCARD/ : { *(.discard) }
98052
98053 + .rodata : {
98054 + *(.rodata) *(.rodata.*)
98055 + *(.data..read_only)
98056 + }
98057 __ksymtab : { *(SORT(___ksymtab+*)) }
98058 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
98059 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
98060 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98061 index 90e521f..e9eaf8f 100644
98062 --- a/scripts/package/builddeb
98063 +++ b/scripts/package/builddeb
98064 @@ -281,6 +281,7 @@ fi
98065 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98066 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98067 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98068 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98069 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98070 mkdir -p "$destdir"
98071 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98072 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98073 index 68bb4ef..2f419e1 100644
98074 --- a/scripts/pnmtologo.c
98075 +++ b/scripts/pnmtologo.c
98076 @@ -244,14 +244,14 @@ static void write_header(void)
98077 fprintf(out, " * Linux logo %s\n", logoname);
98078 fputs(" */\n\n", out);
98079 fputs("#include <linux/linux_logo.h>\n\n", out);
98080 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98081 + fprintf(out, "static unsigned char %s_data[] = {\n",
98082 logoname);
98083 }
98084
98085 static void write_footer(void)
98086 {
98087 fputs("\n};\n\n", out);
98088 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98089 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98090 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98091 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98092 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98093 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98094 fputs("\n};\n\n", out);
98095
98096 /* write logo clut */
98097 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98098 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98099 logoname);
98100 write_hex_cnt = 0;
98101 for (i = 0; i < logo_clutsize; i++) {
98102 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98103 index f5eb43d..1814de8 100644
98104 --- a/scripts/sortextable.h
98105 +++ b/scripts/sortextable.h
98106 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98107 const char *secstrtab;
98108 const char *strtab;
98109 char *extab_image;
98110 - int extab_index = 0;
98111 - int i;
98112 - int idx;
98113 + unsigned int extab_index = 0;
98114 + unsigned int i;
98115 + unsigned int idx;
98116
98117 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98118 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98119 diff --git a/security/Kconfig b/security/Kconfig
98120 index e9c6ac7..031a726 100644
98121 --- a/security/Kconfig
98122 +++ b/security/Kconfig
98123 @@ -4,6 +4,960 @@
98124
98125 menu "Security options"
98126
98127 +menu "Grsecurity"
98128 +
98129 + config ARCH_TRACK_EXEC_LIMIT
98130 + bool
98131 +
98132 + config PAX_KERNEXEC_PLUGIN
98133 + bool
98134 +
98135 + config PAX_PER_CPU_PGD
98136 + bool
98137 +
98138 + config TASK_SIZE_MAX_SHIFT
98139 + int
98140 + depends on X86_64
98141 + default 47 if !PAX_PER_CPU_PGD
98142 + default 42 if PAX_PER_CPU_PGD
98143 +
98144 + config PAX_ENABLE_PAE
98145 + bool
98146 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98147 +
98148 + config PAX_USERCOPY_SLABS
98149 + bool
98150 +
98151 +config GRKERNSEC
98152 + bool "Grsecurity"
98153 + select CRYPTO
98154 + select CRYPTO_SHA256
98155 + select PROC_FS
98156 + select STOP_MACHINE
98157 + select TTY
98158 + select DEBUG_LIST
98159 + help
98160 + If you say Y here, you will be able to configure many features
98161 + that will enhance the security of your system. It is highly
98162 + recommended that you say Y here and read through the help
98163 + for each option so that you fully understand the features and
98164 + can evaluate their usefulness for your machine.
98165 +
98166 +choice
98167 + prompt "Configuration Method"
98168 + depends on GRKERNSEC
98169 + default GRKERNSEC_CONFIG_CUSTOM
98170 + help
98171 +
98172 +config GRKERNSEC_CONFIG_AUTO
98173 + bool "Automatic"
98174 + help
98175 + If you choose this configuration method, you'll be able to answer a small
98176 + number of simple questions about how you plan to use this kernel.
98177 + The settings of grsecurity and PaX will be automatically configured for
98178 + the highest commonly-used settings within the provided constraints.
98179 +
98180 + If you require additional configuration, custom changes can still be made
98181 + from the "custom configuration" menu.
98182 +
98183 +config GRKERNSEC_CONFIG_CUSTOM
98184 + bool "Custom"
98185 + help
98186 + If you choose this configuration method, you'll be able to configure all
98187 + grsecurity and PaX settings manually. Via this method, no options are
98188 + automatically enabled.
98189 +
98190 +endchoice
98191 +
98192 +choice
98193 + prompt "Usage Type"
98194 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98195 + default GRKERNSEC_CONFIG_SERVER
98196 + help
98197 +
98198 +config GRKERNSEC_CONFIG_SERVER
98199 + bool "Server"
98200 + help
98201 + Choose this option if you plan to use this kernel on a server.
98202 +
98203 +config GRKERNSEC_CONFIG_DESKTOP
98204 + bool "Desktop"
98205 + help
98206 + Choose this option if you plan to use this kernel on a desktop.
98207 +
98208 +endchoice
98209 +
98210 +choice
98211 + prompt "Virtualization Type"
98212 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98213 + default GRKERNSEC_CONFIG_VIRT_NONE
98214 + help
98215 +
98216 +config GRKERNSEC_CONFIG_VIRT_NONE
98217 + bool "None"
98218 + help
98219 + Choose this option if this kernel will be run on bare metal.
98220 +
98221 +config GRKERNSEC_CONFIG_VIRT_GUEST
98222 + bool "Guest"
98223 + help
98224 + Choose this option if this kernel will be run as a VM guest.
98225 +
98226 +config GRKERNSEC_CONFIG_VIRT_HOST
98227 + bool "Host"
98228 + help
98229 + Choose this option if this kernel will be run as a VM host.
98230 +
98231 +endchoice
98232 +
98233 +choice
98234 + prompt "Virtualization Hardware"
98235 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98236 + help
98237 +
98238 +config GRKERNSEC_CONFIG_VIRT_EPT
98239 + bool "EPT/RVI Processor Support"
98240 + depends on X86
98241 + help
98242 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
98243 + hardware virtualization. This allows for additional kernel hardening protections
98244 + to operate without additional performance impact.
98245 +
98246 + To see if your Intel processor supports EPT, see:
98247 + http://ark.intel.com/Products/VirtualizationTechnology
98248 + (Most Core i3/5/7 support EPT)
98249 +
98250 + To see if your AMD processor supports RVI, see:
98251 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
98252 +
98253 +config GRKERNSEC_CONFIG_VIRT_SOFT
98254 + bool "First-gen/No Hardware Virtualization"
98255 + help
98256 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
98257 + support hardware virtualization or doesn't support the EPT/RVI extensions.
98258 +
98259 +endchoice
98260 +
98261 +choice
98262 + prompt "Virtualization Software"
98263 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98264 + help
98265 +
98266 +config GRKERNSEC_CONFIG_VIRT_XEN
98267 + bool "Xen"
98268 + help
98269 + Choose this option if this kernel is running as a Xen guest or host.
98270 +
98271 +config GRKERNSEC_CONFIG_VIRT_VMWARE
98272 + bool "VMWare"
98273 + help
98274 + Choose this option if this kernel is running as a VMWare guest or host.
98275 +
98276 +config GRKERNSEC_CONFIG_VIRT_KVM
98277 + bool "KVM"
98278 + help
98279 + Choose this option if this kernel is running as a KVM guest or host.
98280 +
98281 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
98282 + bool "VirtualBox"
98283 + help
98284 + Choose this option if this kernel is running as a VirtualBox guest or host.
98285 +
98286 +endchoice
98287 +
98288 +choice
98289 + prompt "Required Priorities"
98290 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98291 + default GRKERNSEC_CONFIG_PRIORITY_PERF
98292 + help
98293 +
98294 +config GRKERNSEC_CONFIG_PRIORITY_PERF
98295 + bool "Performance"
98296 + help
98297 + Choose this option if performance is of highest priority for this deployment
98298 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
98299 + clearing of structures intended for userland, and freed memory sanitizing will
98300 + be disabled.
98301 +
98302 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
98303 + bool "Security"
98304 + help
98305 + Choose this option if security is of highest priority for this deployment of
98306 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
98307 + for userland, and freed memory sanitizing will be enabled for this kernel.
98308 + In a worst-case scenario, these features can introduce a 20% performance hit
98309 + (UDEREF on x64 contributing half of this hit).
98310 +
98311 +endchoice
98312 +
98313 +menu "Default Special Groups"
98314 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98315 +
98316 +config GRKERNSEC_PROC_GID
98317 + int "GID exempted from /proc restrictions"
98318 + default 1001
98319 + help
98320 + Setting this GID determines which group will be exempted from
98321 + grsecurity's /proc restrictions, allowing users of the specified
98322 + group to view network statistics and the existence of other users'
98323 + processes on the system. This GID may also be chosen at boot time
98324 + via "grsec_proc_gid=" on the kernel commandline.
98325 +
98326 +config GRKERNSEC_TPE_UNTRUSTED_GID
98327 + int "GID for TPE-untrusted users"
98328 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
98329 + default 1005
98330 + help
98331 + Setting this GID determines which group untrusted users should
98332 + be added to. These users will be placed under grsecurity's Trusted Path
98333 + Execution mechanism, preventing them from executing their own binaries.
98334 + The users will only be able to execute binaries in directories owned and
98335 + writable only by the root user. If the sysctl option is enabled, a sysctl
98336 + option with name "tpe_gid" is created.
98337 +
98338 +config GRKERNSEC_TPE_TRUSTED_GID
98339 + int "GID for TPE-trusted users"
98340 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
98341 + default 1005
98342 + help
98343 + Setting this GID determines what group TPE restrictions will be
98344 + *disabled* for. If the sysctl option is enabled, a sysctl option
98345 + with name "tpe_gid" is created.
98346 +
98347 +config GRKERNSEC_SYMLINKOWN_GID
98348 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
98349 + depends on GRKERNSEC_CONFIG_SERVER
98350 + default 1006
98351 + help
98352 + Setting this GID determines what group kernel-enforced
98353 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
98354 + is enabled, a sysctl option with name "symlinkown_gid" is created.
98355 +
98356 +
98357 +endmenu
98358 +
98359 +menu "Customize Configuration"
98360 +depends on GRKERNSEC
98361 +
98362 +menu "PaX"
98363 +
98364 +config PAX
98365 + bool "Enable various PaX features"
98366 + default y if GRKERNSEC_CONFIG_AUTO
98367 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
98368 + help
98369 + This allows you to enable various PaX features. PaX adds
98370 + intrusion prevention mechanisms to the kernel that reduce
98371 + the risks posed by exploitable memory corruption bugs.
98372 +
98373 +menu "PaX Control"
98374 + depends on PAX
98375 +
98376 +config PAX_SOFTMODE
98377 + bool 'Support soft mode'
98378 + help
98379 + Enabling this option will allow you to run PaX in soft mode, that
98380 + is, PaX features will not be enforced by default, only on executables
98381 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
98382 + support as they are the only way to mark executables for soft mode use.
98383 +
98384 + Soft mode can be activated by using the "pax_softmode=1" kernel command
98385 + line option on boot. Furthermore you can control various PaX features
98386 + at runtime via the entries in /proc/sys/kernel/pax.
98387 +
98388 +config PAX_EI_PAX
98389 + bool 'Use legacy ELF header marking'
98390 + default y if GRKERNSEC_CONFIG_AUTO
98391 + help
98392 + Enabling this option will allow you to control PaX features on
98393 + a per executable basis via the 'chpax' utility available at
98394 + http://pax.grsecurity.net/. The control flags will be read from
98395 + an otherwise reserved part of the ELF header. This marking has
98396 + numerous drawbacks (no support for soft-mode, toolchain does not
98397 + know about the non-standard use of the ELF header) therefore it
98398 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
98399 + support.
98400 +
98401 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
98402 + support as well, they will override the legacy EI_PAX marks.
98403 +
98404 + If you enable none of the marking options then all applications
98405 + will run with PaX enabled on them by default.
98406 +
98407 +config PAX_PT_PAX_FLAGS
98408 + bool 'Use ELF program header marking'
98409 + default y if GRKERNSEC_CONFIG_AUTO
98410 + help
98411 + Enabling this option will allow you to control PaX features on
98412 + a per executable basis via the 'paxctl' utility available at
98413 + http://pax.grsecurity.net/. The control flags will be read from
98414 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
98415 + has the benefits of supporting both soft mode and being fully
98416 + integrated into the toolchain (the binutils patch is available
98417 + from http://pax.grsecurity.net).
98418 +
98419 + Note that if you enable the legacy EI_PAX marking support as well,
98420 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
98421 +
98422 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98423 + must make sure that the marks are the same if a binary has both marks.
98424 +
98425 + If you enable none of the marking options then all applications
98426 + will run with PaX enabled on them by default.
98427 +
98428 +config PAX_XATTR_PAX_FLAGS
98429 + bool 'Use filesystem extended attributes marking'
98430 + default y if GRKERNSEC_CONFIG_AUTO
98431 + select CIFS_XATTR if CIFS
98432 + select EXT2_FS_XATTR if EXT2_FS
98433 + select EXT3_FS_XATTR if EXT3_FS
98434 + select EXT4_FS_XATTR if EXT4_FS
98435 + select JFFS2_FS_XATTR if JFFS2_FS
98436 + select REISERFS_FS_XATTR if REISERFS_FS
98437 + select SQUASHFS_XATTR if SQUASHFS
98438 + select TMPFS_XATTR if TMPFS
98439 + select UBIFS_FS_XATTR if UBIFS_FS
98440 + help
98441 + Enabling this option will allow you to control PaX features on
98442 + a per executable basis via the 'setfattr' utility. The control
98443 + flags will be read from the user.pax.flags extended attribute of
98444 + the file. This marking has the benefit of supporting binary-only
98445 + applications that self-check themselves (e.g., skype) and would
98446 + not tolerate chpax/paxctl changes. The main drawback is that
98447 + extended attributes are not supported by some filesystems (e.g.,
98448 + isofs, udf, vfat) so copying files through such filesystems will
98449 + lose the extended attributes and these PaX markings.
98450 +
98451 + Note that if you enable the legacy EI_PAX marking support as well,
98452 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
98453 +
98454 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98455 + must make sure that the marks are the same if a binary has both marks.
98456 +
98457 + If you enable none of the marking options then all applications
98458 + will run with PaX enabled on them by default.
98459 +
98460 +choice
98461 + prompt 'MAC system integration'
98462 + default PAX_HAVE_ACL_FLAGS
98463 + help
98464 + Mandatory Access Control systems have the option of controlling
98465 + PaX flags on a per executable basis, choose the method supported
98466 + by your particular system.
98467 +
98468 + - "none": if your MAC system does not interact with PaX,
98469 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
98470 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
98471 +
98472 + NOTE: this option is for developers/integrators only.
98473 +
98474 + config PAX_NO_ACL_FLAGS
98475 + bool 'none'
98476 +
98477 + config PAX_HAVE_ACL_FLAGS
98478 + bool 'direct'
98479 +
98480 + config PAX_HOOK_ACL_FLAGS
98481 + bool 'hook'
98482 +endchoice
98483 +
98484 +endmenu
98485 +
98486 +menu "Non-executable pages"
98487 + depends on PAX
98488 +
98489 +config PAX_NOEXEC
98490 + bool "Enforce non-executable pages"
98491 + default y if GRKERNSEC_CONFIG_AUTO
98492 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98493 + help
98494 + By design some architectures do not allow for protecting memory
98495 + pages against execution or even if they do, Linux does not make
98496 + use of this feature. In practice this means that if a page is
98497 + readable (such as the stack or heap) it is also executable.
98498 +
98499 + There is a well known exploit technique that makes use of this
98500 + fact and a common programming mistake where an attacker can
98501 + introduce code of his choice somewhere in the attacked program's
98502 + memory (typically the stack or the heap) and then execute it.
98503 +
98504 + If the attacked program was running with different (typically
98505 + higher) privileges than that of the attacker, then he can elevate
98506 + his own privilege level (e.g. get a root shell, write to files for
98507 + which he does not have write access to, etc).
98508 +
98509 + Enabling this option will let you choose from various features
98510 + that prevent the injection and execution of 'foreign' code in
98511 + a program.
98512 +
98513 + This will also break programs that rely on the old behaviour and
98514 + expect that dynamically allocated memory via the malloc() family
98515 + of functions is executable (which it is not). Notable examples
98516 + are the XFree86 4.x server, the java runtime and wine.
98517 +
98518 +config PAX_PAGEEXEC
98519 + bool "Paging based non-executable pages"
98520 + default y if GRKERNSEC_CONFIG_AUTO
98521 + 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)
98522 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98523 + help
98524 + This implementation is based on the paging feature of the CPU.
98525 + On i386 without hardware non-executable bit support there is a
98526 + variable but usually low performance impact, however on Intel's
98527 + P4 core based CPUs it is very high so you should not enable this
98528 + for kernels meant to be used on such CPUs.
98529 +
98530 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98531 + with hardware non-executable bit support there is no performance
98532 + impact, on ppc the impact is negligible.
98533 +
98534 + Note that several architectures require various emulations due to
98535 + badly designed userland ABIs, this will cause a performance impact
98536 + but will disappear as soon as userland is fixed. For example, ppc
98537 + userland MUST have been built with secure-plt by a recent toolchain.
98538 +
98539 +config PAX_SEGMEXEC
98540 + bool "Segmentation based non-executable pages"
98541 + default y if GRKERNSEC_CONFIG_AUTO
98542 + depends on PAX_NOEXEC && X86_32
98543 + help
98544 + This implementation is based on the segmentation feature of the
98545 + CPU and has a very small performance impact, however applications
98546 + will be limited to a 1.5 GB address space instead of the normal
98547 + 3 GB.
98548 +
98549 +config PAX_EMUTRAMP
98550 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98551 + default y if PARISC
98552 + help
98553 + There are some programs and libraries that for one reason or
98554 + another attempt to execute special small code snippets from
98555 + non-executable memory pages. Most notable examples are the
98556 + signal handler return code generated by the kernel itself and
98557 + the GCC trampolines.
98558 +
98559 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98560 + such programs will no longer work under your kernel.
98561 +
98562 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98563 + utilities to enable trampoline emulation for the affected programs
98564 + yet still have the protection provided by the non-executable pages.
98565 +
98566 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98567 + your system will not even boot.
98568 +
98569 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98570 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98571 + for the affected files.
98572 +
98573 + NOTE: enabling this feature *may* open up a loophole in the
98574 + protection provided by non-executable pages that an attacker
98575 + could abuse. Therefore the best solution is to not have any
98576 + files on your system that would require this option. This can
98577 + be achieved by not using libc5 (which relies on the kernel
98578 + signal handler return code) and not using or rewriting programs
98579 + that make use of the nested function implementation of GCC.
98580 + Skilled users can just fix GCC itself so that it implements
98581 + nested function calls in a way that does not interfere with PaX.
98582 +
98583 +config PAX_EMUSIGRT
98584 + bool "Automatically emulate sigreturn trampolines"
98585 + depends on PAX_EMUTRAMP && PARISC
98586 + default y
98587 + help
98588 + Enabling this option will have the kernel automatically detect
98589 + and emulate signal return trampolines executing on the stack
98590 + that would otherwise lead to task termination.
98591 +
98592 + This solution is intended as a temporary one for users with
98593 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98594 + Modula-3 runtime, etc) or executables linked to such, basically
98595 + everything that does not specify its own SA_RESTORER function in
98596 + normal executable memory like glibc 2.1+ does.
98597 +
98598 + On parisc you MUST enable this option, otherwise your system will
98599 + not even boot.
98600 +
98601 + NOTE: this feature cannot be disabled on a per executable basis
98602 + and since it *does* open up a loophole in the protection provided
98603 + by non-executable pages, the best solution is to not have any
98604 + files on your system that would require this option.
98605 +
98606 +config PAX_MPROTECT
98607 + bool "Restrict mprotect()"
98608 + default y if GRKERNSEC_CONFIG_AUTO
98609 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98610 + help
98611 + Enabling this option will prevent programs from
98612 + - changing the executable status of memory pages that were
98613 + not originally created as executable,
98614 + - making read-only executable pages writable again,
98615 + - creating executable pages from anonymous memory,
98616 + - making read-only-after-relocations (RELRO) data pages writable again.
98617 +
98618 + You should say Y here to complete the protection provided by
98619 + the enforcement of non-executable pages.
98620 +
98621 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98622 + this feature on a per file basis.
98623 +
98624 +config PAX_MPROTECT_COMPAT
98625 + bool "Use legacy/compat protection demoting (read help)"
98626 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98627 + depends on PAX_MPROTECT
98628 + help
98629 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98630 + by sending the proper error code to the application. For some broken
98631 + userland, this can cause problems with Python or other applications. The
98632 + current implementation however allows for applications like clamav to
98633 + detect if JIT compilation/execution is allowed and to fall back gracefully
98634 + to an interpreter-based mode if it does not. While we encourage everyone
98635 + to use the current implementation as-is and push upstream to fix broken
98636 + userland (note that the RWX logging option can assist with this), in some
98637 + environments this may not be possible. Having to disable MPROTECT
98638 + completely on certain binaries reduces the security benefit of PaX,
98639 + so this option is provided for those environments to revert to the old
98640 + behavior.
98641 +
98642 +config PAX_ELFRELOCS
98643 + bool "Allow ELF text relocations (read help)"
98644 + depends on PAX_MPROTECT
98645 + default n
98646 + help
98647 + Non-executable pages and mprotect() restrictions are effective
98648 + in preventing the introduction of new executable code into an
98649 + attacked task's address space. There remain only two venues
98650 + for this kind of attack: if the attacker can execute already
98651 + existing code in the attacked task then he can either have it
98652 + create and mmap() a file containing his code or have it mmap()
98653 + an already existing ELF library that does not have position
98654 + independent code in it and use mprotect() on it to make it
98655 + writable and copy his code there. While protecting against
98656 + the former approach is beyond PaX, the latter can be prevented
98657 + by having only PIC ELF libraries on one's system (which do not
98658 + need to relocate their code). If you are sure this is your case,
98659 + as is the case with all modern Linux distributions, then leave
98660 + this option disabled. You should say 'n' here.
98661 +
98662 +config PAX_ETEXECRELOCS
98663 + bool "Allow ELF ET_EXEC text relocations"
98664 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98665 + select PAX_ELFRELOCS
98666 + default y
98667 + help
98668 + On some architectures there are incorrectly created applications
98669 + that require text relocations and would not work without enabling
98670 + this option. If you are an alpha, ia64 or parisc user, you should
98671 + enable this option and disable it once you have made sure that
98672 + none of your applications need it.
98673 +
98674 +config PAX_EMUPLT
98675 + bool "Automatically emulate ELF PLT"
98676 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98677 + default y
98678 + help
98679 + Enabling this option will have the kernel automatically detect
98680 + and emulate the Procedure Linkage Table entries in ELF files.
98681 + On some architectures such entries are in writable memory, and
98682 + become non-executable leading to task termination. Therefore
98683 + it is mandatory that you enable this option on alpha, parisc,
98684 + sparc and sparc64, otherwise your system would not even boot.
98685 +
98686 + NOTE: this feature *does* open up a loophole in the protection
98687 + provided by the non-executable pages, therefore the proper
98688 + solution is to modify the toolchain to produce a PLT that does
98689 + not need to be writable.
98690 +
98691 +config PAX_DLRESOLVE
98692 + bool 'Emulate old glibc resolver stub'
98693 + depends on PAX_EMUPLT && SPARC
98694 + default n
98695 + help
98696 + This option is needed if userland has an old glibc (before 2.4)
98697 + that puts a 'save' instruction into the runtime generated resolver
98698 + stub that needs special emulation.
98699 +
98700 +config PAX_KERNEXEC
98701 + bool "Enforce non-executable kernel pages"
98702 + 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))
98703 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98704 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98705 + select PAX_KERNEXEC_PLUGIN if X86_64
98706 + help
98707 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98708 + that is, enabling this option will make it harder to inject
98709 + and execute 'foreign' code in kernel memory itself.
98710 +
98711 +choice
98712 + prompt "Return Address Instrumentation Method"
98713 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98714 + depends on PAX_KERNEXEC_PLUGIN
98715 + help
98716 + Select the method used to instrument function pointer dereferences.
98717 + Note that binary modules cannot be instrumented by this approach.
98718 +
98719 + Note that the implementation requires a gcc with plugin support,
98720 + i.e., gcc 4.5 or newer. You may need to install the supporting
98721 + headers explicitly in addition to the normal gcc package.
98722 +
98723 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98724 + bool "bts"
98725 + help
98726 + This method is compatible with binary only modules but has
98727 + a higher runtime overhead.
98728 +
98729 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98730 + bool "or"
98731 + depends on !PARAVIRT
98732 + help
98733 + This method is incompatible with binary only modules but has
98734 + a lower runtime overhead.
98735 +endchoice
98736 +
98737 +config PAX_KERNEXEC_PLUGIN_METHOD
98738 + string
98739 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98740 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98741 + default ""
98742 +
98743 +config PAX_KERNEXEC_MODULE_TEXT
98744 + int "Minimum amount of memory reserved for module code"
98745 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98746 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98747 + depends on PAX_KERNEXEC && X86_32
98748 + help
98749 + Due to implementation details the kernel must reserve a fixed
98750 + amount of memory for runtime allocated code (such as modules)
98751 + at compile time that cannot be changed at runtime. Here you
98752 + can specify the minimum amount in MB that will be reserved.
98753 + Due to the same implementation details this size will always
98754 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98755 + the actually available memory for runtime allocated code will
98756 + usually be more than this minimum.
98757 +
98758 + The default 4 MB should be enough for most users but if you have
98759 + an excessive number of modules (e.g., most distribution configs
98760 + compile many drivers as modules) or use huge modules such as
98761 + nvidia's kernel driver, you will need to adjust this amount.
98762 + A good rule of thumb is to look at your currently loaded kernel
98763 + modules and add up their sizes.
98764 +
98765 +endmenu
98766 +
98767 +menu "Address Space Layout Randomization"
98768 + depends on PAX
98769 +
98770 +config PAX_ASLR
98771 + bool "Address Space Layout Randomization"
98772 + default y if GRKERNSEC_CONFIG_AUTO
98773 + help
98774 + Many if not most exploit techniques rely on the knowledge of
98775 + certain addresses in the attacked program. The following options
98776 + will allow the kernel to apply a certain amount of randomization
98777 + to specific parts of the program thereby forcing an attacker to
98778 + guess them in most cases. Any failed guess will most likely crash
98779 + the attacked program which allows the kernel to detect such attempts
98780 + and react on them. PaX itself provides no reaction mechanisms,
98781 + instead it is strongly encouraged that you make use of Nergal's
98782 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98783 + (http://www.grsecurity.net/) built-in crash detection features or
98784 + develop one yourself.
98785 +
98786 + By saying Y here you can choose to randomize the following areas:
98787 + - top of the task's kernel stack
98788 + - top of the task's userland stack
98789 + - base address for mmap() requests that do not specify one
98790 + (this includes all libraries)
98791 + - base address of the main executable
98792 +
98793 + It is strongly recommended to say Y here as address space layout
98794 + randomization has negligible impact on performance yet it provides
98795 + a very effective protection.
98796 +
98797 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98798 + this feature on a per file basis.
98799 +
98800 +config PAX_RANDKSTACK
98801 + bool "Randomize kernel stack base"
98802 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98803 + depends on X86_TSC && X86
98804 + help
98805 + By saying Y here the kernel will randomize every task's kernel
98806 + stack on every system call. This will not only force an attacker
98807 + to guess it but also prevent him from making use of possible
98808 + leaked information about it.
98809 +
98810 + Since the kernel stack is a rather scarce resource, randomization
98811 + may cause unexpected stack overflows, therefore you should very
98812 + carefully test your system. Note that once enabled in the kernel
98813 + configuration, this feature cannot be disabled on a per file basis.
98814 +
98815 +config PAX_RANDUSTACK
98816 + bool "Randomize user stack base"
98817 + default y if GRKERNSEC_CONFIG_AUTO
98818 + depends on PAX_ASLR
98819 + help
98820 + By saying Y here the kernel will randomize every task's userland
98821 + stack. The randomization is done in two steps where the second
98822 + one may apply a big amount of shift to the top of the stack and
98823 + cause problems for programs that want to use lots of memory (more
98824 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98825 + For this reason the second step can be controlled by 'chpax' or
98826 + 'paxctl' on a per file basis.
98827 +
98828 +config PAX_RANDMMAP
98829 + bool "Randomize mmap() base"
98830 + default y if GRKERNSEC_CONFIG_AUTO
98831 + depends on PAX_ASLR
98832 + help
98833 + By saying Y here the kernel will use a randomized base address for
98834 + mmap() requests that do not specify one themselves. As a result
98835 + all dynamically loaded libraries will appear at random addresses
98836 + and therefore be harder to exploit by a technique where an attacker
98837 + attempts to execute library code for his purposes (e.g. spawn a
98838 + shell from an exploited program that is running at an elevated
98839 + privilege level).
98840 +
98841 + Furthermore, if a program is relinked as a dynamic ELF file, its
98842 + base address will be randomized as well, completing the full
98843 + randomization of the address space layout. Attacking such programs
98844 + becomes a guess game. You can find an example of doing this at
98845 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98846 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98847 +
98848 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98849 + feature on a per file basis.
98850 +
98851 +endmenu
98852 +
98853 +menu "Miscellaneous hardening features"
98854 +
98855 +config PAX_MEMORY_SANITIZE
98856 + bool "Sanitize all freed memory"
98857 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98858 + depends on !HIBERNATION
98859 + help
98860 + By saying Y here the kernel will erase memory pages and slab objects
98861 + as soon as they are freed. This in turn reduces the lifetime of data
98862 + stored in them, making it less likely that sensitive information such
98863 + as passwords, cryptographic secrets, etc stay in memory for too long.
98864 +
98865 + This is especially useful for programs whose runtime is short, long
98866 + lived processes and the kernel itself benefit from this as long as
98867 + they ensure timely freeing of memory that may hold sensitive
98868 + information.
98869 +
98870 + A nice side effect of the sanitization of slab objects is the
98871 + reduction of possible info leaks caused by padding bytes within the
98872 + leaky structures. Use-after-free bugs for structures containing
98873 + pointers can also be detected as dereferencing the sanitized pointer
98874 + will generate an access violation.
98875 +
98876 + The tradeoff is performance impact, on a single CPU system kernel
98877 + compilation sees a 3% slowdown, other systems and workloads may vary
98878 + and you are advised to test this feature on your expected workload
98879 + before deploying it.
98880 +
98881 + To reduce the performance penalty by sanitizing pages only, albeit
98882 + limiting the effectiveness of this feature at the same time, slab
98883 + sanitization can be disabled with the kernel commandline parameter
98884 + "pax_sanitize_slab=0".
98885 +
98886 + Note that this feature does not protect data stored in live pages,
98887 + e.g., process memory swapped to disk may stay there for a long time.
98888 +
98889 +config PAX_MEMORY_STACKLEAK
98890 + bool "Sanitize kernel stack"
98891 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98892 + depends on X86
98893 + help
98894 + By saying Y here the kernel will erase the kernel stack before it
98895 + returns from a system call. This in turn reduces the information
98896 + that a kernel stack leak bug can reveal.
98897 +
98898 + Note that such a bug can still leak information that was put on
98899 + the stack by the current system call (the one eventually triggering
98900 + the bug) but traces of earlier system calls on the kernel stack
98901 + cannot leak anymore.
98902 +
98903 + The tradeoff is performance impact: on a single CPU system kernel
98904 + compilation sees a 1% slowdown, other systems and workloads may vary
98905 + and you are advised to test this feature on your expected workload
98906 + before deploying it.
98907 +
98908 + Note that the full feature requires a gcc with plugin support,
98909 + i.e., gcc 4.5 or newer. You may need to install the supporting
98910 + headers explicitly in addition to the normal gcc package. Using
98911 + older gcc versions means that functions with large enough stack
98912 + frames may leave uninitialized memory behind that may be exposed
98913 + to a later syscall leaking the stack.
98914 +
98915 +config PAX_MEMORY_STRUCTLEAK
98916 + bool "Forcibly initialize local variables copied to userland"
98917 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98918 + help
98919 + By saying Y here the kernel will zero initialize some local
98920 + variables that are going to be copied to userland. This in
98921 + turn prevents unintended information leakage from the kernel
98922 + stack should later code forget to explicitly set all parts of
98923 + the copied variable.
98924 +
98925 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98926 + at a much smaller coverage.
98927 +
98928 + Note that the implementation requires a gcc with plugin support,
98929 + i.e., gcc 4.5 or newer. You may need to install the supporting
98930 + headers explicitly in addition to the normal gcc package.
98931 +
98932 +config PAX_MEMORY_UDEREF
98933 + bool "Prevent invalid userland pointer dereference"
98934 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98935 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98936 + select PAX_PER_CPU_PGD if X86_64
98937 + help
98938 + By saying Y here the kernel will be prevented from dereferencing
98939 + userland pointers in contexts where the kernel expects only kernel
98940 + pointers. This is both a useful runtime debugging feature and a
98941 + security measure that prevents exploiting a class of kernel bugs.
98942 +
98943 + The tradeoff is that some virtualization solutions may experience
98944 + a huge slowdown and therefore you should not enable this feature
98945 + for kernels meant to run in such environments. Whether a given VM
98946 + solution is affected or not is best determined by simply trying it
98947 + out, the performance impact will be obvious right on boot as this
98948 + mechanism engages from very early on. A good rule of thumb is that
98949 + VMs running on CPUs without hardware virtualization support (i.e.,
98950 + the majority of IA-32 CPUs) will likely experience the slowdown.
98951 +
98952 + On X86_64 the kernel will make use of PCID support when available
98953 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98954 + or performance impact. Pass pax_weakuderef on the kernel command
98955 + line to choose the latter.
98956 +
98957 +config PAX_REFCOUNT
98958 + bool "Prevent various kernel object reference counter overflows"
98959 + default y if GRKERNSEC_CONFIG_AUTO
98960 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98961 + help
98962 + By saying Y here the kernel will detect and prevent overflowing
98963 + various (but not all) kinds of object reference counters. Such
98964 + overflows can normally occur due to bugs only and are often, if
98965 + not always, exploitable.
98966 +
98967 + The tradeoff is that data structures protected by an overflowed
98968 + refcount will never be freed and therefore will leak memory. Note
98969 + that this leak also happens even without this protection but in
98970 + that case the overflow can eventually trigger the freeing of the
98971 + data structure while it is still being used elsewhere, resulting
98972 + in the exploitable situation that this feature prevents.
98973 +
98974 + Since this has a negligible performance impact, you should enable
98975 + this feature.
98976 +
98977 +config PAX_CONSTIFY_PLUGIN
98978 + bool "Automatically constify eligible structures"
98979 + default y
98980 + depends on !UML && PAX_KERNEXEC
98981 + help
98982 + By saying Y here the compiler will automatically constify a class
98983 + of types that contain only function pointers. This reduces the
98984 + kernel's attack surface and also produces a better memory layout.
98985 +
98986 + Note that the implementation requires a gcc with plugin support,
98987 + i.e., gcc 4.5 or newer. You may need to install the supporting
98988 + headers explicitly in addition to the normal gcc package.
98989 +
98990 + Note that if some code really has to modify constified variables
98991 + then the source code will have to be patched to allow it. Examples
98992 + can be found in PaX itself (the no_const attribute) and for some
98993 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98994 +
98995 +config PAX_USERCOPY
98996 + bool "Harden heap object copies between kernel and userland"
98997 + default y if GRKERNSEC_CONFIG_AUTO
98998 + depends on ARM || IA64 || PPC || SPARC || X86
98999 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99000 + select PAX_USERCOPY_SLABS
99001 + help
99002 + By saying Y here the kernel will enforce the size of heap objects
99003 + when they are copied in either direction between the kernel and
99004 + userland, even if only a part of the heap object is copied.
99005 +
99006 + Specifically, this checking prevents information leaking from the
99007 + kernel heap during kernel to userland copies (if the kernel heap
99008 + object is otherwise fully initialized) and prevents kernel heap
99009 + overflows during userland to kernel copies.
99010 +
99011 + Note that the current implementation provides the strictest bounds
99012 + checks for the SLUB allocator.
99013 +
99014 + Enabling this option also enables per-slab cache protection against
99015 + data in a given cache being copied into/out of via userland
99016 + accessors. Though the whitelist of regions will be reduced over
99017 + time, it notably protects important data structures like task structs.
99018 +
99019 + If frame pointers are enabled on x86, this option will also restrict
99020 + copies into and out of the kernel stack to local variables within a
99021 + single frame.
99022 +
99023 + Since this has a negligible performance impact, you should enable
99024 + this feature.
99025 +
99026 +config PAX_USERCOPY_DEBUG
99027 + bool
99028 + depends on X86 && PAX_USERCOPY
99029 + default n
99030 +
99031 +config PAX_SIZE_OVERFLOW
99032 + bool "Prevent various integer overflows in function size parameters"
99033 + default y if GRKERNSEC_CONFIG_AUTO
99034 + depends on X86
99035 + help
99036 + By saying Y here the kernel recomputes expressions of function
99037 + arguments marked by a size_overflow attribute with double integer
99038 + precision (DImode/TImode for 32/64 bit integer types).
99039 +
99040 + The recomputed argument is checked against TYPE_MAX and an event
99041 + is logged on overflow and the triggering process is killed.
99042 +
99043 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99044 +
99045 + Note that the implementation requires a gcc with plugin support,
99046 + i.e., gcc 4.5 or newer. You may need to install the supporting
99047 + headers explicitly in addition to the normal gcc package.
99048 +
99049 +config PAX_LATENT_ENTROPY
99050 + bool "Generate some entropy during boot and runtime"
99051 + default y if GRKERNSEC_CONFIG_AUTO
99052 + help
99053 + By saying Y here the kernel will instrument some kernel code to
99054 + extract some entropy from both original and artificially created
99055 + program state. This will help especially embedded systems where
99056 + there is little 'natural' source of entropy normally. The cost
99057 + is some slowdown of the boot process and fork and irq processing.
99058 +
99059 + When pax_extra_latent_entropy is passed on the kernel command line,
99060 + entropy will be extracted from up to the first 4GB of RAM while the
99061 + runtime memory allocator is being initialized. This costs even more
99062 + slowdown of the boot process.
99063 +
99064 + Note that the implementation 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.
99067 +
99068 + Note that entropy extracted this way is not cryptographically
99069 + secure!
99070 +
99071 +endmenu
99072 +
99073 +endmenu
99074 +
99075 +source grsecurity/Kconfig
99076 +
99077 +endmenu
99078 +
99079 +endmenu
99080 +
99081 source security/keys/Kconfig
99082
99083 config SECURITY_DMESG_RESTRICT
99084 @@ -103,7 +1057,7 @@ config INTEL_TXT
99085 config LSM_MMAP_MIN_ADDR
99086 int "Low address space for LSM to protect from user allocation"
99087 depends on SECURITY && SECURITY_SELINUX
99088 - default 32768 if ARM
99089 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99090 default 65536
99091 help
99092 This is the portion of low virtual memory which should be protected
99093 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
99094 index fb99e18..b3e0bbb 100644
99095 --- a/security/apparmor/lsm.c
99096 +++ b/security/apparmor/lsm.c
99097 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99098 return error;
99099 }
99100
99101 -static struct security_operations apparmor_ops = {
99102 +static struct security_operations apparmor_ops __read_only = {
99103 .name = "apparmor",
99104
99105 .ptrace_access_check = apparmor_ptrace_access_check,
99106 diff --git a/security/commoncap.c b/security/commoncap.c
99107 index b9d613e..f68305c 100644
99108 --- a/security/commoncap.c
99109 +++ b/security/commoncap.c
99110 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99111 return 0;
99112 }
99113
99114 +/* returns:
99115 + 1 for suid privilege
99116 + 2 for sgid privilege
99117 + 3 for fscap privilege
99118 +*/
99119 +int is_privileged_binary(const struct dentry *dentry)
99120 +{
99121 + struct cpu_vfs_cap_data capdata;
99122 + struct inode *inode = dentry->d_inode;
99123 +
99124 + if (!inode || S_ISDIR(inode->i_mode))
99125 + return 0;
99126 +
99127 + if (inode->i_mode & S_ISUID)
99128 + return 1;
99129 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99130 + return 2;
99131 +
99132 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99133 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99134 + return 3;
99135 + }
99136 +
99137 + return 0;
99138 +}
99139 +
99140 /*
99141 * Attempt to get the on-exec apply capability sets for an executable file from
99142 * its xattrs and, if present, apply them to the proposed credentials being
99143 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99144 const struct cred *cred = current_cred();
99145 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99146
99147 + if (gr_acl_enable_at_secure())
99148 + return 1;
99149 +
99150 if (!uid_eq(cred->uid, root_uid)) {
99151 if (bprm->cap_effective)
99152 return 1;
99153 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99154 index b3dd616..4bb17f3 100644
99155 --- a/security/integrity/ima/ima.h
99156 +++ b/security/integrity/ima/ima.h
99157 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99158 extern spinlock_t ima_queue_lock;
99159
99160 struct ima_h_table {
99161 - atomic_long_t len; /* number of stored measurements in the list */
99162 - atomic_long_t violations;
99163 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99164 + atomic_long_unchecked_t violations;
99165 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99166 };
99167 extern struct ima_h_table ima_htable;
99168 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99169 index 1c03e8f1..398a941 100644
99170 --- a/security/integrity/ima/ima_api.c
99171 +++ b/security/integrity/ima/ima_api.c
99172 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99173 int result;
99174
99175 /* can overflow, only indicator */
99176 - atomic_long_inc(&ima_htable.violations);
99177 + atomic_long_inc_unchecked(&ima_htable.violations);
99178
99179 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99180 if (!entry) {
99181 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99182 index 38477c9..87a60c7 100644
99183 --- a/security/integrity/ima/ima_fs.c
99184 +++ b/security/integrity/ima/ima_fs.c
99185 @@ -28,12 +28,12 @@
99186 static int valid_policy = 1;
99187 #define TMPBUFLEN 12
99188 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99189 - loff_t *ppos, atomic_long_t *val)
99190 + loff_t *ppos, atomic_long_unchecked_t *val)
99191 {
99192 char tmpbuf[TMPBUFLEN];
99193 ssize_t len;
99194
99195 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99196 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99197 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99198 }
99199
99200 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99201 index ff63fe0..809cd96 100644
99202 --- a/security/integrity/ima/ima_queue.c
99203 +++ b/security/integrity/ima/ima_queue.c
99204 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99205 INIT_LIST_HEAD(&qe->later);
99206 list_add_tail_rcu(&qe->later, &ima_measurements);
99207
99208 - atomic_long_inc(&ima_htable.len);
99209 + atomic_long_inc_unchecked(&ima_htable.len);
99210 key = ima_hash_key(entry->digest);
99211 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99212 return 0;
99213 diff --git a/security/keys/compat.c b/security/keys/compat.c
99214 index d65fa7f..cbfe366 100644
99215 --- a/security/keys/compat.c
99216 +++ b/security/keys/compat.c
99217 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99218 if (ret == 0)
99219 goto no_payload_free;
99220
99221 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99222 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99223 err:
99224 if (iov != iovstack)
99225 kfree(iov);
99226 diff --git a/security/keys/internal.h b/security/keys/internal.h
99227 index d4f1468..cc52f92 100644
99228 --- a/security/keys/internal.h
99229 +++ b/security/keys/internal.h
99230 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99231 extern long keyctl_invalidate_key(key_serial_t);
99232
99233 extern long keyctl_instantiate_key_common(key_serial_t,
99234 - const struct iovec *,
99235 + const struct iovec __user *,
99236 unsigned, size_t, key_serial_t);
99237
99238 /*
99239 diff --git a/security/keys/key.c b/security/keys/key.c
99240 index 8fb7c7b..ba3610d 100644
99241 --- a/security/keys/key.c
99242 +++ b/security/keys/key.c
99243 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99244
99245 atomic_set(&key->usage, 1);
99246 init_rwsem(&key->sem);
99247 - lockdep_set_class(&key->sem, &type->lock_class);
99248 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99249 key->type = type;
99250 key->user = user;
99251 key->quotalen = quotalen;
99252 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99253 struct key_type *p;
99254 int ret;
99255
99256 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99257 + pax_open_kernel();
99258 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99259 + pax_close_kernel();
99260
99261 ret = -EEXIST;
99262 down_write(&key_types_sem);
99263 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99264 }
99265
99266 /* store the type */
99267 - list_add(&ktype->link, &key_types_list);
99268 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99269
99270 pr_notice("Key type %s registered\n", ktype->name);
99271 ret = 0;
99272 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99273 void unregister_key_type(struct key_type *ktype)
99274 {
99275 down_write(&key_types_sem);
99276 - list_del_init(&ktype->link);
99277 + pax_list_del_init((struct list_head *)&ktype->link);
99278 downgrade_write(&key_types_sem);
99279 key_gc_keytype(ktype);
99280 pr_notice("Key type %s unregistered\n", ktype->name);
99281 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99282 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99283
99284 /* add the special key types */
99285 - list_add_tail(&key_type_keyring.link, &key_types_list);
99286 - list_add_tail(&key_type_dead.link, &key_types_list);
99287 - list_add_tail(&key_type_user.link, &key_types_list);
99288 - list_add_tail(&key_type_logon.link, &key_types_list);
99289 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99290 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99291 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99292 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99293
99294 /* record the root user tracking */
99295 rb_link_node(&root_key_user.node,
99296 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99297 index 33cfd27..842fc5a 100644
99298 --- a/security/keys/keyctl.c
99299 +++ b/security/keys/keyctl.c
99300 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99301 /*
99302 * Copy the iovec data from userspace
99303 */
99304 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99305 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99306 unsigned ioc)
99307 {
99308 for (; ioc > 0; ioc--) {
99309 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99310 * If successful, 0 will be returned.
99311 */
99312 long keyctl_instantiate_key_common(key_serial_t id,
99313 - const struct iovec *payload_iov,
99314 + const struct iovec __user *payload_iov,
99315 unsigned ioc,
99316 size_t plen,
99317 key_serial_t ringid)
99318 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99319 [0].iov_len = plen
99320 };
99321
99322 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99323 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99324 }
99325
99326 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99327 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99328 if (ret == 0)
99329 goto no_payload_free;
99330
99331 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99332 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99333 err:
99334 if (iov != iovstack)
99335 kfree(iov);
99336 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99337 index 6ece7f2..ecdb55c 100644
99338 --- a/security/keys/keyring.c
99339 +++ b/security/keys/keyring.c
99340 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99341 ret = -EFAULT;
99342
99343 for (loop = 0; loop < klist->nkeys; loop++) {
99344 + key_serial_t serial;
99345 key = rcu_deref_link_locked(klist, loop,
99346 keyring);
99347 + serial = key->serial;
99348
99349 tmp = sizeof(key_serial_t);
99350 if (tmp > buflen)
99351 tmp = buflen;
99352
99353 - if (copy_to_user(buffer,
99354 - &key->serial,
99355 - tmp) != 0)
99356 + if (copy_to_user(buffer, &serial, tmp))
99357 goto error;
99358
99359 buflen -= tmp;
99360 diff --git a/security/min_addr.c b/security/min_addr.c
99361 index f728728..6457a0c 100644
99362 --- a/security/min_addr.c
99363 +++ b/security/min_addr.c
99364 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99365 */
99366 static void update_mmap_min_addr(void)
99367 {
99368 +#ifndef SPARC
99369 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99370 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99371 mmap_min_addr = dac_mmap_min_addr;
99372 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99373 #else
99374 mmap_min_addr = dac_mmap_min_addr;
99375 #endif
99376 +#endif
99377 }
99378
99379 /*
99380 diff --git a/security/security.c b/security/security.c
99381 index 4dc31f4..eabcf41 100644
99382 --- a/security/security.c
99383 +++ b/security/security.c
99384 @@ -33,8 +33,8 @@
99385 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99386 CONFIG_DEFAULT_SECURITY;
99387
99388 -static struct security_operations *security_ops;
99389 -static struct security_operations default_security_ops = {
99390 +struct security_operations *security_ops __read_only;
99391 +struct security_operations default_security_ops __read_only = {
99392 .name = "default",
99393 };
99394
99395 @@ -73,11 +73,6 @@ int __init security_init(void)
99396 return 0;
99397 }
99398
99399 -void reset_security_ops(void)
99400 -{
99401 - security_ops = &default_security_ops;
99402 -}
99403 -
99404 /* Save user chosen LSM */
99405 static int __init choose_lsm(char *str)
99406 {
99407 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99408 index fc3e662..7844c60 100644
99409 --- a/security/selinux/avc.c
99410 +++ b/security/selinux/avc.c
99411 @@ -59,7 +59,7 @@ struct avc_node {
99412 struct avc_cache {
99413 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99414 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99415 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99416 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99417 atomic_t active_nodes;
99418 u32 latest_notif; /* latest revocation notification */
99419 };
99420 @@ -167,7 +167,7 @@ void __init avc_init(void)
99421 spin_lock_init(&avc_cache.slots_lock[i]);
99422 }
99423 atomic_set(&avc_cache.active_nodes, 0);
99424 - atomic_set(&avc_cache.lru_hint, 0);
99425 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99426
99427 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99428 0, SLAB_PANIC, NULL);
99429 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99430 spinlock_t *lock;
99431
99432 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99433 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99434 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99435 head = &avc_cache.slots[hvalue];
99436 lock = &avc_cache.slots_lock[hvalue];
99437
99438 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99439 index 5b52310..da3bf8e 100644
99440 --- a/security/selinux/hooks.c
99441 +++ b/security/selinux/hooks.c
99442 @@ -5603,7 +5603,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99443
99444 #endif
99445
99446 -static struct security_operations selinux_ops = {
99447 +static struct security_operations selinux_ops __read_only = {
99448 .name = "selinux",
99449
99450 .ptrace_access_check = selinux_ptrace_access_check,
99451 @@ -5955,6 +5955,9 @@ static void selinux_nf_ip_exit(void)
99452 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99453 static int selinux_disabled;
99454
99455 +extern struct security_operations *security_ops;
99456 +extern struct security_operations default_security_ops;
99457 +
99458 int selinux_disable(void)
99459 {
99460 if (ss_initialized) {
99461 @@ -5972,7 +5975,9 @@ int selinux_disable(void)
99462 selinux_disabled = 1;
99463 selinux_enabled = 0;
99464
99465 - reset_security_ops();
99466 + pax_open_kernel();
99467 + security_ops = &default_security_ops;
99468 + pax_close_kernel();
99469
99470 /* Try to destroy the avc node cache */
99471 avc_disable();
99472 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99473 index 6713f04..c57ecef 100644
99474 --- a/security/selinux/include/xfrm.h
99475 +++ b/security/selinux/include/xfrm.h
99476 @@ -52,7 +52,7 @@ static inline void selinux_xfrm_notify_policyload(void)
99477 {
99478 struct net *net;
99479
99480 - atomic_inc(&flow_cache_genid);
99481 + atomic_inc_unchecked(&flow_cache_genid);
99482 rtnl_lock();
99483 for_each_net(net)
99484 rt_genid_bump_all(net);
99485 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99486 index 8825375..97a623b 100644
99487 --- a/security/smack/smack_lsm.c
99488 +++ b/security/smack/smack_lsm.c
99489 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99490 return 0;
99491 }
99492
99493 -struct security_operations smack_ops = {
99494 +struct security_operations smack_ops __read_only = {
99495 .name = "smack",
99496
99497 .ptrace_access_check = smack_ptrace_access_check,
99498 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99499 index 390c646..f2f8db3 100644
99500 --- a/security/tomoyo/mount.c
99501 +++ b/security/tomoyo/mount.c
99502 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99503 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99504 need_dev = -1; /* dev_name is a directory */
99505 } else {
99506 + if (!capable(CAP_SYS_ADMIN)) {
99507 + error = -EPERM;
99508 + goto out;
99509 + }
99510 fstype = get_fs_type(type);
99511 if (!fstype) {
99512 error = -ENODEV;
99513 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99514 index f0b756e..b129202 100644
99515 --- a/security/tomoyo/tomoyo.c
99516 +++ b/security/tomoyo/tomoyo.c
99517 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99518 * tomoyo_security_ops is a "struct security_operations" which is used for
99519 * registering TOMOYO.
99520 */
99521 -static struct security_operations tomoyo_security_ops = {
99522 +static struct security_operations tomoyo_security_ops __read_only = {
99523 .name = "tomoyo",
99524 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99525 .cred_prepare = tomoyo_cred_prepare,
99526 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99527 index 20ef514..4182bed 100644
99528 --- a/security/yama/Kconfig
99529 +++ b/security/yama/Kconfig
99530 @@ -1,6 +1,6 @@
99531 config SECURITY_YAMA
99532 bool "Yama support"
99533 - depends on SECURITY
99534 + depends on SECURITY && !GRKERNSEC
99535 select SECURITYFS
99536 select SECURITY_PATH
99537 default n
99538 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99539 index 13c88fbc..f8c115e 100644
99540 --- a/security/yama/yama_lsm.c
99541 +++ b/security/yama/yama_lsm.c
99542 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99543 }
99544
99545 #ifndef CONFIG_SECURITY_YAMA_STACKED
99546 -static struct security_operations yama_ops = {
99547 +static struct security_operations yama_ops __read_only = {
99548 .name = "yama",
99549
99550 .ptrace_access_check = yama_ptrace_access_check,
99551 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99552 #endif
99553
99554 #ifdef CONFIG_SYSCTL
99555 +static int zero __read_only;
99556 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99557 +
99558 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99559 void __user *buffer, size_t *lenp, loff_t *ppos)
99560 {
99561 - int rc;
99562 + ctl_table_no_const yama_table;
99563
99564 if (write && !capable(CAP_SYS_PTRACE))
99565 return -EPERM;
99566
99567 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99568 - if (rc)
99569 - return rc;
99570 -
99571 + yama_table = *table;
99572 /* Lock the max value if it ever gets set. */
99573 - if (write && *(int *)table->data == *(int *)table->extra2)
99574 - table->extra1 = table->extra2;
99575 -
99576 - return rc;
99577 + if (ptrace_scope == max_scope)
99578 + yama_table.extra1 = &max_scope;
99579 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99580 }
99581
99582 -static int zero;
99583 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99584 -
99585 struct ctl_path yama_sysctl_path[] = {
99586 { .procname = "kernel", },
99587 { .procname = "yama", },
99588 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99589 index 4cedc69..e59d8a3 100644
99590 --- a/sound/aoa/codecs/onyx.c
99591 +++ b/sound/aoa/codecs/onyx.c
99592 @@ -54,7 +54,7 @@ struct onyx {
99593 spdif_locked:1,
99594 analog_locked:1,
99595 original_mute:2;
99596 - int open_count;
99597 + local_t open_count;
99598 struct codec_info *codec_info;
99599
99600 /* mutex serializes concurrent access to the device
99601 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99602 struct onyx *onyx = cii->codec_data;
99603
99604 mutex_lock(&onyx->mutex);
99605 - onyx->open_count++;
99606 + local_inc(&onyx->open_count);
99607 mutex_unlock(&onyx->mutex);
99608
99609 return 0;
99610 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99611 struct onyx *onyx = cii->codec_data;
99612
99613 mutex_lock(&onyx->mutex);
99614 - onyx->open_count--;
99615 - if (!onyx->open_count)
99616 + if (local_dec_and_test(&onyx->open_count))
99617 onyx->spdif_locked = onyx->analog_locked = 0;
99618 mutex_unlock(&onyx->mutex);
99619
99620 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99621 index ffd2025..df062c9 100644
99622 --- a/sound/aoa/codecs/onyx.h
99623 +++ b/sound/aoa/codecs/onyx.h
99624 @@ -11,6 +11,7 @@
99625 #include <linux/i2c.h>
99626 #include <asm/pmac_low_i2c.h>
99627 #include <asm/prom.h>
99628 +#include <asm/local.h>
99629
99630 /* PCM3052 register definitions */
99631
99632 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99633 index 4c1cc51..16040040 100644
99634 --- a/sound/core/oss/pcm_oss.c
99635 +++ b/sound/core/oss/pcm_oss.c
99636 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99637 if (in_kernel) {
99638 mm_segment_t fs;
99639 fs = snd_enter_user();
99640 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99641 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99642 snd_leave_user(fs);
99643 } else {
99644 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99645 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99646 }
99647 if (ret != -EPIPE && ret != -ESTRPIPE)
99648 break;
99649 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99650 if (in_kernel) {
99651 mm_segment_t fs;
99652 fs = snd_enter_user();
99653 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99654 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99655 snd_leave_user(fs);
99656 } else {
99657 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99658 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99659 }
99660 if (ret == -EPIPE) {
99661 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99662 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99663 struct snd_pcm_plugin_channel *channels;
99664 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99665 if (!in_kernel) {
99666 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99667 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99668 return -EFAULT;
99669 buf = runtime->oss.buffer;
99670 }
99671 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99672 }
99673 } else {
99674 tmp = snd_pcm_oss_write2(substream,
99675 - (const char __force *)buf,
99676 + (const char __force_kernel *)buf,
99677 runtime->oss.period_bytes, 0);
99678 if (tmp <= 0)
99679 goto err;
99680 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99681 struct snd_pcm_runtime *runtime = substream->runtime;
99682 snd_pcm_sframes_t frames, frames1;
99683 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99684 - char __user *final_dst = (char __force __user *)buf;
99685 + char __user *final_dst = (char __force_user *)buf;
99686 if (runtime->oss.plugin_first) {
99687 struct snd_pcm_plugin_channel *channels;
99688 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99689 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99690 xfer += tmp;
99691 runtime->oss.buffer_used -= tmp;
99692 } else {
99693 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99694 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99695 runtime->oss.period_bytes, 0);
99696 if (tmp <= 0)
99697 goto err;
99698 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99699 size1);
99700 size1 /= runtime->channels; /* frames */
99701 fs = snd_enter_user();
99702 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99703 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99704 snd_leave_user(fs);
99705 }
99706 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99707 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99708 index af49721..e85058e 100644
99709 --- a/sound/core/pcm_compat.c
99710 +++ b/sound/core/pcm_compat.c
99711 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99712 int err;
99713
99714 fs = snd_enter_user();
99715 - err = snd_pcm_delay(substream, &delay);
99716 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99717 snd_leave_user(fs);
99718 if (err < 0)
99719 return err;
99720 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99721 index a68d4c6..72af3cf 100644
99722 --- a/sound/core/pcm_native.c
99723 +++ b/sound/core/pcm_native.c
99724 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99725 switch (substream->stream) {
99726 case SNDRV_PCM_STREAM_PLAYBACK:
99727 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99728 - (void __user *)arg);
99729 + (void __force_user *)arg);
99730 break;
99731 case SNDRV_PCM_STREAM_CAPTURE:
99732 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99733 - (void __user *)arg);
99734 + (void __force_user *)arg);
99735 break;
99736 default:
99737 result = -EINVAL;
99738 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99739 index 040c60e..989a19a 100644
99740 --- a/sound/core/seq/seq_device.c
99741 +++ b/sound/core/seq/seq_device.c
99742 @@ -64,7 +64,7 @@ struct ops_list {
99743 int argsize; /* argument size */
99744
99745 /* operators */
99746 - struct snd_seq_dev_ops ops;
99747 + struct snd_seq_dev_ops *ops;
99748
99749 /* registered devices */
99750 struct list_head dev_list; /* list of devices */
99751 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99752
99753 mutex_lock(&ops->reg_mutex);
99754 /* copy driver operators */
99755 - ops->ops = *entry;
99756 + ops->ops = entry;
99757 ops->driver |= DRIVER_LOADED;
99758 ops->argsize = argsize;
99759
99760 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99761 dev->name, ops->id, ops->argsize, dev->argsize);
99762 return -EINVAL;
99763 }
99764 - if (ops->ops.init_device(dev) >= 0) {
99765 + if (ops->ops->init_device(dev) >= 0) {
99766 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99767 ops->num_init_devices++;
99768 } else {
99769 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99770 dev->name, ops->id, ops->argsize, dev->argsize);
99771 return -EINVAL;
99772 }
99773 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99774 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99775 dev->status = SNDRV_SEQ_DEVICE_FREE;
99776 dev->driver_data = NULL;
99777 ops->num_init_devices--;
99778 diff --git a/sound/core/sound.c b/sound/core/sound.c
99779 index f002bd9..c462985 100644
99780 --- a/sound/core/sound.c
99781 +++ b/sound/core/sound.c
99782 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99783 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99784 default: return;
99785 }
99786 - request_module(str);
99787 + request_module("%s", str);
99788 }
99789
99790 #endif /* modular kernel */
99791 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99792 index 4e0dd22..7a1f32c 100644
99793 --- a/sound/drivers/mts64.c
99794 +++ b/sound/drivers/mts64.c
99795 @@ -29,6 +29,7 @@
99796 #include <sound/initval.h>
99797 #include <sound/rawmidi.h>
99798 #include <sound/control.h>
99799 +#include <asm/local.h>
99800
99801 #define CARD_NAME "Miditerminal 4140"
99802 #define DRIVER_NAME "MTS64"
99803 @@ -67,7 +68,7 @@ struct mts64 {
99804 struct pardevice *pardev;
99805 int pardev_claimed;
99806
99807 - int open_count;
99808 + local_t open_count;
99809 int current_midi_output_port;
99810 int current_midi_input_port;
99811 u8 mode[MTS64_NUM_INPUT_PORTS];
99812 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99813 {
99814 struct mts64 *mts = substream->rmidi->private_data;
99815
99816 - if (mts->open_count == 0) {
99817 + if (local_read(&mts->open_count) == 0) {
99818 /* We don't need a spinlock here, because this is just called
99819 if the device has not been opened before.
99820 So there aren't any IRQs from the device */
99821 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99822
99823 msleep(50);
99824 }
99825 - ++(mts->open_count);
99826 + local_inc(&mts->open_count);
99827
99828 return 0;
99829 }
99830 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99831 struct mts64 *mts = substream->rmidi->private_data;
99832 unsigned long flags;
99833
99834 - --(mts->open_count);
99835 - if (mts->open_count == 0) {
99836 + if (local_dec_return(&mts->open_count) == 0) {
99837 /* We need the spinlock_irqsave here because we can still
99838 have IRQs at this point */
99839 spin_lock_irqsave(&mts->lock, flags);
99840 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99841
99842 msleep(500);
99843
99844 - } else if (mts->open_count < 0)
99845 - mts->open_count = 0;
99846 + } else if (local_read(&mts->open_count) < 0)
99847 + local_set(&mts->open_count, 0);
99848
99849 return 0;
99850 }
99851 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99852 index b953fb4..1999c01 100644
99853 --- a/sound/drivers/opl4/opl4_lib.c
99854 +++ b/sound/drivers/opl4/opl4_lib.c
99855 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99856 MODULE_DESCRIPTION("OPL4 driver");
99857 MODULE_LICENSE("GPL");
99858
99859 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99860 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99861 {
99862 int timeout = 10;
99863 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99864 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99865 index 991018d..8984740 100644
99866 --- a/sound/drivers/portman2x4.c
99867 +++ b/sound/drivers/portman2x4.c
99868 @@ -48,6 +48,7 @@
99869 #include <sound/initval.h>
99870 #include <sound/rawmidi.h>
99871 #include <sound/control.h>
99872 +#include <asm/local.h>
99873
99874 #define CARD_NAME "Portman 2x4"
99875 #define DRIVER_NAME "portman"
99876 @@ -85,7 +86,7 @@ struct portman {
99877 struct pardevice *pardev;
99878 int pardev_claimed;
99879
99880 - int open_count;
99881 + local_t open_count;
99882 int mode[PORTMAN_NUM_INPUT_PORTS];
99883 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99884 };
99885 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99886 index ea995af..f1bfa37 100644
99887 --- a/sound/firewire/amdtp.c
99888 +++ b/sound/firewire/amdtp.c
99889 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99890 ptr = s->pcm_buffer_pointer + data_blocks;
99891 if (ptr >= pcm->runtime->buffer_size)
99892 ptr -= pcm->runtime->buffer_size;
99893 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99894 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99895
99896 s->pcm_period_pointer += data_blocks;
99897 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99898 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99899 */
99900 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99901 {
99902 - ACCESS_ONCE(s->source_node_id_field) =
99903 + ACCESS_ONCE_RW(s->source_node_id_field) =
99904 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99905 }
99906 EXPORT_SYMBOL(amdtp_out_stream_update);
99907 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99908 index f6103d6..4843fbf 100644
99909 --- a/sound/firewire/amdtp.h
99910 +++ b/sound/firewire/amdtp.h
99911 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99912 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99913 struct snd_pcm_substream *pcm)
99914 {
99915 - ACCESS_ONCE(s->pcm) = pcm;
99916 + ACCESS_ONCE_RW(s->pcm) = pcm;
99917 }
99918
99919 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99920 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99921 index 58a5afe..af5bd64 100644
99922 --- a/sound/firewire/isight.c
99923 +++ b/sound/firewire/isight.c
99924 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99925 ptr += count;
99926 if (ptr >= runtime->buffer_size)
99927 ptr -= runtime->buffer_size;
99928 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99929 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99930
99931 isight->period_counter += count;
99932 if (isight->period_counter >= runtime->period_size) {
99933 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99934 if (err < 0)
99935 return err;
99936
99937 - ACCESS_ONCE(isight->pcm_active) = true;
99938 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99939
99940 return 0;
99941 }
99942 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99943 {
99944 struct isight *isight = substream->private_data;
99945
99946 - ACCESS_ONCE(isight->pcm_active) = false;
99947 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99948
99949 mutex_lock(&isight->mutex);
99950 isight_stop_streaming(isight);
99951 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99952
99953 switch (cmd) {
99954 case SNDRV_PCM_TRIGGER_START:
99955 - ACCESS_ONCE(isight->pcm_running) = true;
99956 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99957 break;
99958 case SNDRV_PCM_TRIGGER_STOP:
99959 - ACCESS_ONCE(isight->pcm_running) = false;
99960 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99961 break;
99962 default:
99963 return -EINVAL;
99964 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99965 index 505fc81..62e569e 100644
99966 --- a/sound/firewire/scs1x.c
99967 +++ b/sound/firewire/scs1x.c
99968 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99969 {
99970 struct scs *scs = stream->rmidi->private_data;
99971
99972 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99973 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99974 if (up) {
99975 scs->output_idle = false;
99976 tasklet_schedule(&scs->tasklet);
99977 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99978 {
99979 struct scs *scs = stream->rmidi->private_data;
99980
99981 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99982 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99983 }
99984
99985 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99986 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99987
99988 snd_card_disconnect(scs->card);
99989
99990 - ACCESS_ONCE(scs->output) = NULL;
99991 - ACCESS_ONCE(scs->input) = NULL;
99992 + ACCESS_ONCE_RW(scs->output) = NULL;
99993 + ACCESS_ONCE_RW(scs->input) = NULL;
99994
99995 wait_event(scs->idle_wait, scs->output_idle);
99996
99997 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99998 index 048439a..3be9f6f 100644
99999 --- a/sound/oss/sb_audio.c
100000 +++ b/sound/oss/sb_audio.c
100001 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100002 buf16 = (signed short *)(localbuf + localoffs);
100003 while (c)
100004 {
100005 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100006 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100007 if (copy_from_user(lbuf8,
100008 userbuf+useroffs + p,
100009 locallen))
100010 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100011 index 7d8803a..559f8d0 100644
100012 --- a/sound/oss/swarm_cs4297a.c
100013 +++ b/sound/oss/swarm_cs4297a.c
100014 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100015 {
100016 struct cs4297a_state *s;
100017 u32 pwr, id;
100018 - mm_segment_t fs;
100019 int rval;
100020 #ifndef CONFIG_BCM_CS4297A_CSWARM
100021 u64 cfg;
100022 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100023 if (!rval) {
100024 char *sb1250_duart_present;
100025
100026 +#if 0
100027 + mm_segment_t fs;
100028 fs = get_fs();
100029 set_fs(KERNEL_DS);
100030 -#if 0
100031 val = SOUND_MASK_LINE;
100032 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100033 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100034 val = initvol[i].vol;
100035 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100036 }
100037 + set_fs(fs);
100038 // cs4297a_write_ac97(s, 0x18, 0x0808);
100039 #else
100040 // cs4297a_write_ac97(s, 0x5e, 0x180);
100041 cs4297a_write_ac97(s, 0x02, 0x0808);
100042 cs4297a_write_ac97(s, 0x18, 0x0808);
100043 #endif
100044 - set_fs(fs);
100045
100046 list_add(&s->list, &cs4297a_devs);
100047
100048 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100049 index e938a68..2a728ad 100644
100050 --- a/sound/pci/hda/hda_codec.c
100051 +++ b/sound/pci/hda/hda_codec.c
100052 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
100053 mutex_unlock(&preset_mutex);
100054
100055 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100056 - char name[32];
100057 if (!mod_requested)
100058 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
100059 - codec->vendor_id);
100060 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
100061 else
100062 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
100063 - (codec->vendor_id >> 16) & 0xffff);
100064 - request_module(name);
100065 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
100066 mod_requested++;
100067 goto again;
100068 }
100069 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
100070 index 4631a23..001ae57 100644
100071 --- a/sound/pci/ymfpci/ymfpci.h
100072 +++ b/sound/pci/ymfpci/ymfpci.h
100073 @@ -358,7 +358,7 @@ struct snd_ymfpci {
100074 spinlock_t reg_lock;
100075 spinlock_t voice_lock;
100076 wait_queue_head_t interrupt_sleep;
100077 - atomic_t interrupt_sleep_count;
100078 + atomic_unchecked_t interrupt_sleep_count;
100079 struct snd_info_entry *proc_entry;
100080 const struct firmware *dsp_microcode;
100081 const struct firmware *controller_microcode;
100082 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
100083 index d591c15..8cb8f94 100644
100084 --- a/sound/pci/ymfpci/ymfpci_main.c
100085 +++ b/sound/pci/ymfpci/ymfpci_main.c
100086 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100087 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100088 break;
100089 }
100090 - if (atomic_read(&chip->interrupt_sleep_count)) {
100091 - atomic_set(&chip->interrupt_sleep_count, 0);
100092 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100093 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100094 wake_up(&chip->interrupt_sleep);
100095 }
100096 __end:
100097 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100098 continue;
100099 init_waitqueue_entry(&wait, current);
100100 add_wait_queue(&chip->interrupt_sleep, &wait);
100101 - atomic_inc(&chip->interrupt_sleep_count);
100102 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100103 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100104 remove_wait_queue(&chip->interrupt_sleep, &wait);
100105 }
100106 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100107 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100108 spin_unlock(&chip->reg_lock);
100109
100110 - if (atomic_read(&chip->interrupt_sleep_count)) {
100111 - atomic_set(&chip->interrupt_sleep_count, 0);
100112 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100113 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100114 wake_up(&chip->interrupt_sleep);
100115 }
100116 }
100117 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100118 spin_lock_init(&chip->reg_lock);
100119 spin_lock_init(&chip->voice_lock);
100120 init_waitqueue_head(&chip->interrupt_sleep);
100121 - atomic_set(&chip->interrupt_sleep_count, 0);
100122 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100123 chip->card = card;
100124 chip->pci = pci;
100125 chip->irq = -1;
100126 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100127 index 6b81d0c..031c056 100644
100128 --- a/sound/soc/fsl/fsl_ssi.c
100129 +++ b/sound/soc/fsl/fsl_ssi.c
100130 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100131 {
100132 struct fsl_ssi_private *ssi_private;
100133 int ret = 0;
100134 - struct device_attribute *dev_attr = NULL;
100135 + device_attribute_no_const *dev_attr = NULL;
100136 struct device_node *np = pdev->dev.of_node;
100137 const char *p, *sprop;
100138 const uint32_t *iprop;
100139 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
100140 index 1a38be0..66809d1 100644
100141 --- a/sound/soc/soc-core.c
100142 +++ b/sound/soc/soc-core.c
100143 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
100144 if (ret)
100145 return ret;
100146
100147 - ops->warm_reset = snd_soc_ac97_warm_reset;
100148 - ops->reset = snd_soc_ac97_reset;
100149 + pax_open_kernel();
100150 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
100151 + *(void **)&ops->reset = snd_soc_ac97_reset;
100152 + pax_close_kernel();
100153
100154 snd_ac97_rst_cfg = cfg;
100155 return 0;
100156 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100157 new file mode 100644
100158 index 0000000..50f2f2f
100159 --- /dev/null
100160 +++ b/tools/gcc/.gitignore
100161 @@ -0,0 +1 @@
100162 +size_overflow_hash.h
100163 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100164 new file mode 100644
100165 index 0000000..144dbee
100166 --- /dev/null
100167 +++ b/tools/gcc/Makefile
100168 @@ -0,0 +1,45 @@
100169 +#CC := gcc
100170 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100171 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100172 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100173 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100174 +
100175 +ifeq ($(PLUGINCC),$(HOSTCC))
100176 +HOSTLIBS := hostlibs
100177 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100178 +else
100179 +HOSTLIBS := hostcxxlibs
100180 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100181 +endif
100182 +
100183 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100184 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100185 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100186 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100187 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100188 +$(HOSTLIBS)-y += colorize_plugin.so
100189 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100190 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100191 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100192 +
100193 +always := $($(HOSTLIBS)-y)
100194 +
100195 +constify_plugin-objs := constify_plugin.o
100196 +stackleak_plugin-objs := stackleak_plugin.o
100197 +kallocstat_plugin-objs := kallocstat_plugin.o
100198 +kernexec_plugin-objs := kernexec_plugin.o
100199 +checker_plugin-objs := checker_plugin.o
100200 +colorize_plugin-objs := colorize_plugin.o
100201 +size_overflow_plugin-objs := size_overflow_plugin.o
100202 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100203 +structleak_plugin-objs := structleak_plugin.o
100204 +
100205 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100206 +
100207 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100208 + cmd_build_size_overflow_hash = \
100209 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100210 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100211 + $(call if_changed,build_size_overflow_hash)
100212 +
100213 +targets += size_overflow_hash.h
100214 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100215 new file mode 100644
100216 index 0000000..22f03c0
100217 --- /dev/null
100218 +++ b/tools/gcc/checker_plugin.c
100219 @@ -0,0 +1,172 @@
100220 +/*
100221 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100222 + * Licensed under the GPL v2
100223 + *
100224 + * Note: the choice of the license means that the compilation process is
100225 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100226 + * but for the kernel it doesn't matter since it doesn't link against
100227 + * any of the gcc libraries
100228 + *
100229 + * gcc plugin to implement various sparse (source code checker) features
100230 + *
100231 + * TODO:
100232 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100233 + *
100234 + * BUGS:
100235 + * - none known
100236 + */
100237 +#include "gcc-plugin.h"
100238 +#include "config.h"
100239 +#include "system.h"
100240 +#include "coretypes.h"
100241 +#include "tree.h"
100242 +#include "tree-pass.h"
100243 +#include "flags.h"
100244 +#include "intl.h"
100245 +#include "toplev.h"
100246 +#include "plugin.h"
100247 +//#include "expr.h" where are you...
100248 +#include "diagnostic.h"
100249 +#include "plugin-version.h"
100250 +#include "tm.h"
100251 +#include "function.h"
100252 +#include "basic-block.h"
100253 +#include "gimple.h"
100254 +#include "rtl.h"
100255 +#include "emit-rtl.h"
100256 +#include "tree-flow.h"
100257 +#include "target.h"
100258 +
100259 +extern void c_register_addr_space (const char *str, addr_space_t as);
100260 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100261 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100262 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100263 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100264 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100265 +
100266 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100267 +extern rtx emit_move_insn(rtx x, rtx y);
100268 +
100269 +int plugin_is_GPL_compatible;
100270 +
100271 +static struct plugin_info checker_plugin_info = {
100272 + .version = "201111150100",
100273 + .help = NULL,
100274 +};
100275 +
100276 +#define ADDR_SPACE_KERNEL 0
100277 +#define ADDR_SPACE_FORCE_KERNEL 1
100278 +#define ADDR_SPACE_USER 2
100279 +#define ADDR_SPACE_FORCE_USER 3
100280 +#define ADDR_SPACE_IOMEM 0
100281 +#define ADDR_SPACE_FORCE_IOMEM 0
100282 +#define ADDR_SPACE_PERCPU 0
100283 +#define ADDR_SPACE_FORCE_PERCPU 0
100284 +#define ADDR_SPACE_RCU 0
100285 +#define ADDR_SPACE_FORCE_RCU 0
100286 +
100287 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100288 +{
100289 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100290 +}
100291 +
100292 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100293 +{
100294 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100295 +}
100296 +
100297 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100298 +{
100299 + return default_addr_space_valid_pointer_mode(mode, as);
100300 +}
100301 +
100302 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100303 +{
100304 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100305 +}
100306 +
100307 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100308 +{
100309 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100310 +}
100311 +
100312 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100313 +{
100314 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100315 + return true;
100316 +
100317 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100318 + return true;
100319 +
100320 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100321 + return true;
100322 +
100323 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100324 + return true;
100325 +
100326 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100327 + return true;
100328 +
100329 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100330 + return true;
100331 +
100332 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100333 + return true;
100334 +
100335 + return subset == superset;
100336 +}
100337 +
100338 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100339 +{
100340 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100341 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100342 +
100343 + return op;
100344 +}
100345 +
100346 +static void register_checker_address_spaces(void *event_data, void *data)
100347 +{
100348 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100349 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100350 + c_register_addr_space("__user", ADDR_SPACE_USER);
100351 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100352 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100353 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100354 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100355 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100356 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100357 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100358 +
100359 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100360 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100361 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100362 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100363 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100364 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100365 + targetm.addr_space.convert = checker_addr_space_convert;
100366 +}
100367 +
100368 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100369 +{
100370 + const char * const plugin_name = plugin_info->base_name;
100371 + const int argc = plugin_info->argc;
100372 + const struct plugin_argument * const argv = plugin_info->argv;
100373 + int i;
100374 +
100375 + if (!plugin_default_version_check(version, &gcc_version)) {
100376 + error(G_("incompatible gcc/plugin versions"));
100377 + return 1;
100378 + }
100379 +
100380 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100381 +
100382 + for (i = 0; i < argc; ++i)
100383 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100384 +
100385 + if (TARGET_64BIT == 0)
100386 + return 0;
100387 +
100388 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100389 +
100390 + return 0;
100391 +}
100392 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100393 new file mode 100644
100394 index 0000000..414fe5e
100395 --- /dev/null
100396 +++ b/tools/gcc/colorize_plugin.c
100397 @@ -0,0 +1,151 @@
100398 +/*
100399 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100400 + * Licensed under the GPL v2
100401 + *
100402 + * Note: the choice of the license means that the compilation process is
100403 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100404 + * but for the kernel it doesn't matter since it doesn't link against
100405 + * any of the gcc libraries
100406 + *
100407 + * gcc plugin to colorize diagnostic output
100408 + *
100409 + */
100410 +
100411 +#include "gcc-plugin.h"
100412 +#include "config.h"
100413 +#include "system.h"
100414 +#include "coretypes.h"
100415 +#include "tree.h"
100416 +#include "tree-pass.h"
100417 +#include "flags.h"
100418 +#include "intl.h"
100419 +#include "toplev.h"
100420 +#include "plugin.h"
100421 +#include "diagnostic.h"
100422 +#include "plugin-version.h"
100423 +#include "tm.h"
100424 +
100425 +int plugin_is_GPL_compatible;
100426 +
100427 +static struct plugin_info colorize_plugin_info = {
100428 + .version = "201302112000",
100429 + .help = NULL,
100430 +};
100431 +
100432 +#define GREEN "\033[32m\033[2m"
100433 +#define LIGHTGREEN "\033[32m\033[1m"
100434 +#define YELLOW "\033[33m\033[2m"
100435 +#define LIGHTYELLOW "\033[33m\033[1m"
100436 +#define RED "\033[31m\033[2m"
100437 +#define LIGHTRED "\033[31m\033[1m"
100438 +#define BLUE "\033[34m\033[2m"
100439 +#define LIGHTBLUE "\033[34m\033[1m"
100440 +#define BRIGHT "\033[m\033[1m"
100441 +#define NORMAL "\033[m"
100442 +
100443 +static diagnostic_starter_fn old_starter;
100444 +static diagnostic_finalizer_fn old_finalizer;
100445 +
100446 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100447 +{
100448 + const char *color;
100449 + char *newprefix;
100450 +
100451 + switch (diagnostic->kind) {
100452 + case DK_NOTE:
100453 + color = LIGHTBLUE;
100454 + break;
100455 +
100456 + case DK_PEDWARN:
100457 + case DK_WARNING:
100458 + color = LIGHTYELLOW;
100459 + break;
100460 +
100461 + case DK_ERROR:
100462 + case DK_FATAL:
100463 + case DK_ICE:
100464 + case DK_PERMERROR:
100465 + case DK_SORRY:
100466 + color = LIGHTRED;
100467 + break;
100468 +
100469 + default:
100470 + color = NORMAL;
100471 + }
100472 +
100473 + old_starter(context, diagnostic);
100474 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100475 + return;
100476 + pp_destroy_prefix(context->printer);
100477 + pp_set_prefix(context->printer, newprefix);
100478 +}
100479 +
100480 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100481 +{
100482 + old_finalizer(context, diagnostic);
100483 +}
100484 +
100485 +static void colorize_arm(void)
100486 +{
100487 + old_starter = diagnostic_starter(global_dc);
100488 + old_finalizer = diagnostic_finalizer(global_dc);
100489 +
100490 + diagnostic_starter(global_dc) = start_colorize;
100491 + diagnostic_finalizer(global_dc) = finalize_colorize;
100492 +}
100493 +
100494 +static unsigned int execute_colorize_rearm(void)
100495 +{
100496 + if (diagnostic_starter(global_dc) == start_colorize)
100497 + return 0;
100498 +
100499 + colorize_arm();
100500 + return 0;
100501 +}
100502 +
100503 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100504 + .pass = {
100505 + .type = SIMPLE_IPA_PASS,
100506 + .name = "colorize_rearm",
100507 +#if BUILDING_GCC_VERSION >= 4008
100508 + .optinfo_flags = OPTGROUP_NONE,
100509 +#endif
100510 + .gate = NULL,
100511 + .execute = execute_colorize_rearm,
100512 + .sub = NULL,
100513 + .next = NULL,
100514 + .static_pass_number = 0,
100515 + .tv_id = TV_NONE,
100516 + .properties_required = 0,
100517 + .properties_provided = 0,
100518 + .properties_destroyed = 0,
100519 + .todo_flags_start = 0,
100520 + .todo_flags_finish = 0
100521 + }
100522 +};
100523 +
100524 +static void colorize_start_unit(void *gcc_data, void *user_data)
100525 +{
100526 + colorize_arm();
100527 +}
100528 +
100529 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100530 +{
100531 + const char * const plugin_name = plugin_info->base_name;
100532 + struct register_pass_info colorize_rearm_pass_info = {
100533 + .pass = &pass_ipa_colorize_rearm.pass,
100534 + .reference_pass_name = "*free_lang_data",
100535 + .ref_pass_instance_number = 1,
100536 + .pos_op = PASS_POS_INSERT_AFTER
100537 + };
100538 +
100539 + if (!plugin_default_version_check(version, &gcc_version)) {
100540 + error(G_("incompatible gcc/plugin versions"));
100541 + return 1;
100542 + }
100543 +
100544 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100545 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100546 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100547 + return 0;
100548 +}
100549 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100550 new file mode 100644
100551 index 0000000..c17312d
100552 --- /dev/null
100553 +++ b/tools/gcc/constify_plugin.c
100554 @@ -0,0 +1,560 @@
100555 +/*
100556 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100557 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100558 + * Licensed under the GPL v2, or (at your option) v3
100559 + *
100560 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100561 + *
100562 + * Homepage:
100563 + * http://www.grsecurity.net/~ephox/const_plugin/
100564 + *
100565 + * Usage:
100566 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100567 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100568 + */
100569 +
100570 +#include "gcc-plugin.h"
100571 +#include "config.h"
100572 +#include "system.h"
100573 +#include "coretypes.h"
100574 +#include "tree.h"
100575 +#include "tree-pass.h"
100576 +#include "flags.h"
100577 +#include "intl.h"
100578 +#include "toplev.h"
100579 +#include "plugin.h"
100580 +#include "diagnostic.h"
100581 +#include "plugin-version.h"
100582 +#include "tm.h"
100583 +#include "function.h"
100584 +#include "basic-block.h"
100585 +#include "gimple.h"
100586 +#include "rtl.h"
100587 +#include "emit-rtl.h"
100588 +#include "tree-flow.h"
100589 +#include "target.h"
100590 +#include "langhooks.h"
100591 +
100592 +// should come from c-tree.h if only it were installed for gcc 4.5...
100593 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100594 +
100595 +// unused type flag in all versions 4.5-4.8
100596 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100597 +
100598 +int plugin_is_GPL_compatible;
100599 +
100600 +static struct plugin_info const_plugin_info = {
100601 + .version = "201305231310",
100602 + .help = "no-constify\tturn off constification\n",
100603 +};
100604 +
100605 +typedef struct {
100606 + bool has_fptr_field;
100607 + bool has_writable_field;
100608 + bool has_do_const_field;
100609 + bool has_no_const_field;
100610 +} constify_info;
100611 +
100612 +static const_tree get_field_type(const_tree field)
100613 +{
100614 + return strip_array_types(TREE_TYPE(field));
100615 +}
100616 +
100617 +static bool is_fptr(const_tree field)
100618 +{
100619 + const_tree ptr = get_field_type(field);
100620 +
100621 + if (TREE_CODE(ptr) != POINTER_TYPE)
100622 + return false;
100623 +
100624 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100625 +}
100626 +
100627 +/*
100628 + * determine whether the given structure type meets the requirements for automatic constification,
100629 + * including the constification attributes on nested structure types
100630 + */
100631 +static void constifiable(const_tree node, constify_info *cinfo)
100632 +{
100633 + const_tree field;
100634 +
100635 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100636 +
100637 + // e.g., pointer to structure fields while still constructing the structure type
100638 + if (TYPE_FIELDS(node) == NULL_TREE)
100639 + return;
100640 +
100641 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100642 + const_tree type = get_field_type(field);
100643 + enum tree_code code = TREE_CODE(type);
100644 +
100645 + if (node == type)
100646 + continue;
100647 +
100648 + if (is_fptr(field))
100649 + cinfo->has_fptr_field = true;
100650 + else if (!TREE_READONLY(field))
100651 + cinfo->has_writable_field = true;
100652 +
100653 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100654 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100655 + cinfo->has_do_const_field = true;
100656 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100657 + cinfo->has_no_const_field = true;
100658 + else
100659 + constifiable(type, cinfo);
100660 + }
100661 + }
100662 +}
100663 +
100664 +static bool constified(const_tree node)
100665 +{
100666 + constify_info cinfo = {
100667 + .has_fptr_field = false,
100668 + .has_writable_field = false,
100669 + .has_do_const_field = false,
100670 + .has_no_const_field = false
100671 + };
100672 +
100673 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100674 +
100675 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100676 + gcc_assert(!TYPE_READONLY(node));
100677 + return false;
100678 + }
100679 +
100680 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100681 + gcc_assert(TYPE_READONLY(node));
100682 + return true;
100683 + }
100684 +
100685 + constifiable(node, &cinfo);
100686 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100687 + return false;
100688 +
100689 + return TYPE_READONLY(node);
100690 +}
100691 +
100692 +static void deconstify_tree(tree node);
100693 +
100694 +static void deconstify_type(tree type)
100695 +{
100696 + tree field;
100697 +
100698 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100699 +
100700 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100701 + const_tree fieldtype = get_field_type(field);
100702 +
100703 + // special case handling of simple ptr-to-same-array-type members
100704 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100705 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100706 +
100707 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100708 + continue;
100709 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100710 + continue;
100711 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100712 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100713 + TREE_TYPE(TREE_TYPE(field)) = type;
100714 + }
100715 + continue;
100716 + }
100717 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100718 + continue;
100719 + if (!constified(fieldtype))
100720 + continue;
100721 +
100722 + deconstify_tree(field);
100723 + TREE_READONLY(field) = 0;
100724 + }
100725 + TYPE_READONLY(type) = 0;
100726 + C_TYPE_FIELDS_READONLY(type) = 0;
100727 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100728 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100729 +}
100730 +
100731 +static void deconstify_tree(tree node)
100732 +{
100733 + tree old_type, new_type, field;
100734 +
100735 + old_type = TREE_TYPE(node);
100736 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100737 + node = TREE_TYPE(node) = copy_node(old_type);
100738 + old_type = TREE_TYPE(old_type);
100739 + }
100740 +
100741 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100742 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100743 +
100744 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100745 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100746 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100747 + DECL_FIELD_CONTEXT(field) = new_type;
100748 +
100749 + deconstify_type(new_type);
100750 +
100751 + TREE_TYPE(node) = new_type;
100752 +}
100753 +
100754 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100755 +{
100756 + tree type;
100757 + constify_info cinfo = {
100758 + .has_fptr_field = false,
100759 + .has_writable_field = false,
100760 + .has_do_const_field = false,
100761 + .has_no_const_field = false
100762 + };
100763 +
100764 + *no_add_attrs = true;
100765 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100766 + error("%qE attribute does not apply to functions", name);
100767 + return NULL_TREE;
100768 + }
100769 +
100770 + if (TREE_CODE(*node) == PARM_DECL) {
100771 + error("%qE attribute does not apply to function parameters", name);
100772 + return NULL_TREE;
100773 + }
100774 +
100775 + if (TREE_CODE(*node) == VAR_DECL) {
100776 + error("%qE attribute does not apply to variables", name);
100777 + return NULL_TREE;
100778 + }
100779 +
100780 + if (TYPE_P(*node)) {
100781 + *no_add_attrs = false;
100782 + type = *node;
100783 + } else {
100784 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100785 + type = TREE_TYPE(*node);
100786 + }
100787 +
100788 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100789 + error("%qE attribute applies to struct and union types only", name);
100790 + return NULL_TREE;
100791 + }
100792 +
100793 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100794 + error("%qE attribute is already applied to the type", name);
100795 + return NULL_TREE;
100796 + }
100797 +
100798 + if (TYPE_P(*node)) {
100799 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100800 + error("%qE attribute is incompatible with 'do_const'", name);
100801 + return NULL_TREE;
100802 + }
100803 +
100804 + constifiable(type, &cinfo);
100805 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100806 + deconstify_tree(*node);
100807 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100808 + return NULL_TREE;
100809 + }
100810 +
100811 + error("%qE attribute used on type that is not constified", name);
100812 + return NULL_TREE;
100813 +}
100814 +
100815 +static void constify_type(tree type)
100816 +{
100817 + TYPE_READONLY(type) = 1;
100818 + C_TYPE_FIELDS_READONLY(type) = 1;
100819 + TYPE_CONSTIFY_VISITED(type) = 1;
100820 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100821 +}
100822 +
100823 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100824 +{
100825 + *no_add_attrs = true;
100826 + if (!TYPE_P(*node)) {
100827 + error("%qE attribute applies to types only", name);
100828 + return NULL_TREE;
100829 + }
100830 +
100831 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100832 + error("%qE attribute applies to struct and union types only", name);
100833 + return NULL_TREE;
100834 + }
100835 +
100836 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100837 + error("%qE attribute is already applied to the type", name);
100838 + return NULL_TREE;
100839 + }
100840 +
100841 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100842 + error("%qE attribute is incompatible with 'no_const'", name);
100843 + return NULL_TREE;
100844 + }
100845 +
100846 + *no_add_attrs = false;
100847 + return NULL_TREE;
100848 +}
100849 +
100850 +static struct attribute_spec no_const_attr = {
100851 + .name = "no_const",
100852 + .min_length = 0,
100853 + .max_length = 0,
100854 + .decl_required = false,
100855 + .type_required = false,
100856 + .function_type_required = false,
100857 + .handler = handle_no_const_attribute,
100858 +#if BUILDING_GCC_VERSION >= 4007
100859 + .affects_type_identity = true
100860 +#endif
100861 +};
100862 +
100863 +static struct attribute_spec do_const_attr = {
100864 + .name = "do_const",
100865 + .min_length = 0,
100866 + .max_length = 0,
100867 + .decl_required = false,
100868 + .type_required = false,
100869 + .function_type_required = false,
100870 + .handler = handle_do_const_attribute,
100871 +#if BUILDING_GCC_VERSION >= 4007
100872 + .affects_type_identity = true
100873 +#endif
100874 +};
100875 +
100876 +static void register_attributes(void *event_data, void *data)
100877 +{
100878 + register_attribute(&no_const_attr);
100879 + register_attribute(&do_const_attr);
100880 +}
100881 +
100882 +static void finish_type(void *event_data, void *data)
100883 +{
100884 + tree type = (tree)event_data;
100885 + constify_info cinfo = {
100886 + .has_fptr_field = false,
100887 + .has_writable_field = false,
100888 + .has_do_const_field = false,
100889 + .has_no_const_field = false
100890 + };
100891 +
100892 + if (type == NULL_TREE || type == error_mark_node)
100893 + return;
100894 +
100895 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100896 + return;
100897 +
100898 + constifiable(type, &cinfo);
100899 +
100900 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100901 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100902 + return;
100903 + if (cinfo.has_writable_field)
100904 + return;
100905 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100906 + return;
100907 + }
100908 +
100909 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100910 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100911 + deconstify_type(type);
100912 + TYPE_CONSTIFY_VISITED(type) = 1;
100913 + } else
100914 + error("'no_const' attribute used on type that is not constified");
100915 + return;
100916 + }
100917 +
100918 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100919 + constify_type(type);
100920 + return;
100921 + }
100922 +
100923 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100924 + constify_type(type);
100925 + return;
100926 + }
100927 +
100928 + deconstify_type(type);
100929 + TYPE_CONSTIFY_VISITED(type) = 1;
100930 +}
100931 +
100932 +static void check_global_variables(void)
100933 +{
100934 + struct varpool_node *node;
100935 +
100936 +#if BUILDING_GCC_VERSION <= 4007
100937 + for (node = varpool_nodes; node; node = node->next) {
100938 + tree var = node->decl;
100939 +#else
100940 + FOR_EACH_VARIABLE(node) {
100941 + tree var = node->symbol.decl;
100942 +#endif
100943 + tree type = TREE_TYPE(var);
100944 +
100945 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100946 + continue;
100947 +
100948 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100949 + continue;
100950 +
100951 + if (!TYPE_CONSTIFY_VISITED(type))
100952 + continue;
100953 +
100954 + if (DECL_EXTERNAL(var))
100955 + continue;
100956 +
100957 + if (DECL_INITIAL(var))
100958 + continue;
100959 +
100960 + // this works around a gcc bug/feature where uninitialized globals
100961 + // are moved into the .bss section regardless of any constification
100962 + DECL_INITIAL(var) = build_constructor(type, NULL);
100963 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100964 + }
100965 +}
100966 +
100967 +static unsigned int check_local_variables(void)
100968 +{
100969 + unsigned int ret = 0;
100970 + tree var;
100971 +
100972 +#if BUILDING_GCC_VERSION == 4005
100973 + tree vars;
100974 +#else
100975 + unsigned int i;
100976 +#endif
100977 +
100978 +#if BUILDING_GCC_VERSION == 4005
100979 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100980 + var = TREE_VALUE(vars);
100981 +#else
100982 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100983 +#endif
100984 + tree type = TREE_TYPE(var);
100985 +
100986 + gcc_assert(DECL_P(var));
100987 + if (is_global_var(var))
100988 + continue;
100989 +
100990 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100991 + continue;
100992 +
100993 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100994 + continue;
100995 +
100996 + if (!TYPE_CONSTIFY_VISITED(type))
100997 + continue;
100998 +
100999 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101000 + ret = 1;
101001 + }
101002 + return ret;
101003 +}
101004 +
101005 +static unsigned int check_variables(void)
101006 +{
101007 + check_global_variables();
101008 + return check_local_variables();
101009 +}
101010 +
101011 + unsigned int ret = 0;
101012 +static struct gimple_opt_pass pass_local_variable = {
101013 + {
101014 + .type = GIMPLE_PASS,
101015 + .name = "check_variables",
101016 +#if BUILDING_GCC_VERSION >= 4008
101017 + .optinfo_flags = OPTGROUP_NONE,
101018 +#endif
101019 + .gate = NULL,
101020 + .execute = check_variables,
101021 + .sub = NULL,
101022 + .next = NULL,
101023 + .static_pass_number = 0,
101024 + .tv_id = TV_NONE,
101025 + .properties_required = 0,
101026 + .properties_provided = 0,
101027 + .properties_destroyed = 0,
101028 + .todo_flags_start = 0,
101029 + .todo_flags_finish = 0
101030 + }
101031 +};
101032 +
101033 +static struct {
101034 + const char *name;
101035 + const char *asm_op;
101036 +} sections[] = {
101037 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101038 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101039 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101040 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101041 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101042 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101043 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101044 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101045 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101046 +};
101047 +
101048 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101049 +
101050 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101051 +{
101052 + size_t i;
101053 +
101054 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101055 + if (!strcmp(sections[i].name, name))
101056 + return 0;
101057 + return old_section_type_flags(decl, name, reloc);
101058 +}
101059 +
101060 +static void constify_start_unit(void *gcc_data, void *user_data)
101061 +{
101062 +// size_t i;
101063 +
101064 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
101065 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
101066 +// sections[i].section = get_section(sections[i].name, 0, NULL);
101067 +
101068 + old_section_type_flags = targetm.section_type_flags;
101069 + targetm.section_type_flags = constify_section_type_flags;
101070 +}
101071 +
101072 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101073 +{
101074 + const char * const plugin_name = plugin_info->base_name;
101075 + const int argc = plugin_info->argc;
101076 + const struct plugin_argument * const argv = plugin_info->argv;
101077 + int i;
101078 + bool constify = true;
101079 +
101080 + struct register_pass_info local_variable_pass_info = {
101081 + .pass = &pass_local_variable.pass,
101082 + .reference_pass_name = "ssa",
101083 + .ref_pass_instance_number = 1,
101084 + .pos_op = PASS_POS_INSERT_BEFORE
101085 + };
101086 +
101087 + if (!plugin_default_version_check(version, &gcc_version)) {
101088 + error(G_("incompatible gcc/plugin versions"));
101089 + return 1;
101090 + }
101091 +
101092 + for (i = 0; i < argc; ++i) {
101093 + if (!(strcmp(argv[i].key, "no-constify"))) {
101094 + constify = false;
101095 + continue;
101096 + }
101097 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101098 + }
101099 +
101100 + if (strcmp(lang_hooks.name, "GNU C")) {
101101 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
101102 + constify = false;
101103 + }
101104 +
101105 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101106 + if (constify) {
101107 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101108 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101109 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101110 + }
101111 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101112 +
101113 + return 0;
101114 +}
101115 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101116 new file mode 100644
101117 index 0000000..e518932
101118 --- /dev/null
101119 +++ b/tools/gcc/generate_size_overflow_hash.sh
101120 @@ -0,0 +1,94 @@
101121 +#!/bin/bash
101122 +
101123 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101124 +
101125 +header1="size_overflow_hash.h"
101126 +database="size_overflow_hash.data"
101127 +n=65536
101128 +
101129 +usage() {
101130 +cat <<EOF
101131 +usage: $0 options
101132 +OPTIONS:
101133 + -h|--help help
101134 + -o header file
101135 + -d database file
101136 + -n hash array size
101137 +EOF
101138 + return 0
101139 +}
101140 +
101141 +while true
101142 +do
101143 + case "$1" in
101144 + -h|--help) usage && exit 0;;
101145 + -n) n=$2; shift 2;;
101146 + -o) header1="$2"; shift 2;;
101147 + -d) database="$2"; shift 2;;
101148 + --) shift 1; break ;;
101149 + *) break ;;
101150 + esac
101151 +done
101152 +
101153 +create_defines() {
101154 + for i in `seq 0 31`
101155 + do
101156 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101157 + done
101158 + echo >> "$header1"
101159 +}
101160 +
101161 +create_structs() {
101162 + rm -f "$header1"
101163 +
101164 + create_defines
101165 +
101166 + cat "$database" | while read data
101167 + do
101168 + data_array=($data)
101169 + struct_hash_name="${data_array[0]}"
101170 + funcn="${data_array[1]}"
101171 + params="${data_array[2]}"
101172 + next="${data_array[4]}"
101173 +
101174 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101175 +
101176 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101177 + echo -en "\t.param\t= " >> "$header1"
101178 + line=
101179 + for param_num in ${params//-/ };
101180 + do
101181 + line="${line}PARAM"$param_num"|"
101182 + done
101183 +
101184 + echo -e "${line%?},\n};\n" >> "$header1"
101185 + done
101186 +}
101187 +
101188 +create_headers() {
101189 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101190 +}
101191 +
101192 +create_array_elements() {
101193 + index=0
101194 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101195 + do
101196 + data_array=($data)
101197 + i="${data_array[3]}"
101198 + hash="${data_array[0]}"
101199 + while [[ $index -lt $i ]]
101200 + do
101201 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101202 + index=$(($index + 1))
101203 + done
101204 + index=$(($index + 1))
101205 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101206 + done
101207 + echo '};' >> $header1
101208 +}
101209 +
101210 +create_structs
101211 +create_headers
101212 +create_array_elements
101213 +
101214 +exit 0
101215 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101216 new file mode 100644
101217 index 0000000..568b360
101218 --- /dev/null
101219 +++ b/tools/gcc/kallocstat_plugin.c
101220 @@ -0,0 +1,170 @@
101221 +/*
101222 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101223 + * Licensed under the GPL v2
101224 + *
101225 + * Note: the choice of the license means that the compilation process is
101226 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101227 + * but for the kernel it doesn't matter since it doesn't link against
101228 + * any of the gcc libraries
101229 + *
101230 + * gcc plugin to find the distribution of k*alloc sizes
101231 + *
101232 + * TODO:
101233 + *
101234 + * BUGS:
101235 + * - none known
101236 + */
101237 +#include "gcc-plugin.h"
101238 +#include "config.h"
101239 +#include "system.h"
101240 +#include "coretypes.h"
101241 +#include "tree.h"
101242 +#include "tree-pass.h"
101243 +#include "flags.h"
101244 +#include "intl.h"
101245 +#include "toplev.h"
101246 +#include "plugin.h"
101247 +//#include "expr.h" where are you...
101248 +#include "diagnostic.h"
101249 +#include "plugin-version.h"
101250 +#include "tm.h"
101251 +#include "function.h"
101252 +#include "basic-block.h"
101253 +#include "gimple.h"
101254 +#include "rtl.h"
101255 +#include "emit-rtl.h"
101256 +
101257 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101258 +
101259 +int plugin_is_GPL_compatible;
101260 +
101261 +static const char * const kalloc_functions[] = {
101262 + "__kmalloc",
101263 + "kmalloc",
101264 + "kmalloc_large",
101265 + "kmalloc_node",
101266 + "kmalloc_order",
101267 + "kmalloc_order_trace",
101268 + "kmalloc_slab",
101269 + "kzalloc",
101270 + "kzalloc_node",
101271 +};
101272 +
101273 +static struct plugin_info kallocstat_plugin_info = {
101274 + .version = "201302112000",
101275 +};
101276 +
101277 +static unsigned int execute_kallocstat(void);
101278 +
101279 +static struct gimple_opt_pass kallocstat_pass = {
101280 + .pass = {
101281 + .type = GIMPLE_PASS,
101282 + .name = "kallocstat",
101283 +#if BUILDING_GCC_VERSION >= 4008
101284 + .optinfo_flags = OPTGROUP_NONE,
101285 +#endif
101286 + .gate = NULL,
101287 + .execute = execute_kallocstat,
101288 + .sub = NULL,
101289 + .next = NULL,
101290 + .static_pass_number = 0,
101291 + .tv_id = TV_NONE,
101292 + .properties_required = 0,
101293 + .properties_provided = 0,
101294 + .properties_destroyed = 0,
101295 + .todo_flags_start = 0,
101296 + .todo_flags_finish = 0
101297 + }
101298 +};
101299 +
101300 +static bool is_kalloc(const char *fnname)
101301 +{
101302 + size_t i;
101303 +
101304 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101305 + if (!strcmp(fnname, kalloc_functions[i]))
101306 + return true;
101307 + return false;
101308 +}
101309 +
101310 +static unsigned int execute_kallocstat(void)
101311 +{
101312 + basic_block bb;
101313 +
101314 + // 1. loop through BBs and GIMPLE statements
101315 + FOR_EACH_BB(bb) {
101316 + gimple_stmt_iterator gsi;
101317 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101318 + // gimple match:
101319 + tree fndecl, size;
101320 + gimple call_stmt;
101321 + const char *fnname;
101322 +
101323 + // is it a call
101324 + call_stmt = gsi_stmt(gsi);
101325 + if (!is_gimple_call(call_stmt))
101326 + continue;
101327 + fndecl = gimple_call_fndecl(call_stmt);
101328 + if (fndecl == NULL_TREE)
101329 + continue;
101330 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101331 + continue;
101332 +
101333 + // is it a call to k*alloc
101334 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101335 + if (!is_kalloc(fnname))
101336 + continue;
101337 +
101338 + // is the size arg the result of a simple const assignment
101339 + size = gimple_call_arg(call_stmt, 0);
101340 + while (true) {
101341 + gimple def_stmt;
101342 + expanded_location xloc;
101343 + size_t size_val;
101344 +
101345 + if (TREE_CODE(size) != SSA_NAME)
101346 + break;
101347 + def_stmt = SSA_NAME_DEF_STMT(size);
101348 + if (!def_stmt || !is_gimple_assign(def_stmt))
101349 + break;
101350 + if (gimple_num_ops(def_stmt) != 2)
101351 + break;
101352 + size = gimple_assign_rhs1(def_stmt);
101353 + if (!TREE_CONSTANT(size))
101354 + continue;
101355 + xloc = expand_location(gimple_location(def_stmt));
101356 + if (!xloc.file)
101357 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101358 + size_val = TREE_INT_CST_LOW(size);
101359 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101360 + break;
101361 + }
101362 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101363 +//debug_tree(gimple_call_fn(call_stmt));
101364 +//print_node(stderr, "pax", fndecl, 4);
101365 + }
101366 + }
101367 +
101368 + return 0;
101369 +}
101370 +
101371 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101372 +{
101373 + const char * const plugin_name = plugin_info->base_name;
101374 + struct register_pass_info kallocstat_pass_info = {
101375 + .pass = &kallocstat_pass.pass,
101376 + .reference_pass_name = "ssa",
101377 + .ref_pass_instance_number = 1,
101378 + .pos_op = PASS_POS_INSERT_AFTER
101379 + };
101380 +
101381 + if (!plugin_default_version_check(version, &gcc_version)) {
101382 + error(G_("incompatible gcc/plugin versions"));
101383 + return 1;
101384 + }
101385 +
101386 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101387 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101388 +
101389 + return 0;
101390 +}
101391 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101392 new file mode 100644
101393 index 0000000..698da67
101394 --- /dev/null
101395 +++ b/tools/gcc/kernexec_plugin.c
101396 @@ -0,0 +1,471 @@
101397 +/*
101398 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101399 + * Licensed under the GPL v2
101400 + *
101401 + * Note: the choice of the license means that the compilation process is
101402 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101403 + * but for the kernel it doesn't matter since it doesn't link against
101404 + * any of the gcc libraries
101405 + *
101406 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101407 + *
101408 + * TODO:
101409 + *
101410 + * BUGS:
101411 + * - none known
101412 + */
101413 +#include "gcc-plugin.h"
101414 +#include "config.h"
101415 +#include "system.h"
101416 +#include "coretypes.h"
101417 +#include "tree.h"
101418 +#include "tree-pass.h"
101419 +#include "flags.h"
101420 +#include "intl.h"
101421 +#include "toplev.h"
101422 +#include "plugin.h"
101423 +//#include "expr.h" where are you...
101424 +#include "diagnostic.h"
101425 +#include "plugin-version.h"
101426 +#include "tm.h"
101427 +#include "function.h"
101428 +#include "basic-block.h"
101429 +#include "gimple.h"
101430 +#include "rtl.h"
101431 +#include "emit-rtl.h"
101432 +#include "tree-flow.h"
101433 +
101434 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101435 +extern rtx emit_move_insn(rtx x, rtx y);
101436 +
101437 +#if BUILDING_GCC_VERSION <= 4006
101438 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101439 +#endif
101440 +
101441 +#if BUILDING_GCC_VERSION >= 4008
101442 +#define TODO_dump_func 0
101443 +#endif
101444 +
101445 +int plugin_is_GPL_compatible;
101446 +
101447 +static struct plugin_info kernexec_plugin_info = {
101448 + .version = "201308230150",
101449 + .help = "method=[bts|or]\tinstrumentation method\n"
101450 +};
101451 +
101452 +static unsigned int execute_kernexec_reload(void);
101453 +static unsigned int execute_kernexec_fptr(void);
101454 +static unsigned int execute_kernexec_retaddr(void);
101455 +static bool kernexec_cmodel_check(void);
101456 +
101457 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101458 +static void (*kernexec_instrument_retaddr)(rtx);
101459 +
101460 +static struct gimple_opt_pass kernexec_reload_pass = {
101461 + .pass = {
101462 + .type = GIMPLE_PASS,
101463 + .name = "kernexec_reload",
101464 +#if BUILDING_GCC_VERSION >= 4008
101465 + .optinfo_flags = OPTGROUP_NONE,
101466 +#endif
101467 + .gate = kernexec_cmodel_check,
101468 + .execute = execute_kernexec_reload,
101469 + .sub = NULL,
101470 + .next = NULL,
101471 + .static_pass_number = 0,
101472 + .tv_id = TV_NONE,
101473 + .properties_required = 0,
101474 + .properties_provided = 0,
101475 + .properties_destroyed = 0,
101476 + .todo_flags_start = 0,
101477 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101478 + }
101479 +};
101480 +
101481 +static struct gimple_opt_pass kernexec_fptr_pass = {
101482 + .pass = {
101483 + .type = GIMPLE_PASS,
101484 + .name = "kernexec_fptr",
101485 +#if BUILDING_GCC_VERSION >= 4008
101486 + .optinfo_flags = OPTGROUP_NONE,
101487 +#endif
101488 + .gate = kernexec_cmodel_check,
101489 + .execute = execute_kernexec_fptr,
101490 + .sub = NULL,
101491 + .next = NULL,
101492 + .static_pass_number = 0,
101493 + .tv_id = TV_NONE,
101494 + .properties_required = 0,
101495 + .properties_provided = 0,
101496 + .properties_destroyed = 0,
101497 + .todo_flags_start = 0,
101498 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101499 + }
101500 +};
101501 +
101502 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101503 + .pass = {
101504 + .type = RTL_PASS,
101505 + .name = "kernexec_retaddr",
101506 +#if BUILDING_GCC_VERSION >= 4008
101507 + .optinfo_flags = OPTGROUP_NONE,
101508 +#endif
101509 + .gate = kernexec_cmodel_check,
101510 + .execute = execute_kernexec_retaddr,
101511 + .sub = NULL,
101512 + .next = NULL,
101513 + .static_pass_number = 0,
101514 + .tv_id = TV_NONE,
101515 + .properties_required = 0,
101516 + .properties_provided = 0,
101517 + .properties_destroyed = 0,
101518 + .todo_flags_start = 0,
101519 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101520 + }
101521 +};
101522 +
101523 +static bool kernexec_cmodel_check(void)
101524 +{
101525 + tree section;
101526 +
101527 + if (ix86_cmodel != CM_KERNEL)
101528 + return false;
101529 +
101530 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101531 + if (!section || !TREE_VALUE(section))
101532 + return true;
101533 +
101534 + section = TREE_VALUE(TREE_VALUE(section));
101535 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101536 + return true;
101537 +
101538 + return false;
101539 +}
101540 +
101541 +/*
101542 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101543 + */
101544 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101545 +{
101546 + gimple asm_movabs_stmt;
101547 +
101548 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101549 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101550 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101551 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101552 + update_stmt(asm_movabs_stmt);
101553 +}
101554 +
101555 +/*
101556 + * find all asm() stmts that clobber r10 and add a reload of r10
101557 + */
101558 +static unsigned int execute_kernexec_reload(void)
101559 +{
101560 + basic_block bb;
101561 +
101562 + // 1. loop through BBs and GIMPLE statements
101563 + FOR_EACH_BB(bb) {
101564 + gimple_stmt_iterator gsi;
101565 +
101566 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101567 + // gimple match: __asm__ ("" : : : "r10");
101568 + gimple asm_stmt;
101569 + size_t nclobbers;
101570 +
101571 + // is it an asm ...
101572 + asm_stmt = gsi_stmt(gsi);
101573 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101574 + continue;
101575 +
101576 + // ... clobbering r10
101577 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101578 + while (nclobbers--) {
101579 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101580 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101581 + continue;
101582 + kernexec_reload_fptr_mask(&gsi);
101583 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101584 + break;
101585 + }
101586 + }
101587 + }
101588 +
101589 + return 0;
101590 +}
101591 +
101592 +/*
101593 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101594 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101595 + */
101596 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101597 +{
101598 + gimple assign_intptr, assign_new_fptr, call_stmt;
101599 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101600 +
101601 + call_stmt = gsi_stmt(*gsi);
101602 + old_fptr = gimple_call_fn(call_stmt);
101603 +
101604 + // create temporary unsigned long variable used for bitops and cast fptr to it
101605 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101606 +#if BUILDING_GCC_VERSION <= 4007
101607 + add_referenced_var(intptr);
101608 +#endif
101609 + intptr = make_ssa_name(intptr, NULL);
101610 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101611 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101612 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101613 + update_stmt(assign_intptr);
101614 +
101615 + // apply logical or to temporary unsigned long and bitmask
101616 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101617 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101618 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101619 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101620 + assign_intptr = gimple_build_assign(intptr, orptr);
101621 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101622 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101623 + update_stmt(assign_intptr);
101624 +
101625 + // cast temporary unsigned long back to a temporary fptr variable
101626 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101627 +#if BUILDING_GCC_VERSION <= 4007
101628 + add_referenced_var(new_fptr);
101629 +#endif
101630 + new_fptr = make_ssa_name(new_fptr, NULL);
101631 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101632 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101633 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101634 + update_stmt(assign_new_fptr);
101635 +
101636 + // replace call stmt fn with the new fptr
101637 + gimple_call_set_fn(call_stmt, new_fptr);
101638 + update_stmt(call_stmt);
101639 +}
101640 +
101641 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101642 +{
101643 + gimple asm_or_stmt, call_stmt;
101644 + tree old_fptr, new_fptr, input, output;
101645 +#if BUILDING_GCC_VERSION <= 4007
101646 + VEC(tree, gc) *inputs = NULL;
101647 + VEC(tree, gc) *outputs = NULL;
101648 +#else
101649 + vec<tree, va_gc> *inputs = NULL;
101650 + vec<tree, va_gc> *outputs = NULL;
101651 +#endif
101652 +
101653 + call_stmt = gsi_stmt(*gsi);
101654 + old_fptr = gimple_call_fn(call_stmt);
101655 +
101656 + // create temporary fptr variable
101657 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101658 +#if BUILDING_GCC_VERSION <= 4007
101659 + add_referenced_var(new_fptr);
101660 +#endif
101661 + new_fptr = make_ssa_name(new_fptr, NULL);
101662 +
101663 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101664 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101665 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101666 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101667 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101668 +#if BUILDING_GCC_VERSION <= 4007
101669 + VEC_safe_push(tree, gc, inputs, input);
101670 + VEC_safe_push(tree, gc, outputs, output);
101671 +#else
101672 + vec_safe_push(inputs, input);
101673 + vec_safe_push(outputs, output);
101674 +#endif
101675 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101676 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101677 + gimple_asm_set_volatile(asm_or_stmt, true);
101678 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101679 + update_stmt(asm_or_stmt);
101680 +
101681 + // replace call stmt fn with the new fptr
101682 + gimple_call_set_fn(call_stmt, new_fptr);
101683 + update_stmt(call_stmt);
101684 +}
101685 +
101686 +/*
101687 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101688 + */
101689 +static unsigned int execute_kernexec_fptr(void)
101690 +{
101691 + basic_block bb;
101692 +
101693 + // 1. loop through BBs and GIMPLE statements
101694 + FOR_EACH_BB(bb) {
101695 + gimple_stmt_iterator gsi;
101696 +
101697 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101698 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101699 + tree fn;
101700 + gimple call_stmt;
101701 +
101702 + // is it a call ...
101703 + call_stmt = gsi_stmt(gsi);
101704 + if (!is_gimple_call(call_stmt))
101705 + continue;
101706 + fn = gimple_call_fn(call_stmt);
101707 + if (TREE_CODE(fn) == ADDR_EXPR)
101708 + continue;
101709 + if (TREE_CODE(fn) != SSA_NAME)
101710 + gcc_unreachable();
101711 +
101712 + // ... through a function pointer
101713 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101714 + fn = SSA_NAME_VAR(fn);
101715 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101716 + debug_tree(fn);
101717 + gcc_unreachable();
101718 + }
101719 + }
101720 + fn = TREE_TYPE(fn);
101721 + if (TREE_CODE(fn) != POINTER_TYPE)
101722 + continue;
101723 + fn = TREE_TYPE(fn);
101724 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101725 + continue;
101726 +
101727 + kernexec_instrument_fptr(&gsi);
101728 +
101729 +//debug_tree(gimple_call_fn(call_stmt));
101730 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101731 + }
101732 + }
101733 +
101734 + return 0;
101735 +}
101736 +
101737 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101738 +static void kernexec_instrument_retaddr_bts(rtx insn)
101739 +{
101740 + rtx btsq;
101741 + rtvec argvec, constraintvec, labelvec;
101742 + int line;
101743 +
101744 + // create asm volatile("btsq $63,(%%rsp)":::)
101745 + argvec = rtvec_alloc(0);
101746 + constraintvec = rtvec_alloc(0);
101747 + labelvec = rtvec_alloc(0);
101748 + line = expand_location(RTL_LOCATION(insn)).line;
101749 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101750 + MEM_VOLATILE_P(btsq) = 1;
101751 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101752 + emit_insn_before(btsq, insn);
101753 +}
101754 +
101755 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101756 +static void kernexec_instrument_retaddr_or(rtx insn)
101757 +{
101758 + rtx orq;
101759 + rtvec argvec, constraintvec, labelvec;
101760 + int line;
101761 +
101762 + // create asm volatile("orq %%r10,(%%rsp)":::)
101763 + argvec = rtvec_alloc(0);
101764 + constraintvec = rtvec_alloc(0);
101765 + labelvec = rtvec_alloc(0);
101766 + line = expand_location(RTL_LOCATION(insn)).line;
101767 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101768 + MEM_VOLATILE_P(orq) = 1;
101769 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101770 + emit_insn_before(orq, insn);
101771 +}
101772 +
101773 +/*
101774 + * find all asm level function returns and forcibly set the highest bit of the return address
101775 + */
101776 +static unsigned int execute_kernexec_retaddr(void)
101777 +{
101778 + rtx insn;
101779 +
101780 + // 1. find function returns
101781 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101782 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101783 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101784 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101785 + rtx body;
101786 +
101787 + // is it a retn
101788 + if (!JUMP_P(insn))
101789 + continue;
101790 + body = PATTERN(insn);
101791 + if (GET_CODE(body) == PARALLEL)
101792 + body = XVECEXP(body, 0, 0);
101793 + if (!ANY_RETURN_P(body))
101794 + continue;
101795 + kernexec_instrument_retaddr(insn);
101796 + }
101797 +
101798 +// print_simple_rtl(stderr, get_insns());
101799 +// print_rtl(stderr, get_insns());
101800 +
101801 + return 0;
101802 +}
101803 +
101804 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101805 +{
101806 + const char * const plugin_name = plugin_info->base_name;
101807 + const int argc = plugin_info->argc;
101808 + const struct plugin_argument * const argv = plugin_info->argv;
101809 + int i;
101810 + struct register_pass_info kernexec_reload_pass_info = {
101811 + .pass = &kernexec_reload_pass.pass,
101812 + .reference_pass_name = "ssa",
101813 + .ref_pass_instance_number = 1,
101814 + .pos_op = PASS_POS_INSERT_AFTER
101815 + };
101816 + struct register_pass_info kernexec_fptr_pass_info = {
101817 + .pass = &kernexec_fptr_pass.pass,
101818 + .reference_pass_name = "ssa",
101819 + .ref_pass_instance_number = 1,
101820 + .pos_op = PASS_POS_INSERT_AFTER
101821 + };
101822 + struct register_pass_info kernexec_retaddr_pass_info = {
101823 + .pass = &kernexec_retaddr_pass.pass,
101824 + .reference_pass_name = "pro_and_epilogue",
101825 + .ref_pass_instance_number = 1,
101826 + .pos_op = PASS_POS_INSERT_AFTER
101827 + };
101828 +
101829 + if (!plugin_default_version_check(version, &gcc_version)) {
101830 + error(G_("incompatible gcc/plugin versions"));
101831 + return 1;
101832 + }
101833 +
101834 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101835 +
101836 + if (TARGET_64BIT == 0)
101837 + return 0;
101838 +
101839 + for (i = 0; i < argc; ++i) {
101840 + if (!strcmp(argv[i].key, "method")) {
101841 + if (!argv[i].value) {
101842 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101843 + continue;
101844 + }
101845 + if (!strcmp(argv[i].value, "bts")) {
101846 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101847 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101848 + } else if (!strcmp(argv[i].value, "or")) {
101849 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101850 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101851 + fix_register("r10", 1, 1);
101852 + } else
101853 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101854 + continue;
101855 + }
101856 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101857 + }
101858 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101859 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101860 +
101861 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101862 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101863 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101864 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101865 +
101866 + return 0;
101867 +}
101868 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101869 new file mode 100644
101870 index 0000000..679b9ef
101871 --- /dev/null
101872 +++ b/tools/gcc/latent_entropy_plugin.c
101873 @@ -0,0 +1,335 @@
101874 +/*
101875 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101876 + * Licensed under the GPL v2
101877 + *
101878 + * Note: the choice of the license means that the compilation process is
101879 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101880 + * but for the kernel it doesn't matter since it doesn't link against
101881 + * any of the gcc libraries
101882 + *
101883 + * gcc plugin to help generate a little bit of entropy from program state,
101884 + * used during boot in the kernel
101885 + *
101886 + * TODO:
101887 + * - add ipa pass to identify not explicitly marked candidate functions
101888 + * - mix in more program state (function arguments/return values, loop variables, etc)
101889 + * - more instrumentation control via attribute parameters
101890 + *
101891 + * BUGS:
101892 + * - LTO needs -flto-partition=none for now
101893 + */
101894 +#include "gcc-plugin.h"
101895 +#include "config.h"
101896 +#include "system.h"
101897 +#include "coretypes.h"
101898 +#include "tree.h"
101899 +#include "tree-pass.h"
101900 +#include "flags.h"
101901 +#include "intl.h"
101902 +#include "toplev.h"
101903 +#include "plugin.h"
101904 +//#include "expr.h" where are you...
101905 +#include "diagnostic.h"
101906 +#include "plugin-version.h"
101907 +#include "tm.h"
101908 +#include "function.h"
101909 +#include "basic-block.h"
101910 +#include "gimple.h"
101911 +#include "rtl.h"
101912 +#include "emit-rtl.h"
101913 +#include "tree-flow.h"
101914 +#include "langhooks.h"
101915 +
101916 +#if BUILDING_GCC_VERSION >= 4008
101917 +#define TODO_dump_func 0
101918 +#endif
101919 +
101920 +int plugin_is_GPL_compatible;
101921 +
101922 +static tree latent_entropy_decl;
101923 +
101924 +static struct plugin_info latent_entropy_plugin_info = {
101925 + .version = "201308230230",
101926 + .help = NULL
101927 +};
101928 +
101929 +static unsigned int execute_latent_entropy(void);
101930 +static bool gate_latent_entropy(void);
101931 +
101932 +static struct gimple_opt_pass latent_entropy_pass = {
101933 + .pass = {
101934 + .type = GIMPLE_PASS,
101935 + .name = "latent_entropy",
101936 +#if BUILDING_GCC_VERSION >= 4008
101937 + .optinfo_flags = OPTGROUP_NONE,
101938 +#endif
101939 + .gate = gate_latent_entropy,
101940 + .execute = execute_latent_entropy,
101941 + .sub = NULL,
101942 + .next = NULL,
101943 + .static_pass_number = 0,
101944 + .tv_id = TV_NONE,
101945 + .properties_required = PROP_gimple_leh | PROP_cfg,
101946 + .properties_provided = 0,
101947 + .properties_destroyed = 0,
101948 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101949 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101950 + }
101951 +};
101952 +
101953 +static unsigned HOST_WIDE_INT seed;
101954 +static unsigned HOST_WIDE_INT get_random_const(void)
101955 +{
101956 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101957 + return seed;
101958 +}
101959 +
101960 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101961 +{
101962 + switch (TREE_CODE(*node)) {
101963 + default:
101964 + *no_add_attrs = true;
101965 + error("%qE attribute only applies to functions and variables", name);
101966 + break;
101967 +
101968 + case VAR_DECL:
101969 + if (DECL_INITIAL(*node)) {
101970 + *no_add_attrs = true;
101971 + error("variable %qD with %qE attribute must not be initialized", *node, name);
101972 + break;
101973 + }
101974 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101975 + break;
101976 +
101977 + case FUNCTION_DECL:
101978 + break;
101979 + }
101980 +
101981 + return NULL_TREE;
101982 +}
101983 +
101984 +static struct attribute_spec latent_entropy_attr = {
101985 + .name = "latent_entropy",
101986 + .min_length = 0,
101987 + .max_length = 0,
101988 + .decl_required = true,
101989 + .type_required = false,
101990 + .function_type_required = false,
101991 + .handler = handle_latent_entropy_attribute,
101992 +#if BUILDING_GCC_VERSION >= 4007
101993 + .affects_type_identity = false
101994 +#endif
101995 +};
101996 +
101997 +static void register_attributes(void *event_data, void *data)
101998 +{
101999 + register_attribute(&latent_entropy_attr);
102000 +}
102001 +
102002 +static bool gate_latent_entropy(void)
102003 +{
102004 + tree latent_entropy_attr;
102005 +
102006 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102007 + return latent_entropy_attr != NULL_TREE;
102008 +}
102009 +
102010 +static enum tree_code get_op(tree *rhs)
102011 +{
102012 + static enum tree_code op;
102013 + unsigned HOST_WIDE_INT random_const;
102014 +
102015 + random_const = get_random_const();
102016 +
102017 + switch (op) {
102018 + case BIT_XOR_EXPR:
102019 + op = PLUS_EXPR;
102020 + break;
102021 +
102022 + case PLUS_EXPR:
102023 + if (rhs) {
102024 + op = LROTATE_EXPR;
102025 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102026 + break;
102027 + }
102028 +
102029 + case LROTATE_EXPR:
102030 + default:
102031 + op = BIT_XOR_EXPR;
102032 + break;
102033 + }
102034 + if (rhs)
102035 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102036 + return op;
102037 +}
102038 +
102039 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102040 +{
102041 + gimple_stmt_iterator gsi;
102042 + gimple assign;
102043 + tree addxorrol, rhs;
102044 + enum tree_code op;
102045 +
102046 + op = get_op(&rhs);
102047 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102048 + assign = gimple_build_assign(local_entropy, addxorrol);
102049 + gsi = gsi_after_labels(bb);
102050 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102051 + update_stmt(assign);
102052 +//debug_bb(bb);
102053 +}
102054 +
102055 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102056 +{
102057 + gimple_stmt_iterator gsi;
102058 + gimple assign;
102059 + tree addxorrol, temp;
102060 +
102061 + // 1. create temporary copy of latent_entropy
102062 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102063 +#if BUILDING_GCC_VERSION <= 4007
102064 + add_referenced_var(temp);
102065 +#endif
102066 +
102067 + // 2. read...
102068 + temp = make_ssa_name(temp, NULL);
102069 + assign = gimple_build_assign(temp, latent_entropy_decl);
102070 + SSA_NAME_DEF_STMT(temp) = assign;
102071 +#if BUILDING_GCC_VERSION <= 4007
102072 + add_referenced_var(latent_entropy_decl);
102073 +#endif
102074 + gsi = gsi_after_labels(bb);
102075 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102076 + update_stmt(assign);
102077 +
102078 + // 3. ...modify...
102079 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
102080 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
102081 + assign = gimple_build_assign(temp, addxorrol);
102082 + SSA_NAME_DEF_STMT(temp) = assign;
102083 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102084 + update_stmt(assign);
102085 +
102086 + // 4. ...write latent_entropy
102087 + assign = gimple_build_assign(latent_entropy_decl, temp);
102088 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102089 + update_stmt(assign);
102090 +}
102091 +
102092 +static unsigned int execute_latent_entropy(void)
102093 +{
102094 + basic_block bb;
102095 + gimple assign;
102096 + gimple_stmt_iterator gsi;
102097 + tree local_entropy;
102098 +
102099 + if (!latent_entropy_decl) {
102100 + struct varpool_node *node;
102101 +
102102 +#if BUILDING_GCC_VERSION <= 4007
102103 + for (node = varpool_nodes; node; node = node->next) {
102104 + tree var = node->decl;
102105 +#else
102106 + FOR_EACH_VARIABLE(node) {
102107 + tree var = node->symbol.decl;
102108 +#endif
102109 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102110 + continue;
102111 + latent_entropy_decl = var;
102112 +// debug_tree(var);
102113 + break;
102114 + }
102115 + if (!latent_entropy_decl) {
102116 +// debug_tree(current_function_decl);
102117 + return 0;
102118 + }
102119 + }
102120 +
102121 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102122 +
102123 + // 1. create local entropy variable
102124 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102125 +#if BUILDING_GCC_VERSION <= 4007
102126 + add_referenced_var(local_entropy);
102127 + mark_sym_for_renaming(local_entropy);
102128 +#endif
102129 +
102130 + // 2. initialize local entropy variable
102131 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102132 + if (dom_info_available_p(CDI_DOMINATORS))
102133 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102134 + gsi = gsi_start_bb(bb);
102135 +
102136 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102137 +// gimple_set_location(assign, loc);
102138 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102139 + update_stmt(assign);
102140 +//debug_bb(bb);
102141 + bb = bb->next_bb;
102142 +
102143 + // 3. instrument each BB with an operation on the local entropy variable
102144 + while (bb != EXIT_BLOCK_PTR) {
102145 + perturb_local_entropy(bb, local_entropy);
102146 +//debug_bb(bb);
102147 + bb = bb->next_bb;
102148 + };
102149 +
102150 + // 4. mix local entropy into the global entropy variable
102151 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102152 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102153 + return 0;
102154 +}
102155 +
102156 +static void start_unit_callback(void *gcc_data, void *user_data)
102157 +{
102158 + tree latent_entropy_type;
102159 +
102160 +#if BUILDING_GCC_VERSION >= 4007
102161 + seed = get_random_seed(false);
102162 +#else
102163 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102164 + seed *= seed;
102165 +#endif
102166 +
102167 + if (in_lto_p)
102168 + return;
102169 +
102170 + // extern volatile u64 latent_entropy
102171 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102172 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102173 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102174 +
102175 + TREE_STATIC(latent_entropy_decl) = 1;
102176 + TREE_PUBLIC(latent_entropy_decl) = 1;
102177 + TREE_USED(latent_entropy_decl) = 1;
102178 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102179 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102180 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102181 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102182 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102183 +// varpool_finalize_decl(latent_entropy_decl);
102184 +// varpool_mark_needed_node(latent_entropy_decl);
102185 +}
102186 +
102187 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102188 +{
102189 + const char * const plugin_name = plugin_info->base_name;
102190 + struct register_pass_info latent_entropy_pass_info = {
102191 + .pass = &latent_entropy_pass.pass,
102192 + .reference_pass_name = "optimized",
102193 + .ref_pass_instance_number = 1,
102194 + .pos_op = PASS_POS_INSERT_BEFORE
102195 + };
102196 +
102197 + if (!plugin_default_version_check(version, &gcc_version)) {
102198 + error(G_("incompatible gcc/plugin versions"));
102199 + return 1;
102200 + }
102201 +
102202 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102203 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102204 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102205 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102206 +
102207 + return 0;
102208 +}
102209 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102210 new file mode 100644
102211 index 0000000..0a9d518
102212 --- /dev/null
102213 +++ b/tools/gcc/size_overflow_hash.data
102214 @@ -0,0 +1,7637 @@
102215 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102216 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
102217 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102218 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102219 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102220 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102221 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102222 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102223 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102224 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102225 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102226 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102227 +load_msg_95 load_msg 2 95 NULL
102228 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102229 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 NULL nohasharray
102230 +write_all_supers_117 write_all_supers 0 117 &ipath_verbs_send_117
102231 +init_q_132 init_q 4 132 NULL
102232 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
102233 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102234 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102235 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
102236 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
102237 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
102238 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
102239 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
102240 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
102241 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
102242 +br_port_info_size_268 br_port_info_size 0 268 NULL
102243 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
102244 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
102245 +SYSC_connect_304 SYSC_connect 3 304 NULL
102246 +syslog_print_307 syslog_print 2 307 NULL
102247 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102248 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
102249 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
102250 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
102251 +get_more_blocks_367 get_more_blocks 0 367 NULL
102252 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
102253 +hw_device_state_409 hw_device_state 0 409 NULL
102254 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
102255 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102256 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102257 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
102258 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102259 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
102260 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102261 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
102262 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102263 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
102264 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102265 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
102266 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
102267 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102268 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102269 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102270 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
102271 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102272 +cl_page_own0_599 cl_page_own0 0 599 NULL
102273 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
102274 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102275 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102276 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
102277 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
102278 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
102279 +clone_split_bio_633 clone_split_bio 6 633 NULL
102280 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102281 +remap_to_cache_640 remap_to_cache 3 640 NULL
102282 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
102283 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
102284 +unlink_queued_645 unlink_queued 4 645 NULL
102285 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102286 +div_u64_rem_672 div_u64_rem 0 672 NULL
102287 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102288 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102289 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102290 +disk_max_parts_719 disk_max_parts 0 719 NULL
102291 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102292 +dvb_video_write_754 dvb_video_write 3 754 NULL
102293 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
102294 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
102295 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
102296 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
102297 +if_writecmd_815 if_writecmd 2 815 NULL
102298 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102299 +SyS_write_846 SyS_write 3 846 NULL
102300 +um_idi_read_850 um_idi_read 3 850 NULL
102301 +error_state_read_859 error_state_read 6 859 NULL
102302 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102303 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102304 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
102305 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102306 +readw_931 readw 0 931 NULL
102307 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102308 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102309 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
102310 +memcmp_990 memcmp 0 990 NULL
102311 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
102312 +free_ind_block_999 free_ind_block 0 999 NULL
102313 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102314 +readreg_1017 readreg 0-1 1017 NULL
102315 +_do_truncate_1019 _do_truncate 2 1019 NULL
102316 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102317 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102318 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102319 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102320 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
102321 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102322 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102323 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
102324 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
102325 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102326 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
102327 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
102328 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
102329 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102330 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102331 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102332 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
102333 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102334 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102335 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
102336 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102337 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102338 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102339 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
102340 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102341 +nested_get_page_1252 nested_get_page 2 1252 NULL
102342 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102343 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102344 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102345 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102346 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
102347 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102348 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
102349 +ffs_1322 ffs 0 1322 NULL
102350 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
102351 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
102352 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102353 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102354 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
102355 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102356 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102357 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102358 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102359 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102360 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102361 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102362 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
102363 +zone_page_state_1393 zone_page_state 0 1393 NULL
102364 +file_read_actor_1401 file_read_actor 4 1401 NULL
102365 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
102366 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
102367 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
102368 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102369 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102370 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102371 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102372 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102373 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102374 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102375 +fpregs_set_1497 fpregs_set 4 1497 NULL
102376 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
102377 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102378 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102379 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102380 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
102381 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102382 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
102383 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102384 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102385 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102386 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
102387 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102388 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
102389 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102390 +rmap_add_1677 rmap_add 3 1677 NULL
102391 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102392 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
102393 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
102394 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
102395 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102396 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102397 +internal_create_group_1733 internal_create_group 0 1733 NULL
102398 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
102399 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102400 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102401 +cosa_write_1774 cosa_write 3 1774 NULL
102402 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102403 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
102404 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
102405 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102406 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102407 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102408 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
102409 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102410 +bdev_erase_1933 bdev_erase 3 1933 NULL
102411 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
102412 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102413 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102414 +read_swap_header_1957 read_swap_header 0 1957 NULL
102415 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102416 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102417 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
102418 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
102419 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102420 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
102421 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102422 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102423 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102424 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102425 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102426 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
102427 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102428 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102429 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
102430 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
102431 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
102432 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102433 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
102434 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102435 +audit_expand_2098 audit_expand 0 2098 NULL
102436 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102437 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
102438 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102439 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102440 +enable_read_2117 enable_read 3 2117 NULL
102441 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102442 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
102443 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102444 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102445 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102446 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
102447 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
102448 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
102449 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102450 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
102451 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102452 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102453 +vhci_write_2224 vhci_write 3 2224 NULL
102454 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
102455 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102456 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102457 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102458 +do_update_counters_2259 do_update_counters 4 2259 NULL
102459 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102460 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102461 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
102462 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
102463 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102464 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
102465 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
102466 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
102467 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102468 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102469 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102470 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
102471 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
102472 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
102473 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102474 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102475 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
102476 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102477 +raid1_size_2419 raid1_size 0-2 2419 NULL
102478 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
102479 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102480 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102481 +wiphy_new_2482 wiphy_new 2 2482 NULL
102482 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102483 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
102484 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102485 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102486 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102487 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102488 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102489 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102490 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
102491 +slot_bytes_2609 slot_bytes 0 2609 NULL
102492 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102493 +switch_status_2629 switch_status 5 2629 NULL
102494 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
102495 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102496 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
102497 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
102498 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
102499 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
102500 +oti6858_write_2692 oti6858_write 4 2692 NULL
102501 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102502 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
102503 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
102504 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
102505 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
102506 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
102507 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
102508 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102509 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102510 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
102511 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102512 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
102513 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
102514 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102515 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
102516 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
102517 +sock_create_2838 sock_create 0 2838 NULL
102518 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102519 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102520 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102521 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
102522 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102523 +mq_map_2871 mq_map 2 2871 NULL
102524 +__swab64p_2875 __swab64p 0 2875 NULL
102525 +nla_padlen_2883 nla_padlen 1 2883 NULL
102526 +cmm_write_2896 cmm_write 3 2896 NULL
102527 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102528 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
102529 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102530 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102531 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102532 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
102533 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102534 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
102535 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102536 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
102537 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102538 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
102539 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
102540 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102541 +depth_write_3021 depth_write 3 3021 NULL
102542 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102543 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
102544 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102545 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
102546 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
102547 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102548 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102549 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102550 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
102551 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102552 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
102553 +free_coherent_3082 free_coherent 4-2 3082 NULL
102554 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
102555 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102556 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102557 +rb_alloc_3102 rb_alloc 1 3102 NULL
102558 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
102559 +print_time_3132 print_time 0 3132 NULL
102560 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102561 +find_free_extent_3153 find_free_extent 5 3153 NULL
102562 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102563 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102564 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
102565 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102566 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102567 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102568 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
102569 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102570 +alloc_context_3194 alloc_context 1 3194 NULL
102571 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
102572 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
102573 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102574 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
102575 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
102576 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102577 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
102578 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102579 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102580 +key_key_read_3241 key_key_read 3 3241 NULL
102581 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
102582 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
102583 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102584 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
102585 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102586 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102587 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102588 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
102589 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102590 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102591 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102592 +scnprintf_3360 scnprintf 0-2 3360 NULL
102593 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
102594 +sr_read_3366 sr_read 3 3366 NULL
102595 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
102596 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102597 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102598 +send_stream_3397 send_stream 4 3397 NULL
102599 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102600 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102601 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102602 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102603 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102604 +send_unlink_3438 send_unlink 0 3438 NULL
102605 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102606 +map_single_3449 map_single 0 3449 NULL
102607 +softsynth_write_3455 softsynth_write 3 3455 NULL
102608 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102609 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
102610 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102611 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102612 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
102613 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
102614 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
102615 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
102616 +SyS_readv_3539 SyS_readv 3 3539 NULL
102617 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102618 +iommu_map_3554 iommu_map 3-2 3554 NULL
102619 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
102620 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
102621 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102622 +evtchn_read_3569 evtchn_read 3 3569 NULL
102623 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
102624 +vc_resize_3585 vc_resize 3-2 3585 NULL
102625 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
102626 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102627 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102628 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102629 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102630 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
102631 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102632 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102633 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
102634 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102635 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
102636 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102637 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102638 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102639 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
102640 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102641 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
102642 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102643 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
102644 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
102645 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
102646 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102647 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102648 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102649 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102650 +get_fd_set_3866 get_fd_set 1 3866 NULL
102651 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
102652 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102653 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102654 +nvram_write_3894 nvram_write 3 3894 NULL
102655 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102656 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102657 +vcs_write_3910 vcs_write 3 3910 NULL
102658 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
102659 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
102660 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102661 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
102662 +do_add_counters_3992 do_add_counters 3 3992 NULL
102663 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
102664 +userspace_status_4004 userspace_status 4 4004 NULL
102665 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102666 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102667 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102668 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
102669 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
102670 +blk_end_request_4024 blk_end_request 3 4024 NULL
102671 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102672 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
102673 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
102674 +read_file_queues_4078 read_file_queues 3 4078 NULL
102675 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102676 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
102677 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102678 +tm6000_read_4151 tm6000_read 3 4151 NULL
102679 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102680 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102681 +get_alua_req_4166 get_alua_req 3 4166 NULL
102682 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102683 +read_file_bool_4180 read_file_bool 3 4180 NULL
102684 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
102685 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102686 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102687 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102688 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
102689 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102690 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
102691 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102692 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102693 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102694 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102695 +__pool_find_4308 __pool_find 3 4308 NULL
102696 +count_strings_4315 count_strings 0 4315 NULL
102697 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102698 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102699 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
102700 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
102701 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
102702 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
102703 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102704 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
102705 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102706 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102707 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
102708 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102709 +memparse_4444 memparse 0 4444 NULL
102710 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
102711 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102712 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
102713 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
102714 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102715 +set_link_security_4502 set_link_security 4 4502 NULL
102716 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102717 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
102718 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
102719 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102720 +tty_register_device_4544 tty_register_device 2 4544 NULL
102721 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102722 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102723 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102724 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
102725 +bch_alloc_4593 bch_alloc 1 4593 NULL
102726 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
102727 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102728 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
102729 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102730 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
102731 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102732 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102733 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102734 +kone_receive_4690 kone_receive 4 4690 NULL
102735 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
102736 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102737 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102738 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102739 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102740 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
102741 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
102742 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
102743 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102744 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
102745 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
102746 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
102747 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
102748 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
102749 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102750 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
102751 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
102752 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102753 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102754 +get_new_location_4866 get_new_location 0 4866 NULL
102755 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
102756 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102757 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102758 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
102759 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102760 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
102761 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102762 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102763 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102764 +do_sync_read_4977 do_sync_read 0 4977 NULL
102765 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102766 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
102767 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
102768 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
102769 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
102770 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
102771 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102772 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102773 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102774 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
102775 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102776 +sound_write_5102 sound_write 3 5102 NULL
102777 +clear_dirty_5105 clear_dirty 3 5105 NULL
102778 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
102779 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
102780 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102781 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
102782 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102783 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102784 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102785 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
102786 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
102787 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102788 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102789 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
102790 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102791 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
102792 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
102793 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102794 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
102795 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102796 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
102797 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102798 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102799 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102800 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
102801 +cq_free_res_5355 cq_free_res 5 5355 NULL
102802 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102803 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
102804 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
102805 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102806 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
102807 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
102808 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102809 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
102810 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
102811 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102812 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102813 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102814 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102815 +tty_write_5494 tty_write 3 5494 NULL
102816 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102817 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102818 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102819 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102820 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
102821 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102822 +le_readq_5557 le_readq 0 5557 NULL
102823 +inw_5558 inw 0 5558 NULL
102824 +bioset_create_5580 bioset_create 1 5580 NULL
102825 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
102826 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
102827 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102828 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102829 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
102830 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
102831 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102832 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102833 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102834 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
102835 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102836 +get_arg_5694 get_arg 3 5694 NULL
102837 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102838 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
102839 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102840 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102841 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
102842 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
102843 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102844 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
102845 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102846 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102847 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102848 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102849 +setup_req_5848 setup_req 3 5848 NULL
102850 +ria_page_count_5849 ria_page_count 0 5849 NULL
102851 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102852 +config_buf_5862 config_buf 0 5862 NULL
102853 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
102854 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102855 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
102856 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
102857 +port_show_regs_5904 port_show_regs 3 5904 NULL
102858 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102859 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102860 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102861 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102862 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102863 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
102864 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
102865 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102866 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102867 +native_pte_val_5978 native_pte_val 0 5978 NULL
102868 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
102869 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
102870 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
102871 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
102872 +alloc_msg_6072 alloc_msg 1 6072 NULL
102873 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102874 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102875 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102876 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
102877 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102878 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102879 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102880 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
102881 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102882 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102883 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102884 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102885 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102886 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
102887 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102888 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
102889 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
102890 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102891 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102892 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102893 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102894 +changed_ref_6242 changed_ref 0 6242 NULL
102895 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102896 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
102897 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102898 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102899 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
102900 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102901 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102902 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102903 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102904 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
102905 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
102906 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
102907 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102908 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102909 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
102910 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102911 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102912 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102913 +msb_write_block_6379 msb_write_block 3 6379 NULL
102914 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
102915 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102916 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
102917 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102918 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
102919 +add_to_list_6433 add_to_list 0 6433 NULL
102920 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102921 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
102922 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
102923 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102924 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
102925 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102926 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102927 +mei_read_6507 mei_read 3 6507 NULL
102928 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
102929 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102930 +wdm_read_6549 wdm_read 3 6549 NULL
102931 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
102932 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102933 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102934 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102935 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
102936 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
102937 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102938 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102939 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
102940 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
102941 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102942 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
102943 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102944 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102945 +mpeg_read_6708 mpeg_read 3 6708 NULL
102946 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
102947 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102948 +video_proc_write_6724 video_proc_write 3 6724 NULL
102949 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102950 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
102951 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
102952 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
102953 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102954 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102955 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
102956 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102957 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102958 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
102959 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
102960 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102961 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102962 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102963 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102964 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
102965 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
102966 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102967 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102968 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102969 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
102970 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102971 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102972 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102973 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102974 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102975 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
102976 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102977 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
102978 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
102979 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
102980 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102981 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102982 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
102983 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
102984 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102985 +request_key_async_6990 request_key_async 4 6990 NULL
102986 +tpl_write_6998 tpl_write 3 6998 NULL
102987 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102988 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
102989 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102990 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102991 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
102992 +wimax_msg_7030 wimax_msg 4 7030 NULL
102993 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102994 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102995 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
102996 +event_enable_read_7074 event_enable_read 3 7074 NULL
102997 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
102998 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102999 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103000 +check_header_7108 check_header 0 7108 NULL
103001 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
103002 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
103003 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
103004 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
103005 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103006 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
103007 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
103008 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
103009 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103010 +get_param_h_7247 get_param_h 0 7247 NULL
103011 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
103012 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
103013 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103014 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
103015 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
103016 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
103017 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103018 +get_string_7302 get_string 0 7302 NULL
103019 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103020 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
103021 +mgmt_control_7349 mgmt_control 3 7349 NULL
103022 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
103023 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
103024 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
103025 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
103026 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103027 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
103028 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
103029 +hweight_long_7388 hweight_long 1-0 7388 NULL
103030 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103031 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
103032 +readb_7401 readb 0 7401 NULL
103033 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103034 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103035 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103036 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
103037 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
103038 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
103039 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
103040 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103041 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
103042 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103043 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103044 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
103045 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
103046 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103047 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103048 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
103049 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
103050 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
103051 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
103052 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
103053 +create_dir_7614 create_dir 0 7614 NULL nohasharray
103054 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
103055 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
103056 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
103057 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
103058 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103059 +dev_write_7708 dev_write 3 7708 NULL
103060 +unmap_region_7709 unmap_region 1 7709 NULL
103061 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
103062 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
103063 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103064 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103065 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
103066 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103067 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103068 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
103069 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
103070 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
103071 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103072 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
103073 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
103074 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
103075 +config_desc_7878 config_desc 0 7878 NULL
103076 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103077 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103078 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103079 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103080 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103081 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
103082 +compare_refs_7938 compare_refs 0 7938 NULL
103083 +fsnotify_7943 fsnotify 0 7943 NULL
103084 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103085 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103086 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103087 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
103088 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
103089 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
103090 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103091 +vcs_read_8017 vcs_read 3 8017 NULL
103092 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103093 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103094 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103095 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103096 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
103097 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103098 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103099 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
103100 +venus_lookup_8121 venus_lookup 4 8121 NULL
103101 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103102 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
103103 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
103104 +ore_truncate_8181 ore_truncate 3 8181 NULL
103105 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103106 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103107 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
103108 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103109 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
103110 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103111 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103112 +play_iframe_8219 play_iframe 3 8219 NULL
103113 +create_log_8225 create_log 2 8225 NULL nohasharray
103114 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103115 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103116 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103117 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103118 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103119 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103120 +init_cdev_8274 init_cdev 1 8274 NULL
103121 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103122 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103123 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
103124 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103125 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103126 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103127 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103128 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
103129 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
103130 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
103131 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
103132 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103133 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103134 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103135 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103136 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103137 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
103138 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
103139 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
103140 +dir_changed_8471 dir_changed 0 8471 NULL
103141 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103142 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
103143 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103144 +dev_config_8506 dev_config 3 8506 NULL
103145 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103146 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103147 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103148 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103149 +user_on_off_8552 user_on_off 2 8552 NULL
103150 +profile_remove_8556 profile_remove 3 8556 NULL
103151 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
103152 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103153 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103154 +tower_write_8580 tower_write 3 8580 NULL
103155 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
103156 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
103157 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103158 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
103159 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103160 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103161 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103162 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103163 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
103164 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103165 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103166 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103167 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103168 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103169 +arcfb_write_8702 arcfb_write 3 8702 NULL
103170 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103171 +init_header_8703 init_header 0 8703 &i_size_read_8703
103172 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
103173 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
103174 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
103175 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
103176 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103177 +f_dupfd_8730 f_dupfd 1 8730 NULL
103178 +__create_irqs_8733 __create_irqs 2-1-0 8733 NULL
103179 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103180 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103181 +compound_order_8750 compound_order 0 8750 NULL
103182 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
103183 +yurex_write_8761 yurex_write 3 8761 NULL
103184 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103185 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
103186 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
103187 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103188 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103189 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
103190 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103191 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103192 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
103193 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103194 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
103195 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
103196 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103197 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103198 +clear_bitset_8840 clear_bitset 2 8840 NULL
103199 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103200 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103201 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
103202 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103203 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
103204 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
103205 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
103206 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103207 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
103208 +write_file_ani_8918 write_file_ani 3 8918 NULL
103209 +layout_commit_8926 layout_commit 3 8926 NULL
103210 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103211 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103212 +lookup_zone_8956 lookup_zone 2 8956 NULL
103213 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103214 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103215 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103216 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103217 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103218 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
103219 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
103220 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103221 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
103222 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
103223 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
103224 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103225 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
103226 +nla_put_9042 nla_put 3 9042 NULL
103227 +offset_il_node_9059 offset_il_node 0 9059 NULL
103228 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
103229 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
103230 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
103231 +create_queues_9088 create_queues 3-2 9088 NULL
103232 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
103233 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
103234 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
103235 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
103236 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
103237 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
103238 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
103239 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
103240 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
103241 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
103242 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
103243 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
103244 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
103245 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
103246 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
103247 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
103248 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
103249 +get_pfn_9207 get_pfn 1 9207 NULL
103250 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
103251 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
103252 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
103253 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
103254 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
103255 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
103256 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
103257 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
103258 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
103259 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
103260 +flakey_status_9274 flakey_status 5 9274 NULL
103261 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
103262 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
103263 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
103264 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
103265 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
103266 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
103267 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
103268 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
103269 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
103270 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
103271 +read_9397 read 3 9397 NULL
103272 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
103273 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
103274 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
103275 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
103276 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
103277 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
103278 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
103279 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
103280 +crypt_status_9492 crypt_status 5 9492 NULL
103281 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
103282 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
103283 +lp_write_9511 lp_write 3 9511 NULL
103284 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
103285 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
103286 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
103287 +read_file_dma_9530 read_file_dma 3 9530 NULL
103288 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
103289 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
103290 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 NULL
103291 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
103292 +readl_9557 readl 0 9557 NULL
103293 +fw_node_create_9559 fw_node_create 2 9559 NULL
103294 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
103295 +kobj_map_9566 kobj_map 3-2 9566 NULL
103296 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
103297 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
103298 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
103299 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
103300 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
103301 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
103302 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
103303 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
103304 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
103305 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
103306 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
103307 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
103308 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
103309 +dns_query_9676 dns_query 3 9676 NULL
103310 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
103311 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
103312 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
103313 +fnb_9703 fnb 2-3-0 9703 NULL
103314 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
103315 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
103316 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
103317 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
103318 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
103319 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
103320 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
103321 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
103322 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
103323 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
103324 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
103325 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
103326 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
103327 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
103328 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
103329 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
103330 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
103331 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
103332 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
103333 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
103334 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
103335 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
103336 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
103337 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
103338 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
103339 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
103340 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
103341 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
103342 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
103343 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
103344 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
103345 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
103346 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
103347 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
103348 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
103349 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
103350 +read_file_misc_9948 read_file_misc 3 9948 NULL
103351 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
103352 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
103353 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
103354 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
103355 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
103356 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
103357 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
103358 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
103359 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
103360 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
103361 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
103362 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
103363 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
103364 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
103365 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
103366 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
103367 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
103368 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
103369 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
103370 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
103371 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
103372 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
103373 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
103374 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
103375 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
103376 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
103377 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
103378 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
103379 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
103380 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
103381 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
103382 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
103383 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
103384 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
103385 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
103386 +read_emulate_10310 read_emulate 2-4 10310 NULL
103387 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
103388 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
103389 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
103390 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
103391 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
103392 +get_dump_page_10338 get_dump_page 1 10338 NULL
103393 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
103394 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
103395 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
103396 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
103397 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
103398 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
103399 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
103400 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
103401 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
103402 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
103403 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
103404 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
103405 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
103406 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
103407 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
103408 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
103409 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
103410 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
103411 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
103412 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
103413 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
103414 +SYSC_read_10545 SYSC_read 3 10545 NULL
103415 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
103416 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
103417 +otp_read_10594 otp_read 5-4-2 10594 NULL
103418 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
103419 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
103420 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
103421 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
103422 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
103423 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
103424 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
103425 +parport_write_10669 parport_write 0 10669 NULL
103426 +edge_write_10692 edge_write 4 10692 NULL
103427 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
103428 +inl_10708 inl 0 10708 NULL nohasharray
103429 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
103430 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
103431 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
103432 +spi_sync_10731 spi_sync 0 10731 NULL
103433 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
103434 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
103435 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
103436 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
103437 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
103438 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
103439 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
103440 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
103441 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
103442 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
103443 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
103444 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
103445 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103446 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
103447 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103448 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103449 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103450 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
103451 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
103452 +get_scq_10897 get_scq 2 10897 NULL
103453 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103454 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103455 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
103456 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
103457 +kobject_add_10919 kobject_add 0 10919 NULL
103458 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103459 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103460 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103461 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103462 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103463 +lz4_compress_10986 lz4_compress 2 10986 NULL
103464 +do_switch_10994 do_switch 0 10994 NULL
103465 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103466 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
103467 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103468 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103469 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
103470 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
103471 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103472 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
103473 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103474 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
103475 +count_argc_11083 count_argc 0 11083 NULL
103476 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103477 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103478 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103479 +page_offset_11120 page_offset 0 11120 NULL
103480 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103481 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103482 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
103483 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
103484 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
103485 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103486 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
103487 +mmap_region_11247 mmap_region 0-2 11247 NULL
103488 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103489 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103490 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103491 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
103492 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
103493 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
103494 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103495 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
103496 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
103497 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
103498 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103499 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103500 +next_segment_11330 next_segment 0-2-1 11330 NULL
103501 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
103502 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103503 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
103504 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
103505 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103506 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103507 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103508 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103509 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
103510 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
103511 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
103512 +str_to_user_11411 str_to_user 2 11411 NULL
103513 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103514 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103515 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
103516 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103517 +trace_options_read_11419 trace_options_read 3 11419 NULL
103518 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
103519 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
103520 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
103521 +prepare_image_11424 prepare_image 0 11424 NULL
103522 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
103523 +bttv_read_11432 bttv_read 3 11432 NULL
103524 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103525 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
103526 +swp_offset_11475 swp_offset 0 11475 NULL
103527 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
103528 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
103529 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
103530 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103531 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103532 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103533 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
103534 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103535 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103536 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
103537 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
103538 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
103539 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
103540 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
103541 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103542 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103543 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103544 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
103545 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103546 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
103547 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103548 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103549 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103550 +slab_ksize_11664 slab_ksize 0 11664 NULL
103551 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
103552 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103553 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
103554 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103555 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103556 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103557 +split_11691 split 2 11691 NULL
103558 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103559 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103560 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103561 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103562 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
103563 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
103564 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103565 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103566 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103567 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
103568 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
103569 +umc_device_register_11824 umc_device_register 0 11824 NULL
103570 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103571 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103572 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103573 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103574 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103575 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103576 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
103577 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
103578 +ti_write_11916 ti_write 4 11916 NULL
103579 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103580 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103581 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103582 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
103583 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103584 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
103585 +split_node_11976 split_node 0 11976 &usc_InReg_11976
103586 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
103587 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103588 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
103589 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
103590 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103591 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
103592 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103593 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103594 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103595 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103596 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103597 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
103598 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
103599 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
103600 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103601 +set_powered_12129 set_powered 4 12129 NULL
103602 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103603 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103604 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103605 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103606 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
103607 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103608 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103609 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
103610 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103611 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103612 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
103613 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103614 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103615 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103616 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
103617 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103618 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103619 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103620 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
103621 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
103622 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103623 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103624 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103625 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103626 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
103627 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
103628 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103629 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
103630 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103631 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
103632 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103633 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103634 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103635 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103636 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
103637 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
103638 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
103639 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
103640 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103641 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103642 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
103643 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103644 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103645 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103646 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103647 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
103648 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103649 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103650 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
103651 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103652 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103653 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103654 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
103655 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103656 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
103657 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
103658 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103659 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103660 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103661 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
103662 +wb_create_12651 wb_create 1 12651 NULL
103663 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
103664 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103665 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103666 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103667 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
103668 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
103669 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
103670 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103671 +ivtv_write_12721 ivtv_write 3 12721 NULL
103672 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103673 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103674 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
103675 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103676 +listxattr_12769 listxattr 3 12769 NULL
103677 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103678 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
103679 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103680 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103681 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
103682 +readq_12825 readq 0 12825 NULL
103683 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
103684 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103685 +spidev_sync_12842 spidev_sync 0 12842 NULL
103686 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103687 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103688 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103689 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103690 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103691 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
103692 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103693 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
103694 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103695 +bm_status_write_12964 bm_status_write 3 12964 NULL
103696 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103697 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103698 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103699 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103700 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
103701 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103702 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
103703 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103704 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
103705 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
103706 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103707 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
103708 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103709 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103710 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
103711 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
103712 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
103713 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103714 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103715 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103716 +blk_update_request_13146 blk_update_request 3 13146 NULL
103717 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103718 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103719 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103720 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103721 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103722 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103723 +comedi_read_13199 comedi_read 3 13199 NULL
103724 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103725 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103726 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
103727 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103728 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103729 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103730 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
103731 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103732 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103733 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
103734 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103735 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103736 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103737 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103738 +sd_major_13294 sd_major 0-1 13294 NULL
103739 +kempld_read16_13297 kempld_read16 0 13297 NULL
103740 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103741 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103742 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103743 +get_bits_13353 get_bits 0-2 13353 NULL
103744 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
103745 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103746 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103747 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
103748 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
103749 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
103750 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
103751 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
103752 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103753 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
103754 +keyring_read_13438 keyring_read 3 13438 NULL
103755 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
103756 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103757 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
103758 +data_read_13494 data_read 3 13494 NULL
103759 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
103760 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
103761 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
103762 +core_status_13515 core_status 4 13515 NULL
103763 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103764 +bm_init_13529 bm_init 2 13529 NULL
103765 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
103766 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
103767 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
103768 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
103769 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
103770 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103771 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103772 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103773 +cache_write_13589 cache_write 3 13589 NULL
103774 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
103775 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103776 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103777 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103778 +packet_snd_13634 packet_snd 3 13634 NULL
103779 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103780 +cache_downcall_13666 cache_downcall 3 13666 NULL
103781 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
103782 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
103783 +usb_get_string_13693 usb_get_string 0 13693 NULL
103784 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
103785 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103786 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
103787 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103788 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103789 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103790 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103791 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103792 +random_read_13815 random_read 3 13815 NULL
103793 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
103794 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103795 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103796 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
103797 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
103798 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
103799 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
103800 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
103801 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
103802 +window_alignment_13895 window_alignment 0 13895 NULL
103803 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103804 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
103805 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
103806 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103807 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103808 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103809 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103810 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103811 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
103812 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103813 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
103814 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
103815 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103816 +qcam_read_13977 qcam_read 3 13977 NULL
103817 +dsp_read_13980 dsp_read 2 13980 NULL
103818 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103819 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103820 +create_files_14003 create_files 0 14003 NULL
103821 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
103822 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103823 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103824 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103825 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103826 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103827 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103828 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103829 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
103830 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
103831 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103832 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103833 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
103834 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
103835 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
103836 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
103837 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103838 +em_canid_change_14150 em_canid_change 3 14150 NULL
103839 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103840 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103841 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
103842 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103843 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
103844 +do_splice_14196 do_splice 5 14196 NULL
103845 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
103846 +alloc_async_14208 alloc_async 1 14208 NULL
103847 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
103848 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103849 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
103850 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103851 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
103852 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
103853 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
103854 +rr_status_14293 rr_status 5 14293 NULL
103855 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103856 +__readl_14308 __readl 0 14308 NULL
103857 +send_chown_14309 send_chown 0 14309 NULL
103858 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
103859 +oo_objects_14319 oo_objects 0 14319 NULL
103860 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
103861 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
103862 +down_write_failed_14331 down_write_failed 2 14331 NULL
103863 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103864 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
103865 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103866 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
103867 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103868 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103869 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103870 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
103871 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103872 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103873 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
103874 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103875 +block_size_14443 block_size 0 14443 NULL
103876 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
103877 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103878 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
103879 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
103880 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103881 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
103882 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
103883 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103884 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
103885 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 &ep0_write_14536
103886 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
103887 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103888 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103889 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103890 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103891 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103892 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103893 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103894 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
103895 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103896 +dbJoin_14644 dbJoin 0 14644 NULL
103897 +profile_replace_14652 profile_replace 3 14652 NULL
103898 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
103899 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
103900 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
103901 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103902 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103903 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103904 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103905 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103906 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
103907 +cgroup_path_14713 cgroup_path 3 14713 NULL
103908 +get_bio_block_14714 get_bio_block 0 14714 NULL
103909 +vfd_write_14717 vfd_write 3 14717 NULL
103910 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
103911 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103912 +raid1_resize_14740 raid1_resize 2 14740 NULL
103913 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
103914 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103915 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103916 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103917 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103918 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
103919 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103920 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
103921 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103922 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103923 +changed_cb_14819 changed_cb 0 14819 NULL
103924 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103925 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103926 +lcd_write_14857 lcd_write 3 14857 NULL
103927 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103928 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
103929 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103930 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103931 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
103932 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103933 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
103934 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103935 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
103936 +queue_cnt_14951 queue_cnt 0 14951 NULL
103937 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
103938 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
103939 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103940 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103941 +setkey_14987 setkey 3 14987 NULL nohasharray
103942 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103943 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103944 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103945 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
103946 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103947 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103948 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103949 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
103950 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
103951 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
103952 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
103953 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103954 +start_port_15124 start_port 0 15124 NULL
103955 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103956 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
103957 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103958 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103959 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103960 +reserve_resources_15194 reserve_resources 3 15194 NULL
103961 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
103962 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103963 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
103964 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103965 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103966 +simple_strtol_15273 simple_strtol 0 15273 NULL
103967 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
103968 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103969 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103970 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
103971 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
103972 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
103973 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
103974 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103975 +ioread16_15342 ioread16 0 15342 NULL
103976 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
103977 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103978 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
103979 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
103980 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103981 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103982 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103983 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103984 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103985 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103986 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103987 +get_modalias_15406 get_modalias 2 15406 NULL
103988 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
103989 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103990 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
103991 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
103992 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103993 +memweight_15450 memweight 2 15450 NULL
103994 +vmalloc_15464 vmalloc 1 15464 NULL
103995 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
103996 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
103997 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103998 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
103999 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104000 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104001 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
104002 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
104003 +persistent_status_15574 persistent_status 4 15574 NULL
104004 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104005 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
104006 +vme_user_write_15587 vme_user_write 3 15587 NULL
104007 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
104008 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104009 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104010 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104011 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104012 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
104013 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104014 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104015 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
104016 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
104017 +xsd_read_15653 xsd_read 3 15653 NULL
104018 +unix_bind_15668 unix_bind 3 15668 NULL
104019 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
104020 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
104021 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104022 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL
104023 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
104024 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
104025 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104026 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
104027 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
104028 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
104029 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104030 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
104031 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104032 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
104033 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104034 +table_size_15851 table_size 0-1-2 15851 NULL
104035 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
104036 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104037 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104038 +profile_pc_15887 profile_pc 0 15887 NULL
104039 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104040 +native_read_msr_15905 native_read_msr 0 15905 NULL
104041 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104042 +power_read_15939 power_read 3 15939 NULL
104043 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104044 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
104045 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
104046 +frame_alloc_15981 frame_alloc 4 15981 NULL
104047 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104048 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104049 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
104050 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
104051 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104052 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
104053 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
104054 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104055 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104056 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104057 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104058 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104059 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104060 +fsm_init_16134 fsm_init 2 16134 NULL
104061 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104062 +update_block_group_16155 update_block_group 0 16155 NULL
104063 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
104064 +mapping_level_16188 mapping_level 2 16188 NULL
104065 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
104066 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
104067 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
104068 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104069 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104070 +create_table_16213 create_table 2 16213 NULL
104071 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104072 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104073 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
104074 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
104075 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
104076 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
104077 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
104078 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104079 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104080 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104081 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104082 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
104083 +account_16283 account 0-4-2 16283 NULL nohasharray
104084 +mirror_status_16283 mirror_status 5 16283 &account_16283
104085 +retry_instruction_16285 retry_instruction 2 16285 NULL
104086 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
104087 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
104088 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104089 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104090 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104091 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104092 +wb_map_16301 wb_map 2 16301 NULL
104093 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
104094 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104095 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104096 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
104097 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
104098 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104099 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104100 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104101 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104102 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104103 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
104104 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0 16452 NULL
104105 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
104106 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104107 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
104108 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
104109 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
104110 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104111 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
104112 +start_this_handle_16519 start_this_handle 0 16519 NULL
104113 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104114 +raid10_resize_16537 raid10_resize 2 16537 NULL
104115 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104116 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
104117 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104118 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
104119 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
104120 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
104121 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
104122 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104123 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
104124 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
104125 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104126 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
104127 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
104128 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
104129 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104130 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104131 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104132 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104133 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104134 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104135 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104136 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104137 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104138 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104139 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104140 +st_write_16874 st_write 3 16874 NULL
104141 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104142 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
104143 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
104144 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104145 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104146 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
104147 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104148 +wrm_16966 wrm 0 16966 NULL
104149 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104150 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
104151 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104152 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
104153 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104154 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
104155 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104156 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104157 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
104158 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
104159 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104160 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104161 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104162 +entry_length_17093 entry_length 0 17093 NULL
104163 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
104164 +write_mem_17114 write_mem 3 17114 NULL
104165 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104166 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
104167 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104168 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
104169 +sep_read_17161 sep_read 3 17161 NULL
104170 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104171 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104172 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104173 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
104174 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
104175 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
104176 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104177 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104178 +sync_request_17208 sync_request 2 17208 NULL
104179 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104180 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
104181 +to_oblock_17254 to_oblock 0-1 17254 NULL
104182 +unpack_value_17259 unpack_value 1 17259 NULL
104183 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
104184 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104185 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
104186 +alloc_ep_17269 alloc_ep 1 17269 NULL
104187 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
104188 +pg_read_17276 pg_read 3 17276 NULL
104189 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104190 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104191 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104192 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104193 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104194 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104195 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104196 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104197 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
104198 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104199 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104200 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
104201 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104202 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
104203 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104204 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104205 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
104206 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104207 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104208 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104209 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104210 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
104211 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
104212 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
104213 +qp_free_res_17541 qp_free_res 5 17541 NULL
104214 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
104215 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
104216 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
104217 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
104218 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
104219 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
104220 +__inode_info_17603 __inode_info 0 17603 NULL
104221 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
104222 +osst_execute_17607 osst_execute 7-6 17607 NULL
104223 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
104224 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
104225 +dma_map_page_17628 dma_map_page 0 17628 NULL
104226 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
104227 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
104228 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
104229 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
104230 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
104231 +kernel_write_17665 kernel_write 3 17665 NULL
104232 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
104233 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
104234 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
104235 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
104236 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
104237 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
104238 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
104239 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
104240 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
104241 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
104242 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
104243 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
104244 +perf_clock_17787 perf_clock 0 17787 NULL
104245 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
104246 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
104247 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
104248 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
104249 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104250 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104251 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104252 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
104253 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104254 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104255 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104256 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
104257 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
104258 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104259 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104260 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104261 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
104262 +recover_head_17904 recover_head 3 17904 NULL
104263 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
104264 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
104265 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
104266 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
104267 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
104268 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
104269 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
104270 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
104271 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
104272 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
104273 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
104274 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
104275 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
104276 +fill_read_18019 fill_read 0 18019 NULL
104277 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
104278 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
104279 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
104280 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
104281 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
104282 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
104283 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
104284 +fpregs_get_18066 fpregs_get 4 18066 NULL
104285 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
104286 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
104287 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
104288 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
104289 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
104290 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
104291 +svc_getnl_18120 svc_getnl 0 18120 NULL
104292 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
104293 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
104294 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
104295 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
104296 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
104297 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
104298 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
104299 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
104300 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
104301 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
104302 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
104303 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
104304 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
104305 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
104306 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
104307 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
104308 +alloc_ring_18278 alloc_ring 4-2 18278 NULL
104309 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
104310 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
104311 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
104312 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
104313 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
104314 +um_idi_write_18293 um_idi_write 3 18293 NULL
104315 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
104316 +vga_r_18310 vga_r 0 18310 NULL
104317 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
104318 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
104319 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
104320 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
104321 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
104322 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
104323 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
104324 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
104325 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
104326 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
104327 +ep_io_18367 ep_io 0 18367 NULL
104328 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
104329 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
104330 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
104331 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
104332 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
104333 +__video_register_device_18399 __video_register_device 3 18399 NULL
104334 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
104335 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
104336 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
104337 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
104338 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
104339 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
104340 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
104341 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
104342 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
104343 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
104344 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
104345 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
104346 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
104347 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
104348 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
104349 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
104350 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
104351 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
104352 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
104353 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
104354 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
104355 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
104356 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
104357 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
104358 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
104359 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
104360 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
104361 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
104362 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
104363 +debug_output_18575 debug_output 3 18575 NULL
104364 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
104365 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
104366 +numa_node_id_18596 numa_node_id 0 18596 NULL
104367 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
104368 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
104369 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
104370 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
104371 +from_buffer_18625 from_buffer 3 18625 NULL
104372 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
104373 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
104374 +unmap_page_18665 unmap_page 2-3 18665 NULL
104375 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
104376 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
104377 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
104378 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
104379 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
104380 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
104381 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
104382 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
104383 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
104384 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
104385 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
104386 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
104387 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
104388 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
104389 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
104390 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
104391 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
104392 +prealloc_18800 prealloc 0 18800 NULL
104393 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
104394 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
104395 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
104396 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
104397 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
104398 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
104399 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
104400 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
104401 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
104402 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
104403 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
104404 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
104405 +overwrite_item_18896 overwrite_item 0 18896 NULL
104406 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
104407 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
104408 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
104409 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
104410 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
104411 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
104412 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
104413 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
104414 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
104415 +get_inode_path_18988 get_inode_path 0 18988 NULL
104416 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
104417 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
104418 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
104419 +huge_page_size_19008 huge_page_size 0 19008 NULL
104420 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
104421 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
104422 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
104423 +revalidate_19043 revalidate 2 19043 NULL
104424 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
104425 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
104426 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
104427 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
104428 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
104429 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
104430 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
104431 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
104432 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
104433 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
104434 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
104435 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
104436 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
104437 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
104438 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
104439 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
104440 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
104441 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
104442 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
104443 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
104444 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
104445 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
104446 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
104447 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
104448 +ucma_query_19260 ucma_query 4 19260 NULL
104449 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
104450 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
104451 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
104452 +qc_capture_19298 qc_capture 3 19298 NULL
104453 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
104454 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
104455 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
104456 +debug_read_19322 debug_read 3 19322 NULL
104457 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
104458 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
104459 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
104460 +closure_sub_19359 closure_sub 2 19359 NULL
104461 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
104462 +read_zero_19366 read_zero 3 19366 NULL
104463 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
104464 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
104465 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
104466 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
104467 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
104468 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
104469 +__phys_addr_19434 __phys_addr 0 19434 NULL
104470 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
104471 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
104472 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
104473 +sky2_read16_19475 sky2_read16 0 19475 NULL
104474 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
104475 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
104476 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
104477 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
104478 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
104479 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
104480 +howmany_64_19548 howmany_64 2 19548 NULL
104481 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
104482 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
104483 +kernel_read_19559 kernel_read 4-0 19559 NULL
104484 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
104485 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
104486 +nfsd_read_19568 nfsd_read 5 19568 NULL
104487 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
104488 +bm_status_read_19583 bm_status_read 3 19583 NULL
104489 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
104490 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
104491 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
104492 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
104493 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
104494 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
104495 +bio_detain_19690 bio_detain 2 19690 NULL
104496 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
104497 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
104498 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
104499 +read_reg_19723 read_reg 0 19723 NULL
104500 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
104501 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
104502 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
104503 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
104504 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
104505 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
104506 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
104507 +readhscx_19769 readhscx 0 19769 NULL
104508 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
104509 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
104510 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
104511 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
104512 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
104513 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
104514 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
104515 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
104516 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
104517 +__nla_put_19857 __nla_put 3 19857 NULL
104518 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
104519 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
104520 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
104521 +mangle_name_19923 mangle_name 0 19923 NULL
104522 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
104523 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
104524 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
104525 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
104526 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
104527 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
104528 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
104529 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
104530 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
104531 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
104532 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
104533 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
104534 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
104535 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
104536 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
104537 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
104538 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
104539 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
104540 +target_message_20072 target_message 2 20072 NULL
104541 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
104542 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
104543 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
104544 +team_options_register_20091 team_options_register 3 20091 NULL
104545 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
104546 +read_int_20098 read_int 0 20098 NULL
104547 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
104548 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
104549 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
104550 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
104551 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
104552 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
104553 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
104554 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
104555 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
104556 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
104557 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
104558 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
104559 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
104560 +resource_size_20256 resource_size 0 20256 NULL
104561 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
104562 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
104563 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
104564 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
104565 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
104566 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
104567 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
104568 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
104569 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
104570 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
104571 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
104572 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
104573 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
104574 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
104575 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
104576 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
104577 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
104578 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
104579 +read_buf_20469 read_buf 2 20469 NULL
104580 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
104581 +fast_user_write_20494 fast_user_write 5 20494 NULL
104582 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
104583 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
104584 +link_free_space_20512 link_free_space 0 20512 NULL
104585 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
104586 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
104587 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
104588 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
104589 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
104590 +venus_create_20555 venus_create 4 20555 NULL
104591 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
104592 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
104593 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
104594 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
104595 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
104596 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
104597 +lirc_write_20604 lirc_write 3 20604 NULL
104598 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
104599 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
104600 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
104601 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
104602 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
104603 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
104604 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
104605 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL nohasharray
104606 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 &snd_hdsp_playback_copy_20676
104607 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
104608 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
104609 +cpumask_size_20683 cpumask_size 0 20683 NULL
104610 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
104611 +gru_vtop_20689 gru_vtop 2 20689 NULL
104612 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
104613 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
104614 +__maestro_read_20700 __maestro_read 0 20700 NULL
104615 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
104616 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
104617 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
104618 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
104619 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
104620 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
104621 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
104622 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
104623 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
104624 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
104625 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
104626 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
104627 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
104628 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
104629 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
104630 +strndup_user_20819 strndup_user 2 20819 NULL
104631 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
104632 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
104633 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
104634 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
104635 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
104636 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
104637 +get_name_20855 get_name 4 20855 NULL
104638 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
104639 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
104640 +srq_free_res_20868 srq_free_res 5 20868 NULL
104641 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
104642 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
104643 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
104644 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
104645 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
104646 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
104647 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
104648 +htable_bits_20933 htable_bits 0 20933 NULL
104649 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
104650 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104651 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104652 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
104653 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104654 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104655 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104656 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
104657 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
104658 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104659 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104660 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104661 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
104662 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104663 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
104664 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
104665 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104666 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
104667 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
104668 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104669 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104670 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104671 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104672 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104673 +chunk_size_21146 chunk_size 0 21146 NULL
104674 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104675 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104676 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
104677 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104678 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104679 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104680 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
104681 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104682 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
104683 +input_ff_create_21240 input_ff_create 2 21240 NULL
104684 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104685 +fru_length_21257 fru_length 0 21257 NULL
104686 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
104687 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104688 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104689 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104690 +add_res_range_21310 add_res_range 4 21310 NULL
104691 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104692 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104693 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104694 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104695 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104696 +split_leaf_21378 split_leaf 0 21378 NULL
104697 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104698 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104699 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104700 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104701 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104702 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104703 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104704 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104705 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104706 +ReadISAR_21453 ReadISAR 0 21453 NULL
104707 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104708 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104709 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104710 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
104711 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104712 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104713 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104714 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104715 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104716 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104717 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
104718 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104719 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
104720 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
104721 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
104722 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
104723 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104724 +validate_nnode_21638 validate_nnode 0 21638 NULL
104725 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3 21639 NULL
104726 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
104727 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104728 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104729 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
104730 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104731 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
104732 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
104733 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
104734 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
104735 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
104736 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
104737 +vm_brk_21739 vm_brk 1-2 21739 NULL
104738 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104739 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
104740 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104741 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
104742 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
104743 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104744 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104745 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
104746 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104747 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104748 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
104749 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104750 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104751 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
104752 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
104753 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
104754 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104755 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104756 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104757 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
104758 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
104759 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104760 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104761 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104762 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104763 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
104764 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104765 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104766 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
104767 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104768 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104769 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
104770 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104771 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
104772 +write_opcode_22082 write_opcode 2 22082 NULL
104773 +mem_rw_22085 mem_rw 3 22085 NULL
104774 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
104775 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104776 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
104777 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
104778 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
104779 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
104780 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104781 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
104782 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
104783 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
104784 +fls_22210 fls 0 22210 NULL
104785 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
104786 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
104787 +mem_write_22232 mem_write 3 22232 NULL
104788 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104789 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
104790 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104791 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104792 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
104793 +add_res_tree_22263 add_res_tree 7 22263 NULL
104794 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104795 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104796 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
104797 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104798 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104799 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104800 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
104801 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
104802 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
104803 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
104804 +atomic_read_22342 atomic_read 0 22342 NULL
104805 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
104806 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104807 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104808 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104809 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104810 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104811 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104812 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
104813 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
104814 +zoran_write_22404 zoran_write 3 22404 NULL
104815 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
104816 +queue_reply_22416 queue_reply 3 22416 NULL
104817 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104818 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104819 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
104820 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104821 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104822 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
104823 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
104824 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
104825 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
104826 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
104827 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
104828 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
104829 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
104830 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
104831 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
104832 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
104833 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
104834 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
104835 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
104836 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
104837 +snapshot_read_22601 snapshot_read 3 22601 NULL
104838 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
104839 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
104840 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
104841 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
104842 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
104843 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
104844 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
104845 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
104846 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
104847 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
104848 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
104849 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
104850 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
104851 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
104852 +reg_umr_22686 reg_umr 5 22686 NULL
104853 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
104854 +map_22700 map 2 22700 NULL nohasharray
104855 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
104856 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
104857 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
104858 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
104859 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
104860 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
104861 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
104862 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
104863 +print_frame_22769 print_frame 0 22769 NULL
104864 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
104865 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
104866 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
104867 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
104868 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
104869 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
104870 +create_attr_set_22861 create_attr_set 1 22861 NULL
104871 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
104872 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
104873 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
104874 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
104875 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
104876 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
104877 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
104878 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
104879 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
104880 +vme_get_size_22964 vme_get_size 0 22964 NULL
104881 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
104882 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
104883 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
104884 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
104885 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
104886 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
104887 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
104888 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
104889 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
104890 +st_status_23032 st_status 5 23032 NULL
104891 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
104892 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
104893 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
104894 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
104895 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
104896 +filp_close_23071 filp_close 0 23071 NULL
104897 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
104898 +raw_sendmsg_23078 raw_sendmsg 4 23078 NULL
104899 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
104900 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
104901 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
104902 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
104903 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
104904 +fls_long_23096 fls_long 0 23096 NULL
104905 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
104906 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
104907 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
104908 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
104909 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
104910 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
104911 +__clear_user_23118 __clear_user 0-2 23118 NULL
104912 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
104913 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
104914 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
104915 +read_file_ani_23161 read_file_ani 3 23161 NULL
104916 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
104917 +usblp_write_23178 usblp_write 3 23178 NULL
104918 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
104919 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
104920 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
104921 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
104922 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
104923 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
104924 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
104925 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
104926 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
104927 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
104928 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
104929 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
104930 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
104931 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
104932 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
104933 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
104934 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
104935 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
104936 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
104937 +page_readlink_23346 page_readlink 3 23346 NULL
104938 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
104939 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
104940 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
104941 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
104942 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
104943 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
104944 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
104945 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
104946 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
104947 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
104948 +linear_conf_23485 linear_conf 2 23485 NULL
104949 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
104950 +event_filter_read_23494 event_filter_read 3 23494 NULL
104951 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
104952 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
104953 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
104954 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
104955 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
104956 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
104957 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
104958 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
104959 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
104960 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
104961 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
104962 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
104963 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
104964 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
104965 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
104966 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
104967 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
104968 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
104969 +alloc_pte_23642 alloc_pte 3 23642 NULL
104970 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
104971 +sInW_23663 sInW 0 23663 NULL
104972 +SyS_connect_23669 SyS_connect 3 23669 NULL
104973 +cx18_read_23699 cx18_read 3 23699 NULL
104974 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
104975 +at_get_23708 at_get 0 23708 NULL
104976 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
104977 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
104978 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
104979 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
104980 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
104981 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
104982 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
104983 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
104984 +map_write_23795 map_write 3 23795 NULL
104985 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
104986 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
104987 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
104988 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
104989 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
104990 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
104991 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
104992 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
104993 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
104994 +p54_init_common_23850 p54_init_common 1 23850 NULL
104995 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
104996 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
104997 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
104998 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
104999 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105000 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
105001 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
105002 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
105003 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105004 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105005 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
105006 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105007 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105008 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105009 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
105010 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
105011 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105012 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105013 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
105014 +vfs_write_23971 vfs_write 0-3 23971 NULL
105015 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
105016 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105017 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105018 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
105019 +give_pages_24021 give_pages 3 24021 NULL
105020 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105021 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105022 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
105023 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105024 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105025 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105026 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
105027 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105028 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105029 +lov_brw_24122 lov_brw 4 24122 NULL
105030 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
105031 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
105032 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105033 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
105034 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105035 +set_discard_24162 set_discard 2 24162 NULL
105036 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
105037 +adu_read_24177 adu_read 3 24177 NULL
105038 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105039 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
105040 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
105041 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105042 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105043 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
105044 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105045 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
105046 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105047 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105048 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105049 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105050 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105051 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
105052 +thin_status_24278 thin_status 5 24278 NULL
105053 +msg_size_24288 msg_size 0 24288 NULL
105054 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
105055 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
105056 +map_page_24298 map_page 3-4 24298 NULL
105057 +gserial_connect_24302 gserial_connect 0 24302 NULL
105058 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105059 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
105060 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105061 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105062 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105063 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
105064 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105065 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105066 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105067 +igetword_24373 igetword 0 24373 NULL
105068 +max_io_len_24384 max_io_len 0-1 24384 NULL
105069 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
105070 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
105071 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105072 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
105073 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
105074 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105075 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
105076 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105077 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
105078 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
105079 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
105080 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
105081 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
105082 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
105083 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
105084 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105085 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
105086 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
105087 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
105088 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
105089 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105090 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
105091 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
105092 +pd_video_read_24510 pd_video_read 3 24510 NULL
105093 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105094 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105095 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105096 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105097 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
105098 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105099 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
105100 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
105101 +SyS_poll_24620 SyS_poll 2 24620 NULL
105102 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105103 +context_alloc_24645 context_alloc 3 24645 NULL
105104 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105105 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
105106 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
105107 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
105108 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105109 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105110 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105111 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
105112 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105113 +kempld_read8_24756 kempld_read8 0 24756 NULL
105114 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105115 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105116 +cache_read_24790 cache_read 3 24790 NULL
105117 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
105118 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
105119 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
105120 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
105121 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105122 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
105123 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
105124 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105125 +net2272_read_24825 net2272_read 0 24825 NULL
105126 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105127 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
105128 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
105129 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105130 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105131 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105132 +setup_buffering_24872 setup_buffering 3 24872 NULL
105133 +queues_read_24877 queues_read 3 24877 NULL
105134 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
105135 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105136 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
105137 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
105138 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
105139 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105140 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105141 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105142 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105143 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
105144 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105145 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105146 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
105147 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105148 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105149 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
105150 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
105151 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105152 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
105153 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105154 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
105155 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
105156 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
105157 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105158 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
105159 +record_new_ref_25154 record_new_ref 0 25154 NULL
105160 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
105161 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
105162 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
105163 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105164 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
105165 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
105166 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
105167 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105168 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105169 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105170 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
105171 +stripe_status_25259 stripe_status 5 25259 NULL
105172 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105173 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105174 +vfs_writev_25278 vfs_writev 3 25278 NULL
105175 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105176 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
105177 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105178 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105179 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
105180 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105181 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105182 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105183 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
105184 +SyS_splice_25390 SyS_splice 5 25390 NULL
105185 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
105186 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
105187 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105188 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105189 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105190 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
105191 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105192 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105193 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
105194 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
105195 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105196 +sb_permission_25523 sb_permission 0 25523 NULL
105197 +down_read_failed_25532 down_read_failed 2 25532 NULL
105198 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105199 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105200 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
105201 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
105202 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
105203 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
105204 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
105205 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
105206 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
105207 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
105208 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
105209 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
105210 +__direct_map_25647 __direct_map 6-5 25647 NULL
105211 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
105212 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
105213 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
105214 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
105215 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
105216 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
105217 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
105218 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
105219 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
105220 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
105221 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
105222 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
105223 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
105224 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
105225 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
105226 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
105227 +sg_read_25799 sg_read 3 25799 NULL
105228 +system_enable_read_25815 system_enable_read 3 25815 NULL
105229 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
105230 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
105231 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
105232 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
105233 +parport_read_25855 parport_read 0 25855 NULL
105234 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
105235 +key_attr_size_25865 key_attr_size 0 25865 NULL
105236 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
105237 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
105238 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
105239 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
105240 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
105241 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
105242 +rcname_read_25919 rcname_read 3 25919 NULL
105243 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
105244 +key_flags_read_25931 key_flags_read 3 25931 NULL
105245 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
105246 +flush_25957 flush 2 25957 NULL
105247 +video_register_device_25971 video_register_device 3 25971 NULL
105248 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
105249 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
105250 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
105251 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
105252 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
105253 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
105254 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
105255 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
105256 +tun_do_read_26047 tun_do_read 5 26047 NULL
105257 +make_bfloat_26056 make_bfloat 2 26056 NULL
105258 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
105259 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
105260 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
105261 +dup_ref_26100 dup_ref 0 26100 NULL
105262 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
105263 +read_sb_page_26119 read_sb_page 5 26119 NULL
105264 +__fswab64_26155 __fswab64 0 26155 NULL
105265 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
105266 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
105267 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
105268 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
105269 +disk_devt_26180 disk_devt 0 26180 NULL
105270 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
105271 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
105272 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
105273 +mce_write_26201 mce_write 3 26201 NULL
105274 +SyS_splice_26206 SyS_splice 5 26206 NULL
105275 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
105276 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
105277 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
105278 +bio_split_26235 bio_split 2 26235 NULL
105279 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
105280 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
105281 +do_setxattr_26264 do_setxattr 0 26264 NULL
105282 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
105283 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
105284 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
105285 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
105286 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
105287 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
105288 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
105289 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
105290 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
105291 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
105292 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
105293 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
105294 +ntty_write_26404 ntty_write 3 26404 NULL
105295 +pagemap_read_26441 pagemap_read 3 26441 NULL
105296 +tower_read_26461 tower_read 3 26461 NULL nohasharray
105297 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
105298 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
105299 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
105300 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
105301 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
105302 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
105303 +read_vmcore_26501 read_vmcore 3 26501 NULL
105304 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
105305 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
105306 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
105307 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
105308 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
105309 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
105310 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
105311 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
105312 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
105313 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
105314 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
105315 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
105316 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
105317 +pack_value_26625 pack_value 1 26625 NULL
105318 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
105319 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
105320 +process_extent_26646 process_extent 0 26646 NULL nohasharray
105321 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
105322 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
105323 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
105324 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
105325 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
105326 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
105327 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
105328 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
105329 +bos_desc_26752 bos_desc 0 26752 NULL
105330 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
105331 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
105332 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
105333 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
105334 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
105335 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
105336 +smk_write_load_26829 smk_write_load 3 26829 NULL
105337 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
105338 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
105339 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
105340 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
105341 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
105342 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
105343 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
105344 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
105345 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
105346 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
105347 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
105348 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
105349 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
105350 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
105351 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
105352 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
105353 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
105354 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
105355 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
105356 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
105357 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
105358 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
105359 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
105360 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
105361 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
105362 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
105363 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
105364 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
105365 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
105366 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
105367 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
105368 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
105369 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
105370 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
105371 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
105372 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
105373 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
105374 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
105375 +pms_capture_27142 pms_capture 4 27142 NULL
105376 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
105377 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
105378 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
105379 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
105380 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
105381 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
105382 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
105383 +write_kmem_27225 write_kmem 3 27225 NULL
105384 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
105385 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
105386 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
105387 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
105388 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
105389 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
105390 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
105391 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
105392 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
105393 +write_buf_27316 write_buf 0-3 27316 NULL
105394 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
105395 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
105396 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
105397 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
105398 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
105399 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
105400 +seq_read_27411 seq_read 3 27411 NULL
105401 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
105402 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
105403 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
105404 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
105405 +cypress_write_27423 cypress_write 4 27423 NULL
105406 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
105407 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
105408 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
105409 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
105410 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
105411 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
105412 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
105413 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
105414 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
105415 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
105416 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
105417 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
105418 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
105419 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
105420 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
105421 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
105422 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
105423 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
105424 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
105425 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
105426 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
105427 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
105428 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
105429 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
105430 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
105431 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
105432 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
105433 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
105434 +evm_write_key_27715 evm_write_key 3 27715 NULL
105435 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
105436 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
105437 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
105438 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
105439 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
105440 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
105441 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
105442 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
105443 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
105444 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
105445 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
105446 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
105447 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
105448 +init_header_complete_27833 init_header_complete 0 27833 NULL
105449 +read_profile_27859 read_profile 3 27859 NULL
105450 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
105451 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
105452 +process_all_extents_27879 process_all_extents 0 27879 NULL
105453 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
105454 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
105455 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
105456 +bm_find_next_27929 bm_find_next 2 27929 NULL
105457 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
105458 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
105459 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
105460 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
105461 +device_register_27972 device_register 0 27972 NULL nohasharray
105462 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
105463 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
105464 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
105465 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105466 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105467 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
105468 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105469 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
105470 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105471 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105472 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
105473 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
105474 +pool_status_28055 pool_status 5 28055 NULL
105475 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
105476 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105477 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105478 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105479 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105480 +SyS_brk_28096 SyS_brk 1 28096 NULL
105481 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
105482 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
105483 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
105484 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
105485 +video_read_28148 video_read 3 28148 NULL
105486 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
105487 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
105488 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
105489 +vread_28173 vread 0-3 28173 NULL
105490 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
105491 +counter_free_res_28187 counter_free_res 5 28187 NULL
105492 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
105493 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
105494 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
105495 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
105496 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
105497 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
105498 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
105499 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
105500 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
105501 +usemap_size_28281 usemap_size 0 28281 NULL
105502 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
105503 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
105504 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
105505 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
105506 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
105507 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
105508 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
105509 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
105510 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
105511 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
105512 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
105513 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
105514 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
105515 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
105516 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
105517 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
105518 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
105519 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
105520 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
105521 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
105522 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
105523 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
105524 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
105525 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
105526 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
105527 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
105528 +clear_discard_28494 clear_discard 2 28494 NULL
105529 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
105530 +__next_node_28521 __next_node 1-0 28521 NULL
105531 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
105532 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
105533 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
105534 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
105535 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
105536 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
105537 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
105538 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
105539 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
105540 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
105541 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
105542 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
105543 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
105544 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
105545 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
105546 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
105547 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
105548 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
105549 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
105550 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
105551 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
105552 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
105553 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
105554 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
105555 +balance_level_28707 balance_level 0 28707 NULL
105556 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
105557 +spi_execute_28736 spi_execute 5 28736 NULL
105558 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
105559 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
105560 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
105561 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
105562 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
105563 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
105564 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
105565 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
105566 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
105567 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
105568 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
105569 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
105570 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
105571 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
105572 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
105573 +to_cblock_28899 to_cblock 0-1 28899 NULL
105574 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
105575 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
105576 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
105577 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
105578 +push_rx_28939 push_rx 3 28939 NULL
105579 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
105580 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
105581 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
105582 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
105583 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
105584 +bin_uuid_28999 bin_uuid 3 28999 NULL
105585 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
105586 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
105587 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
105588 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
105589 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
105590 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 NULL nohasharray
105591 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 &ProcessGetHostMibs_29049
105592 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
105593 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
105594 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
105595 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
105596 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
105597 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
105598 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
105599 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
105600 +snprintf_29125 snprintf 0 29125 NULL
105601 +iov_shorten_29130 iov_shorten 0 29130 NULL
105602 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
105603 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0 29152 NULL
105604 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
105605 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
105606 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
105607 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
105608 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
105609 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
105610 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
105611 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
105612 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
105613 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
105614 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
105615 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
105616 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
105617 +block_div_29268 block_div 0-1-2 29268 NULL
105618 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
105619 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
105620 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
105621 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
105622 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
105623 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
105624 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
105625 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
105626 +tun_put_user_29337 tun_put_user 5 29337 NULL
105627 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
105628 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
105629 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
105630 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
105631 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
105632 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
105633 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
105634 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
105635 +mempool_create_29437 mempool_create 1 29437 NULL
105636 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
105637 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
105638 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
105639 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
105640 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
105641 +do_register_entry_29478 do_register_entry 4 29478 NULL
105642 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
105643 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
105644 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
105645 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
105646 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
105647 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
105648 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
105649 +vfs_read_29543 vfs_read 0-3 29543 NULL
105650 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
105651 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
105652 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
105653 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
105654 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
105655 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
105656 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
105657 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
105658 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
105659 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
105660 +slots_per_page_29601 slots_per_page 0 29601 NULL
105661 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
105662 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
105663 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
105664 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
105665 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
105666 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
105667 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
105668 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
105669 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
105670 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
105671 +probes_write_29711 probes_write 3 29711 NULL
105672 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
105673 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
105674 +std_nic_write_29752 std_nic_write 3 29752 NULL
105675 +dbAlloc_29794 dbAlloc 0 29794 NULL
105676 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
105677 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
105678 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
105679 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
105680 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
105681 +count_partial_29850 count_partial 0 29850 NULL
105682 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
105683 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
105684 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
105685 +tlv_put_29872 tlv_put 0 29872 NULL
105686 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
105687 +changed_extent_29881 changed_extent 0 29881 NULL
105688 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
105689 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
105690 +write_file_queue_29922 write_file_queue 3 29922 NULL
105691 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
105692 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
105693 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
105694 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
105695 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
105696 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
105697 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
105698 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
105699 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
105700 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
105701 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
105702 +SyS_write_30059 SyS_write 3 30059 NULL
105703 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
105704 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
105705 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
105706 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
105707 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
105708 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
105709 +recv_stream_30138 recv_stream 4 30138 NULL
105710 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
105711 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
105712 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
105713 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
105714 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
105715 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
105716 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
105717 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
105718 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
105719 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
105720 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
105721 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
105722 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
105723 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
105724 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
105725 +compat_readv_30273 compat_readv 3 30273 NULL
105726 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
105727 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
105728 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
105729 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
105730 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
105731 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
105732 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
105733 +i8254_read_30330 i8254_read 0 30330 NULL
105734 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
105735 +resource_from_user_30341 resource_from_user 3 30341 NULL
105736 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
105737 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
105738 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
105739 +inet_getid_30365 inet_getid 2 30365 NULL
105740 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
105741 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
105742 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
105743 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
105744 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
105745 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
105746 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
105747 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
105748 +mq_create_30425 mq_create 1 30425 NULL nohasharray
105749 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
105750 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
105751 +enable_write_30456 enable_write 3 30456 NULL
105752 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
105753 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
105754 +urandom_read_30462 urandom_read 3 30462 NULL
105755 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
105756 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
105757 +send_rmdir_30470 send_rmdir 0 30470 NULL
105758 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
105759 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
105760 +write_head_30481 write_head 4 30481 NULL
105761 +adu_write_30487 adu_write 3 30487 NULL
105762 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
105763 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
105764 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
105765 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
105766 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
105767 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
105768 +set_le_30581 set_le 4 30581 NULL
105769 +from_cblock_30582 from_cblock 0-1 30582 NULL
105770 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
105771 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
105772 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
105773 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
105774 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
105775 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
105776 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
105777 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
105778 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
105779 +agp_remap_30665 agp_remap 2 30665 NULL
105780 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
105781 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
105782 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
105783 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
105784 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
105785 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
105786 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
105787 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
105788 +snapshot_status_30744 snapshot_status 5 30744 NULL
105789 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
105790 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
105791 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
105792 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
105793 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
105794 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
105795 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
105796 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
105797 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
105798 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
105799 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
105800 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
105801 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
105802 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
105803 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
105804 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
105805 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
105806 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
105807 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
105808 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
105809 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
105810 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
105811 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
105812 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
105813 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
105814 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
105815 +depth_read_31112 depth_read 3 31112 NULL
105816 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
105817 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
105818 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
105819 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
105820 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
105821 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
105822 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
105823 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
105824 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
105825 +__read_reg_31216 __read_reg 0 31216 NULL
105826 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
105827 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
105828 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
105829 +cyy_readb_31240 cyy_readb 0 31240 NULL
105830 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
105831 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
105832 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
105833 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
105834 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
105835 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
105836 +command_file_write_31318 command_file_write 3 31318 NULL
105837 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
105838 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
105839 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
105840 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
105841 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
105842 +outlen_write_31358 outlen_write 3 31358 NULL
105843 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
105844 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
105845 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
105846 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
105847 +inb_31388 inb 0 31388 NULL
105848 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
105849 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
105850 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
105851 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
105852 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
105853 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
105854 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
105855 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
105856 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
105857 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
105858 +do_fcntl_31468 do_fcntl 3 31468 NULL
105859 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
105860 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
105861 +alg_setkey_31485 alg_setkey 3 31485 NULL
105862 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
105863 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
105864 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
105865 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
105866 +hidraw_write_31536 hidraw_write 3 31536 NULL
105867 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
105868 +usbvision_read_31555 usbvision_read 3 31555 NULL
105869 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
105870 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
105871 +osst_write_31581 osst_write 3 31581 NULL
105872 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
105873 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
105874 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
105875 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
105876 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
105877 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
105878 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
105879 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
105880 +__lgread_31668 __lgread 4 31668 NULL
105881 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
105882 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
105883 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
105884 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
105885 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
105886 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
105887 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
105888 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
105889 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
105890 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
105891 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
105892 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
105893 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
105894 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
105895 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
105896 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
105897 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
105898 +data_write_31805 data_write 3 31805 NULL
105899 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
105900 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
105901 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
105902 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
105903 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
105904 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
105905 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
105906 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
105907 +xattr_permission_31907 xattr_permission 0 31907 NULL
105908 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
105909 +new_dir_31919 new_dir 3 31919 NULL
105910 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
105911 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
105912 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
105913 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
105914 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
105915 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
105916 +vb2_write_31948 vb2_write 3 31948 NULL
105917 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
105918 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
105919 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
105920 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
105921 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
105922 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
105923 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
105924 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
105925 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
105926 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
105927 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
105928 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
105929 +calc_hmac_32010 calc_hmac 3 32010 NULL
105930 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
105931 +resource_alignment_32020 resource_alignment 0 32020 NULL
105932 +aead_len_32021 aead_len 0 32021 NULL
105933 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
105934 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
105935 +stk_read_32038 stk_read 3 32038 NULL
105936 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
105937 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
105938 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
105939 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
105940 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
105941 +bio_alloc_32095 bio_alloc 2 32095 NULL
105942 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
105943 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
105944 +disk_status_32120 disk_status 4 32120 NULL
105945 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
105946 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
105947 +venus_link_32165 venus_link 5 32165 NULL
105948 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
105949 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
105950 +load_header_32183 load_header 0 32183 NULL
105951 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
105952 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
105953 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
105954 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
105955 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
105956 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
105957 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
105958 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
105959 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
105960 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
105961 +SyS_select_32319 SyS_select 1 32319 NULL
105962 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
105963 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
105964 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
105965 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
105966 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
105967 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
105968 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
105969 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
105970 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
105971 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
105972 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
105973 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
105974 +local_clock_32385 local_clock 0 32385 NULL
105975 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
105976 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
105977 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
105978 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
105979 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
105980 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
105981 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
105982 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
105983 +cache_status_32462 cache_status 5 32462 NULL
105984 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
105985 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
105986 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
105987 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
105988 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
105989 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
105990 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
105991 +disconnect_32521 disconnect 4 32521 NULL
105992 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
105993 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
105994 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
105995 +ilo_read_32531 ilo_read 3 32531 NULL
105996 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
105997 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
105998 +__first_node_32558 __first_node 0 32558 NULL
105999 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106000 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
106001 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106002 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106003 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106004 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106005 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
106006 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106007 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106008 +kvmalloc_32646 kvmalloc 1 32646 NULL
106009 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106010 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
106011 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
106012 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106013 +apei_res_add_32674 apei_res_add 0 32674 NULL
106014 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106015 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
106016 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
106017 +get_arg_page_32746 get_arg_page 2 32746 NULL
106018 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106019 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106020 +begin_cmd_32766 begin_cmd 0 32766 NULL
106021 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
106022 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106023 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
106024 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106025 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106026 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
106027 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106028 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106029 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
106030 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
106031 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106032 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106033 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106034 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106035 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106036 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
106037 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
106038 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
106039 +compat_filldir_32999 compat_filldir 3 32999 NULL
106040 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
106041 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
106042 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106043 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
106044 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
106045 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
106046 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106047 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106048 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106049 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
106050 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
106051 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106052 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106053 +alloc_tio_33077 alloc_tio 3 33077 NULL
106054 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106055 +write_node_33121 write_node 4 33121 NULL
106056 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106057 +__len_within_target_33132 __len_within_target 0 33132 NULL
106058 +SyS_poll_33152 SyS_poll 2 33152 NULL
106059 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106060 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
106061 +pp_read_33210 pp_read 3 33210 NULL
106062 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
106063 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
106064 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
106065 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106066 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106067 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106068 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
106069 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106070 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106071 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
106072 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106073 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
106074 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106075 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106076 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106077 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106078 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106079 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106080 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106081 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
106082 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
106083 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106084 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106085 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106086 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
106087 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106088 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
106089 +message_stats_list_33440 message_stats_list 5 33440 NULL
106090 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106091 +create_entry_33479 create_entry 2 33479 NULL
106092 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106093 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106094 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106095 +res_counter_read_33499 res_counter_read 4 33499 NULL
106096 +fb_read_33506 fb_read 3 33506 NULL
106097 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106098 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106099 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106100 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106101 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106102 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
106103 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
106104 +read_symlink_33572 read_symlink 0 33572 NULL
106105 +count_subheaders_33591 count_subheaders 0 33591 NULL
106106 +scsi_execute_33596 scsi_execute 5 33596 NULL
106107 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106108 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
106109 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106110 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106111 +do_sync_write_33624 do_sync_write 0 33624 NULL
106112 +stride_page_count_33641 stride_page_count 2 33641 NULL
106113 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106114 +inw_p_33668 inw_p 0 33668 NULL
106115 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106116 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106117 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106118 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
106119 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106120 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
106121 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106122 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106123 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
106124 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
106125 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106126 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106127 +hashtab_create_33769 hashtab_create 3 33769 NULL
106128 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
106129 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
106130 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106131 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
106132 +filter_write_33819 filter_write 3 33819 NULL
106133 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106134 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106135 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
106136 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
106137 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106138 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106139 +bin_string_33884 bin_string 3-5 33884 NULL
106140 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106141 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
106142 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106143 +atomic64_add_return_33927 atomic64_add_return 0-1 33927 NULL
106144 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106145 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106146 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
106147 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
106148 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
106149 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
106150 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
106151 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106152 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
106153 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106154 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
106155 +ppp_write_34034 ppp_write 3 34034 NULL
106156 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
106157 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106158 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106159 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106160 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106161 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
106162 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
106163 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
106164 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106165 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106166 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
106167 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106168 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106169 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
106170 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
106171 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106172 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
106173 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106174 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
106175 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
106176 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
106177 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
106178 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106179 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
106180 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106181 +device_private_init_34279 device_private_init 0 34279 NULL
106182 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
106183 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106184 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106185 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
106186 +__insert_34349 __insert 2-3 34349 NULL
106187 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
106188 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
106189 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
106190 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
106191 +ea_read_34378 ea_read 0 34378 NULL
106192 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
106193 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
106194 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
106195 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
106196 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
106197 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
106198 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
106199 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
106200 +security_socket_create_34439 security_socket_create 0 34439 NULL
106201 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
106202 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
106203 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
106204 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
106205 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
106206 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
106207 +SyS_pwritev_34494 SyS_pwritev 3 34494 NULL nohasharray
106208 +__ffs64_34494 __ffs64 1-0 34494 &SyS_pwritev_34494
106209 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
106210 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
106211 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
106212 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 NULL nohasharray
106213 +tracing_stats_read_34537 tracing_stats_read 3 34537 &ext4_fallocate_34537
106214 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
106215 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
106216 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
106217 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
106218 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
106219 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
106220 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
106221 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
106222 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
106223 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
106224 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
106225 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
106226 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL nohasharray
106227 +mtd_write_34609 mtd_write 0 34609 &__jffs2_ref_totlen_34609
106228 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
106229 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
106230 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
106231 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
106232 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
106233 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
106234 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
106235 +port_print_34704 port_print 3 34704 NULL
106236 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
106237 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
106238 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
106239 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
106240 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
106241 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
106242 +device_add_34766 device_add 0 34766 NULL
106243 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
106244 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
106245 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
106246 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
106247 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
106248 +file_page_index_34820 file_page_index 0-2 34820 NULL
106249 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
106250 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
106251 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
106252 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
106253 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
106254 +msg_print_text_34889 msg_print_text 0 34889 NULL
106255 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
106256 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
106257 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
106258 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
106259 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
106260 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
106261 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
106262 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
106263 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
106264 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
106265 +mq_lookup_34990 mq_lookup 2 34990 NULL
106266 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
106267 +schedule_erase_34996 schedule_erase 0 34996 NULL
106268 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
106269 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
106270 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
106271 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
106272 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
106273 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
106274 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
106275 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
106276 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
106277 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
106278 +store_ifalias_35088 store_ifalias 4 35088 NULL
106279 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
106280 +capi_write_35104 capi_write 3 35104 NULL nohasharray
106281 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
106282 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
106283 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
106284 +message_stats_print_35158 message_stats_print 6 35158 NULL
106285 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
106286 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
106287 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
106288 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
106289 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
106290 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
106291 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
106292 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
106293 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
106294 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
106295 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
106296 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
106297 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
106298 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
106299 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
106300 +set_fd_set_35249 set_fd_set 1 35249 NULL
106301 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
106302 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
106303 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
106304 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
106305 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
106306 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
106307 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
106308 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
106309 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
106310 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
106311 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
106312 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
106313 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
106314 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
106315 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
106316 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
106317 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
106318 +read_kmem_35372 read_kmem 3 35372 NULL
106319 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
106320 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
106321 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
106322 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
106323 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
106324 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
106325 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
106326 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
106327 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
106328 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
106329 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
106330 +async_setkey_35521 async_setkey 3 35521 NULL
106331 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
106332 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
106333 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
106334 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
106335 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
106336 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
106337 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
106338 +send_update_extent_35556 send_update_extent 0 35556 NULL
106339 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
106340 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
106341 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
106342 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
106343 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
106344 +kernel_readv_35617 kernel_readv 3 35617 NULL
106345 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
106346 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
106347 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
106348 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
106349 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
106350 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
106351 +dm_table_create_35687 dm_table_create 3 35687 NULL
106352 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
106353 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
106354 +md_super_write_35703 md_super_write 4 35703 NULL
106355 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
106356 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
106357 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
106358 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
106359 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
106360 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
106361 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
106362 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
106363 +changed_xattr_35860 changed_xattr 0 35860 NULL
106364 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
106365 +fls64_35862 fls64 0 35862 NULL
106366 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
106367 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
106368 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
106369 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
106370 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
106371 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
106372 +balance_node_right_35920 balance_node_right 0 35920 NULL
106373 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
106374 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
106375 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
106376 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
106377 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
106378 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
106379 +acl_alloc_35979 acl_alloc 1 35979 NULL
106380 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
106381 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
106382 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
106383 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
106384 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
106385 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
106386 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
106387 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
106388 +account_shadowed_36048 account_shadowed 2 36048 NULL
106389 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
106390 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
106391 +did_create_dir_36062 did_create_dir 0 36062 NULL
106392 +write_emulate_36065 write_emulate 2-4 36065 NULL
106393 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
106394 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
106395 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
106396 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
106397 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
106398 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
106399 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
106400 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
106401 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
106402 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
106403 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
106404 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
106405 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
106406 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
106407 +twl_set_36154 twl_set 2 36154 NULL
106408 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
106409 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
106410 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
106411 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
106412 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
106413 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
106414 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
106415 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
106416 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
106417 +is_dirty_36223 is_dirty 2 36223 NULL
106418 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
106419 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
106420 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
106421 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
106422 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
106423 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
106424 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
106425 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
106426 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
106427 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
106428 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
106429 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
106430 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
106431 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
106432 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
106433 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
106434 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
106435 +lc_create_36332 lc_create 4 36332 NULL
106436 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
106437 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
106438 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
106439 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
106440 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
106441 +to_sector_36361 to_sector 0-1 36361 NULL
106442 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
106443 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
106444 +tunables_read_36385 tunables_read 3 36385 NULL
106445 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
106446 +sierra_write_36402 sierra_write 4 36402 NULL
106447 +msb_update_block_36412 msb_update_block 2 36412 NULL
106448 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
106449 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
106450 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
106451 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
106452 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
106453 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
106454 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
106455 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
106456 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
106457 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
106458 +cmd_loop_36491 cmd_loop 0 36491 NULL
106459 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
106460 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
106461 +get_param_l_36518 get_param_l 0 36518 NULL
106462 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
106463 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
106464 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
106465 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
106466 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
106467 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
106468 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
106469 +__erst_read_36579 __erst_read 0 36579 NULL
106470 +put_cmsg_36589 put_cmsg 4 36589 NULL
106471 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
106472 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
106473 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
106474 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
106475 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
106476 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
106477 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
106478 +perf_calculate_period_36662 perf_calculate_period 2-3 36662 NULL
106479 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
106480 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
106481 +xillybus_read_36678 xillybus_read 3 36678 NULL
106482 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
106483 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
106484 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
106485 +sched_clock_36717 sched_clock 0 36717 NULL
106486 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
106487 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
106488 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
106489 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
106490 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
106491 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
106492 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
106493 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
106494 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
106495 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
106496 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
106497 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
106498 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
106499 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
106500 +cm_write_36858 cm_write 3 36858 NULL
106501 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
106502 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
106503 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
106504 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
106505 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
106506 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
106507 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
106508 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
106509 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
106510 +build_key_36931 build_key 1 36931 NULL
106511 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
106512 +div_u64_36951 div_u64 0 36951 NULL
106513 +write_leb_36957 write_leb 0-5 36957 NULL
106514 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
106515 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
106516 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
106517 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
106518 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
106519 +setxattr_37006 setxattr 4 37006 NULL
106520 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
106521 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
106522 +command_file_read_37038 command_file_read 3 37038 NULL
106523 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
106524 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
106525 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
106526 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
106527 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
106528 +parse_command_37079 parse_command 2 37079 NULL
106529 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
106530 +tun_get_user_37094 tun_get_user 5 37094 NULL
106531 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
106532 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
106533 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
106534 +msg_word_37164 msg_word 0 37164 NULL
106535 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
106536 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
106537 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
106538 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
106539 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
106540 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
106541 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
106542 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
106543 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
106544 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
106545 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
106546 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
106547 +__do_replace_37227 __do_replace 5 37227 NULL
106548 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
106549 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
106550 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
106551 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
106552 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
106553 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
106554 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
106555 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
106556 +create_cq_user_37278 create_cq_user 5 37278 NULL
106557 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
106558 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
106559 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
106560 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
106561 +send_msg_37323 send_msg 4 37323 NULL
106562 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
106563 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
106564 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
106565 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
106566 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
106567 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
106568 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
106569 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
106570 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
106571 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
106572 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
106573 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
106574 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
106575 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
106576 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
106577 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
106578 +fru_alloc_37442 fru_alloc 1 37442 NULL
106579 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
106580 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
106581 +__remove_37457 __remove 2 37457 NULL
106582 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
106583 +get_est_timing_37484 get_est_timing 0 37484 NULL
106584 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
106585 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
106586 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
106587 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
106588 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
106589 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
106590 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
106591 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
106592 +hdr_size_37536 hdr_size 0 37536 NULL
106593 +extent_map_end_37550 extent_map_end 0 37550 NULL
106594 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
106595 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
106596 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
106597 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
106598 +alloc_descs_37593 alloc_descs 0-1 37593 NULL
106599 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
106600 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
106601 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
106602 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
106603 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
106604 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
106605 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
106606 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
106607 +alloc_fd_37637 alloc_fd 1 37637 NULL
106608 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
106609 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
106610 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
106611 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
106612 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
106613 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
106614 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
106615 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
106616 +page_chain_free_37697 page_chain_free 0 37697 NULL
106617 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
106618 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
106619 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
106620 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
106621 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
106622 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
106623 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
106624 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
106625 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
106626 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
106627 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
106628 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
106629 +deny_write_access_37813 deny_write_access 0 37813 NULL
106630 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
106631 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
106632 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
106633 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
106634 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
106635 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
106636 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
106637 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
106638 +set_registers_37883 set_registers 4 37883 NULL
106639 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
106640 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
106641 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
106642 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
106643 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
106644 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
106645 +write_file_bool_37957 write_file_bool 3 37957 NULL
106646 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
106647 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
106648 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
106649 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
106650 +vfs_readv_38011 vfs_readv 3 38011 NULL
106651 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
106652 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
106653 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
106654 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
106655 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
106656 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
106657 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
106658 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
106659 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
106660 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
106661 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
106662 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
106663 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
106664 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
106665 +ep0_read_38095 ep0_read 3 38095 NULL
106666 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
106667 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
106668 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
106669 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
106670 +_get_val_38115 _get_val 2 38115 NULL
106671 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
106672 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
106673 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
106674 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
106675 +send_rename_38170 send_rename 0 38170 NULL
106676 +cdev_add_38176 cdev_add 2-3 38176 NULL
106677 +create_srq_user_38191 create_srq_user 5 38191 NULL
106678 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
106679 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
106680 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
106681 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
106682 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
106683 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
106684 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
106685 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
106686 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
106687 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
106688 +from_dblock_38256 from_dblock 0-1 38256 NULL
106689 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
106690 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 NULL nohasharray
106691 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 &SYSC_msgrcv_38268 nohasharray
106692 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
106693 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
106694 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
106695 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
106696 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106697 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
106698 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106699 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
106700 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
106701 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106702 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
106703 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
106704 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106705 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106706 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
106707 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106708 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106709 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106710 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
106711 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
106712 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
106713 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
106714 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
106715 +dev_names_read_38509 dev_names_read 3 38509 NULL
106716 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
106717 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
106718 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
106719 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
106720 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
106721 +kuc_len_38557 kuc_len 0-1 38557 NULL
106722 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
106723 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
106724 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
106725 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
106726 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
106727 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
106728 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
106729 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
106730 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
106731 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
106732 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
106733 +cma_create_area_38642 cma_create_area 2 38642 NULL
106734 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
106735 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
106736 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
106737 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
106738 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
106739 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
106740 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
106741 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
106742 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
106743 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
106744 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
106745 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
106746 +udf_readpages_38761 udf_readpages 4 38761 NULL
106747 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
106748 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
106749 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
106750 +slab_order_38794 slab_order 0 38794 NULL
106751 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
106752 +err_decode_38804 err_decode 2 38804 NULL
106753 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
106754 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
106755 +direct_entry_38836 direct_entry 3 38836 NULL
106756 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
106757 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
106758 +interfaces_38859 interfaces 2 38859 NULL
106759 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
106760 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
106761 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
106762 +traverse_38897 traverse 0 38897 NULL
106763 +__fswab16_38898 __fswab16 0 38898 NULL
106764 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
106765 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
106766 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
106767 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
106768 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
106769 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
106770 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
106771 +udf_new_block_38999 udf_new_block 4 38999 NULL
106772 +get_nodes_39012 get_nodes 3 39012 NULL
106773 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
106774 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
106775 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
106776 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
106777 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
106778 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
106779 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
106780 +atomic64_add_negative_39098 atomic64_add_negative 1 39098 NULL
106781 +ReadHFC_39104 ReadHFC 0 39104 NULL
106782 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
106783 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
106784 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
106785 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
106786 +ea_foreach_39133 ea_foreach 0 39133 NULL
106787 +generic_permission_39150 generic_permission 0 39150 NULL
106788 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
106789 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
106790 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
106791 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
106792 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
106793 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
106794 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
106795 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
106796 +drm_order_39244 drm_order 0 39244 NULL
106797 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
106798 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
106799 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
106800 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
106801 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
106802 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
106803 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
106804 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
106805 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
106806 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
106807 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
106808 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
106809 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
106810 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
106811 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
106812 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
106813 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
106814 +__send_to_port_39386 __send_to_port 3 39386 NULL
106815 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
106816 +user_power_read_39414 user_power_read 3 39414 NULL
106817 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
106818 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
106819 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
106820 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
106821 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
106822 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
106823 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
106824 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
106825 +int_proc_write_39542 int_proc_write 3 39542 NULL
106826 +pp_write_39554 pp_write 3 39554 NULL
106827 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
106828 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
106829 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
106830 +ext_depth_39607 ext_depth 0 39607 NULL
106831 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
106832 +sdio_readb_39618 sdio_readb 0 39618 NULL
106833 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
106834 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
106835 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
106836 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
106837 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
106838 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
106839 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
106840 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
106841 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
106842 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
106843 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
106844 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
106845 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
106846 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
106847 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
106848 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
106849 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
106850 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
106851 +can_rmdir_39890 can_rmdir 0 39890 NULL
106852 +pkt_add_39897 pkt_add 3 39897 NULL
106853 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
106854 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
106855 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
106856 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
106857 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
106858 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
106859 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
106860 +__spi_async_39932 __spi_async 0 39932 NULL
106861 +__get_order_39935 __get_order 0 39935 NULL
106862 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
106863 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
106864 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
106865 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
106866 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
106867 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
106868 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
106869 +server_name2svname_39998 server_name2svname 4 39998 NULL
106870 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
106871 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
106872 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
106873 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
106874 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
106875 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
106876 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
106877 +add_tty_40055 add_tty 1 40055 NULL nohasharray
106878 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
106879 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
106880 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
106881 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
106882 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
106883 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
106884 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
106885 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
106886 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
106887 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
106888 +pt_write_40159 pt_write 3 40159 NULL
106889 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
106890 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
106891 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
106892 +allocate_probes_40204 allocate_probes 1 40204 NULL
106893 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
106894 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
106895 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
106896 +osst_read_40237 osst_read 3 40237 NULL
106897 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
106898 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
106899 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
106900 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
106901 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
106902 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
106903 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
106904 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
106905 +SyS_bind_40303 SyS_bind 3 40303 NULL
106906 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
106907 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
106908 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
106909 +mmio_read_40348 mmio_read 4 40348 NULL
106910 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
106911 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
106912 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
106913 +get_chars_40373 get_chars 3 40373 NULL
106914 +submit_page_section_40408 submit_page_section 0 40408 NULL
106915 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
106916 +slab_node_40421 slab_node 0 40421 NULL
106917 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
106918 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
106919 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
106920 +SyS_writev_40467 SyS_writev 3 40467 NULL
106921 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
106922 +SyS_select_40473 SyS_select 1 40473 NULL
106923 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
106924 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
106925 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
106926 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
106927 +sg_phys_40507 sg_phys 0 40507 NULL
106928 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
106929 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
106930 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
106931 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
106932 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
106933 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
106934 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
106935 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
106936 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
106937 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
106938 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
106939 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
106940 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
106941 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
106942 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
106943 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
106944 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
106945 +fops_read_40672 fops_read 3 40672 NULL
106946 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
106947 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
106948 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
106949 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
106950 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
106951 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
106952 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
106953 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
106954 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
106955 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
106956 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
106957 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
106958 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
106959 +card_send_command_40757 card_send_command 3 40757 NULL
106960 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
106961 +pg_write_40766 pg_write 3 40766 NULL
106962 +show_list_40775 show_list 3-0 40775 NULL
106963 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
106964 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
106965 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
106966 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
106967 +add_action_40811 add_action 4 40811 NULL
106968 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
106969 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
106970 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
106971 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
106972 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
106973 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
106974 +read_file_queue_40895 read_file_queue 3 40895 NULL
106975 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
106976 +waiters_read_40902 waiters_read 3 40902 NULL
106977 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
106978 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
106979 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
106980 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
106981 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
106982 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
106983 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
106984 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
106985 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
106986 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
106987 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
106988 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
106989 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
106990 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
106991 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
106992 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
106993 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
106994 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
106995 +calculate_order_41061 calculate_order 0 41061 NULL
106996 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
106997 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
106998 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
106999 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107000 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
107001 +dma_attach_41094 dma_attach 6-5 41094 NULL
107002 +provide_user_output_41105 provide_user_output 3 41105 NULL
107003 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107004 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
107005 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
107006 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
107007 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107008 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107009 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107010 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107011 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
107012 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107013 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107014 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107015 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107016 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
107017 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
107018 +create_dir_41256 create_dir 0 41256 NULL
107019 +erst_read_41260 erst_read 0 41260 NULL
107020 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
107021 +alloc_context_41283 alloc_context 1 41283 NULL
107022 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
107023 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
107024 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107025 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
107026 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
107027 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107028 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107029 +kmp_init_41373 kmp_init 2 41373 NULL
107030 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
107031 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107032 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107033 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107034 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107035 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107036 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107037 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107038 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
107039 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107040 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107041 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
107042 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107043 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
107044 +split_item_41483 split_item 0 41483 NULL
107045 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
107046 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
107047 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107048 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107049 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107050 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107051 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
107052 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
107053 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
107054 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
107055 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107056 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107057 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
107058 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
107059 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107060 +vga_io_r_41609 vga_io_r 0 41609 NULL
107061 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107062 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
107063 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
107064 +a2mp_send_41615 a2mp_send 4 41615 NULL
107065 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107066 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
107067 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107068 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107069 +get_std_timing_41654 get_std_timing 0 41654 NULL
107070 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
107071 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107072 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107073 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
107074 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
107075 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
107076 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
107077 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107078 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
107079 +fillonedir_41746 fillonedir 3 41746 NULL
107080 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107081 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107082 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
107083 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107084 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
107085 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
107086 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107087 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107088 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107089 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107090 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107091 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107092 +pci_map_single_41869 pci_map_single 0 41869 NULL
107093 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
107094 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
107095 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107096 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107097 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107098 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107099 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107100 +read_gssp_41947 read_gssp 3 41947 NULL
107101 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107102 +portnames_read_41958 portnames_read 3 41958 NULL
107103 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
107104 +dst_mtu_41969 dst_mtu 0 41969 NULL
107105 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
107106 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107107 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107108 +pool_allocate_42012 pool_allocate 3 42012 NULL
107109 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107110 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
107111 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
107112 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107113 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
107114 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107115 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107116 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107117 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107118 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107119 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107120 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107121 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107122 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107123 +send_truncate_42107 send_truncate 0 42107 NULL
107124 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107125 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107126 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107127 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
107128 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
107129 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
107130 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107131 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
107132 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107133 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107134 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
107135 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107136 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
107137 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
107138 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107139 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
107140 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
107141 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107142 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
107143 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107144 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107145 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107146 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
107147 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
107148 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
107149 +free_cblock_42318 free_cblock 2 42318 NULL
107150 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107151 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
107152 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107153 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107154 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
107155 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107156 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107157 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107158 +krng_get_random_42420 krng_get_random 3 42420 NULL
107159 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107160 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107161 +alloc_request_42448 alloc_request 0 42448 NULL
107162 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107163 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107164 +kuc_free_42455 kuc_free 2 42455 NULL
107165 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107166 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107167 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107168 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107169 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107170 +bypass_write_42498 bypass_write 3 42498 NULL
107171 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
107172 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
107173 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107174 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
107175 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107176 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
107177 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
107178 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107179 +inorder_next_42548 inorder_next 1-0 42548 NULL
107180 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
107181 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
107182 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107183 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
107184 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107185 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
107186 +map_state_42602 map_state 1 42602 NULL
107187 +resp_write_42628 resp_write 2 42628 NULL
107188 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
107189 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
107190 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
107191 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
107192 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
107193 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
107194 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
107195 +vb2_read_42703 vb2_read 3 42703 NULL
107196 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
107197 +read_status_42722 read_status 0 42722 NULL
107198 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
107199 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
107200 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
107201 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
107202 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
107203 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
107204 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
107205 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
107206 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
107207 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
107208 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
107209 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
107210 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
107211 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
107212 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
107213 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
107214 +set_arg_42824 set_arg 3 42824 NULL
107215 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
107216 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
107217 +prandom_u32_42853 prandom_u32 0 42853 NULL
107218 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
107219 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
107220 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
107221 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
107222 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
107223 +hd_end_request_42904 hd_end_request 2 42904 NULL
107224 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
107225 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
107226 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
107227 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
107228 +send_link_42948 send_link 0 42948 NULL
107229 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
107230 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
107231 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
107232 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
107233 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
107234 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
107235 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
107236 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
107237 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
107238 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
107239 +send_to_group_43051 send_to_group 0 43051 NULL
107240 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
107241 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
107242 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
107243 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
107244 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
107245 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
107246 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
107247 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
107248 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
107249 +send_cmd_43168 send_cmd 0 43168 NULL
107250 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
107251 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
107252 +uio_write_43202 uio_write 3 43202 NULL
107253 +iso_callback_43208 iso_callback 3 43208 NULL
107254 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
107255 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
107256 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
107257 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
107258 +fixup_leb_43256 fixup_leb 3 43256 NULL
107259 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
107260 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
107261 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
107262 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
107263 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
107264 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
107265 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
107266 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
107267 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
107268 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
107269 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
107270 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
107271 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
107272 +xenfb_write_43412 xenfb_write 3 43412 NULL
107273 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
107274 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
107275 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
107276 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
107277 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
107278 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
107279 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
107280 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
107281 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
107282 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
107283 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
107284 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
107285 +do_readlink_43518 do_readlink 2 43518 NULL
107286 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
107287 +read_events_43534 read_events 3 43534 NULL
107288 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
107289 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
107290 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
107291 +request_resource_43548 request_resource 0 43548 NULL
107292 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
107293 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
107294 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
107295 +proc_read_43614 proc_read 3 43614 NULL
107296 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
107297 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
107298 +random_write_43656 random_write 3 43656 NULL
107299 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
107300 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
107301 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
107302 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
107303 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
107304 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
107305 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
107306 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
107307 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
107308 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
107309 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
107310 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
107311 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
107312 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
107313 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
107314 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
107315 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
107316 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
107317 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
107318 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
107319 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
107320 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
107321 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
107322 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
107323 +read_flush_43851 read_flush 3 43851 NULL
107324 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
107325 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
107326 +SendString_43928 SendString 3 43928 NULL
107327 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
107328 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
107329 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
107330 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
107331 +nla_reserve_43984 nla_reserve 3 43984 NULL
107332 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
107333 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
107334 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
107335 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
107336 +ulist_add_43994 ulist_add 0 43994 NULL
107337 +emit_flags_44006 emit_flags 4-3 44006 NULL
107338 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
107339 +fru_strlen_44046 fru_strlen 0 44046 NULL
107340 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
107341 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
107342 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
107343 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
107344 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
107345 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
107346 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
107347 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
107348 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
107349 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
107350 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
107351 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
107352 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
107353 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
107354 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
107355 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
107356 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
107357 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
107358 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
107359 +__set_free_44211 __set_free 2 44211 NULL
107360 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
107361 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
107362 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
107363 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
107364 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
107365 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
107366 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
107367 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
107368 +device_create_file_44285 device_create_file 0 44285 NULL
107369 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
107370 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
107371 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
107372 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
107373 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
107374 +rs_init_44327 rs_init 1 44327 NULL
107375 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
107376 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
107377 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
107378 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
107379 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
107380 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
107381 +__is_discarded_44359 __is_discarded 2 44359 NULL
107382 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
107383 +alloc_requests_44372 alloc_requests 0 44372 NULL
107384 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
107385 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
107386 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
107387 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
107388 +strlcpy_44400 strlcpy 3 44400 NULL
107389 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
107390 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
107391 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
107392 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
107393 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
107394 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
107395 +write_file_debug_44476 write_file_debug 3 44476 NULL
107396 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
107397 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
107398 +bio_advance_44496 bio_advance 2 44496 NULL
107399 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
107400 +ac_register_board_44504 ac_register_board 3 44504 NULL
107401 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
107402 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
107403 +spidev_write_44510 spidev_write 3 44510 NULL
107404 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
107405 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
107406 +comm_write_44537 comm_write 3 44537 NULL
107407 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
107408 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
107409 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
107410 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
107411 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
107412 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
107413 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
107414 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
107415 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
107416 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
107417 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
107418 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
107419 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
107420 +mpi_resize_44674 mpi_resize 2 44674 NULL
107421 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
107422 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
107423 +ts_read_44687 ts_read 3 44687 NULL
107424 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
107425 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
107426 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
107427 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
107428 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
107429 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
107430 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
107431 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
107432 +SyS_read_44732 SyS_read 3 44732 NULL
107433 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
107434 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
107435 +set_brk_44749 set_brk 1-2 44749 NULL
107436 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
107437 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
107438 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
107439 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
107440 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
107441 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
107442 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
107443 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
107444 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
107445 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
107446 +sisusb_write_44834 sisusb_write 3 44834 NULL
107447 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
107448 +cubic_root_44848 cubic_root 1 44848 NULL
107449 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
107450 +copydesc_user_44855 copydesc_user 3 44855 NULL
107451 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
107452 +init_rs_44873 init_rs 1 44873 NULL
107453 +skb_availroom_44883 skb_availroom 0 44883 NULL
107454 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
107455 +do_tty_write_44896 do_tty_write 5 44896 NULL
107456 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
107457 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
107458 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
107459 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
107460 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
107461 +send_chmod_45011 send_chmod 0 45011 NULL
107462 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
107463 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
107464 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
107465 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
107466 +dm_kvzalloc_45025 dm_kvzalloc 1 45025 NULL
107467 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
107468 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
107469 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
107470 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
107471 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
107472 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
107473 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
107474 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
107475 +usbdev_read_45114 usbdev_read 3 45114 NULL
107476 +send_to_tty_45141 send_to_tty 3 45141 NULL
107477 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
107478 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
107479 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
107480 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
107481 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
107482 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
107483 +SYSC_write_45160 SYSC_write 3 45160 NULL
107484 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
107485 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
107486 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
107487 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
107488 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
107489 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
107490 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
107491 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
107492 +__dirty_45228 __dirty 2 45228 NULL
107493 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
107494 +event_enable_write_45238 event_enable_write 3 45238 NULL
107495 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
107496 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
107497 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
107498 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
107499 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
107500 +pte_val_45313 pte_val 0 45313 NULL
107501 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
107502 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
107503 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
107504 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
107505 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
107506 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
107507 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
107508 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
107509 +__node_remap_45458 __node_remap 4 45458 NULL
107510 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
107511 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
107512 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
107513 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
107514 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
107515 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
107516 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
107517 +copy_macs_45534 copy_macs 4 45534 NULL
107518 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
107519 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
107520 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
107521 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
107522 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
107523 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
107524 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
107525 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
107526 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
107527 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
107528 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
107529 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
107530 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
107531 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
107532 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
107533 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
107534 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
107535 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
107536 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
107537 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
107538 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
107539 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
107540 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
107541 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
107542 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
107543 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
107544 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
107545 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
107546 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
107547 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
107548 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
107549 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
107550 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
107551 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
107552 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
107553 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
107554 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
107555 +task_state_char_45839 task_state_char 1 45839 NULL
107556 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
107557 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
107558 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
107559 +isdn_write_45863 isdn_write 3 45863 NULL
107560 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
107561 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
107562 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
107563 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
107564 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
107565 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
107566 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
107567 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
107568 +alloc_mr_45935 alloc_mr 1 45935 NULL
107569 +copy_to_45969 copy_to 3 45969 NULL
107570 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
107571 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
107572 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
107573 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
107574 +get_free_entries_46030 get_free_entries 1 46030 NULL
107575 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
107576 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
107577 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
107578 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
107579 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
107580 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
107581 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
107582 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
107583 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
107584 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
107585 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
107586 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
107587 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
107588 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
107589 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
107590 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
107591 +alloc_iova_46160 alloc_iova 2 46160 NULL
107592 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
107593 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
107594 +fq_resize_46195 fq_resize 2 46195 NULL
107595 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
107596 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
107597 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
107598 +dsp_write_46218 dsp_write 2 46218 NULL
107599 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
107600 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
107601 +ReadReg_46277 ReadReg 0 46277 NULL
107602 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
107603 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL nohasharray
107604 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 &__hwahc_dev_set_key_46328
107605 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
107606 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
107607 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
107608 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
107609 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
107610 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
107611 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
107612 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
107613 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
107614 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
107615 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
107616 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
107617 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
107618 +filldir64_46469 filldir64 3 46469 NULL
107619 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
107620 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
107621 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
107622 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
107623 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
107624 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
107625 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
107626 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
107627 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
107628 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
107629 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
107630 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
107631 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
107632 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
107633 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
107634 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
107635 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
107636 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
107637 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
107638 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
107639 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
107640 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
107641 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
107642 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
107643 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
107644 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
107645 +ide_read_status_46719 ide_read_status 0 46719 NULL
107646 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
107647 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
107648 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
107649 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
107650 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
107651 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
107652 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
107653 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
107654 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
107655 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
107656 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
107657 +readreg_46845 readreg 0 46845 NULL
107658 +spi_async_46857 spi_async 0 46857 NULL
107659 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
107660 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
107661 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
107662 +rvmalloc_46873 rvmalloc 1 46873 NULL
107663 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
107664 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
107665 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
107666 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
107667 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
107668 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
107669 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
107670 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
107671 +fb_write_46924 fb_write 3 46924 NULL
107672 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
107673 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
107674 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
107675 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
107676 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
107677 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
107678 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
107679 +strlcat_46985 strlcat 3 46985 NULL
107680 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
107681 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
107682 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
107683 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
107684 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
107685 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
107686 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
107687 +fs_path_len_47060 fs_path_len 0 47060 NULL
107688 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
107689 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
107690 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
107691 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
107692 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
107693 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
107694 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
107695 +mousedev_read_47123 mousedev_read 3 47123 NULL
107696 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
107697 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
107698 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
107699 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
107700 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
107701 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
107702 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
107703 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
107704 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
107705 +options_write_47243 options_write 3 47243 NULL
107706 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
107707 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
107708 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
107709 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
107710 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
107711 +vsnprintf_47291 vsnprintf 0 47291 NULL
107712 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
107713 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
107714 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
107715 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
107716 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
107717 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
107718 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
107719 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
107720 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
107721 +nametbl_list_47391 nametbl_list 2 47391 NULL
107722 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
107723 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
107724 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
107725 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
107726 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
107727 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
107728 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
107729 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
107730 +vzalloc_47421 vzalloc 1 47421 NULL
107731 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
107732 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
107733 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
107734 +environ_read_47451 environ_read 3 47451 NULL
107735 +__load_mapping_47460 __load_mapping 2 47460 NULL
107736 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
107737 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
107738 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
107739 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
107740 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
107741 +core_sys_select_47494 core_sys_select 1 47494 NULL
107742 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
107743 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL nohasharray
107744 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
107745 +unlink_simple_47506 unlink_simple 3 47506 NULL
107746 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
107747 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
107748 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
107749 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
107750 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
107751 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
107752 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
107753 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
107754 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
107755 +read_ldt_47570 read_ldt 2 47570 NULL
107756 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
107757 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
107758 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
107759 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
107760 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
107761 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
107762 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
107763 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
107764 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
107765 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
107766 +get_size_47644 get_size 1-2 47644 NULL
107767 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
107768 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
107769 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
107770 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
107771 +save_microcode_47717 save_microcode 3 47717 NULL
107772 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
107773 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
107774 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
107775 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
107776 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
107777 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
107778 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
107779 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
107780 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
107781 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
107782 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
107783 +lov_packmd_47810 lov_packmd 0 47810 NULL
107784 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
107785 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
107786 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
107787 +vhci_read_47878 vhci_read 3 47878 NULL
107788 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
107789 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
107790 +load_mapping_47904 load_mapping 3 47904 NULL
107791 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
107792 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
107793 +comedi_write_47926 comedi_write 3 47926 NULL
107794 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
107795 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
107796 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
107797 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
107798 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
107799 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
107800 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
107801 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
107802 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
107803 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
107804 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
107805 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
107806 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
107807 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
107808 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
107809 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
107810 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
107811 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
107812 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
107813 +disc_write_48070 disc_write 3 48070 NULL
107814 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
107815 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
107816 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
107817 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
107818 +set_discoverable_48141 set_discoverable 4 48141 NULL
107819 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
107820 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
107821 +_add_to_r4w_48152 _add_to_r4w 4 48152 NULL nohasharray
107822 +bitmap_onto_48152 bitmap_onto 4 48152 &_add_to_r4w_48152
107823 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
107824 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
107825 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
107826 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
107827 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
107828 +init_ipath_48187 init_ipath 1 48187 NULL
107829 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
107830 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
107831 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
107832 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
107833 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
107834 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
107835 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
107836 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
107837 +read_file_recv_48232 read_file_recv 3 48232 NULL
107838 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
107839 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
107840 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
107841 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
107842 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
107843 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
107844 +trace_options_write_48275 trace_options_write 3 48275 NULL
107845 +send_set_info_48288 send_set_info 7 48288 NULL
107846 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
107847 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
107848 +hash_setkey_48310 hash_setkey 3 48310 NULL
107849 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
107850 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
107851 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
107852 +skb_add_data_48363 skb_add_data 3 48363 NULL
107853 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
107854 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
107855 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
107856 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
107857 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
107858 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
107859 +print_filtered_48442 print_filtered 2-0 48442 NULL
107860 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
107861 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
107862 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
107863 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
107864 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
107865 +send_control_msg_48498 send_control_msg 6 48498 NULL
107866 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
107867 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
107868 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
107869 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
107870 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
107871 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
107872 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
107873 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
107874 +llog_data_len_48607 llog_data_len 1 48607 NULL
107875 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
107876 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
107877 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
107878 +mtd_read_48655 mtd_read 0 48655 NULL
107879 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
107880 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
107881 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
107882 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
107883 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
107884 +altera_drscan_48698 altera_drscan 2 48698 NULL
107885 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
107886 +recv_msg_48709 recv_msg 4 48709 NULL
107887 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
107888 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
107889 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
107890 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
107891 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
107892 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
107893 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
107894 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
107895 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
107896 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
107897 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
107898 +azx_get_position_48841 azx_get_position 0 48841 NULL
107899 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
107900 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
107901 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
107902 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
107903 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
107904 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
107905 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
107906 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
107907 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
107908 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
107909 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
107910 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
107911 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
107912 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
107913 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
107914 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
107915 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
107916 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
107917 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
107918 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
107919 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
107920 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
107921 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
107922 +aic_inb_49023 aic_inb 0 49023 NULL
107923 +transient_status_49027 transient_status 4 49027 NULL
107924 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
107925 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
107926 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
107927 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
107928 +ubi_read_49061 ubi_read 0 49061 NULL
107929 +scsi_register_49094 scsi_register 2 49094 NULL
107930 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
107931 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
107932 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
107933 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
107934 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
107935 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
107936 +read_file_49137 read_file 4 49137 NULL
107937 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
107938 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
107939 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
107940 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
107941 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
107942 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
107943 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
107944 +print_queue_49191 print_queue 0 49191 NULL
107945 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
107946 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
107947 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
107948 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
107949 +resp_write_same_49217 resp_write_same 2 49217 NULL
107950 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
107951 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
107952 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
107953 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
107954 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
107955 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
107956 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
107957 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
107958 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
107959 +uio_read_49300 uio_read 3 49300 NULL
107960 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
107961 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
107962 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
107963 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
107964 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
107965 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
107966 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
107967 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
107968 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
107969 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
107970 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
107971 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
107972 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
107973 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
107974 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
107975 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
107976 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
107977 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
107978 +get_lru_size_49441 get_lru_size 0 49441 NULL
107979 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
107980 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
107981 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
107982 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
107983 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
107984 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
107985 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
107986 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
107987 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
107988 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
107989 +smk_write_access_49561 smk_write_access 3 49561 NULL
107990 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
107991 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
107992 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
107993 +readfifo_49583 readfifo 1 49583 NULL
107994 +tap_write_49595 tap_write 3 49595 NULL
107995 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
107996 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
107997 +heap_init_49617 heap_init 2 49617 NULL
107998 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
107999 +port_fops_read_49626 port_fops_read 3 49626 NULL
108000 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
108001 +__swab32p_49657 __swab32p 0 49657 NULL
108002 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
108003 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
108004 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
108005 +__setup_irq_49696 __setup_irq 0 49696 NULL
108006 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
108007 +do_splice_to_49714 do_splice_to 4 49714 NULL
108008 +write_pool_49718 write_pool 3 49718 NULL
108009 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
108010 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
108011 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
108012 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
108013 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
108014 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
108015 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
108016 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
108017 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
108018 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
108019 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
108020 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
108021 +add_uuid_49831 add_uuid 4 49831 NULL
108022 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
108023 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
108024 +twl4030_write_49846 twl4030_write 2 49846 NULL
108025 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
108026 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
108027 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
108028 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
108029 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
108030 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
108031 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
108032 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
108033 +osc_brw_49896 osc_brw 4 49896 NULL
108034 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
108035 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
108036 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
108037 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
108038 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
108039 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
108040 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
108041 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
108042 +__module_alloc_50004 __module_alloc 1 50004 NULL
108043 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
108044 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
108045 +isdn_read_50021 isdn_read 3 50021 NULL
108046 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
108047 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
108048 +ioread8_50049 ioread8 0 50049 NULL
108049 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
108050 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
108051 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
108052 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
108053 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
108054 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
108055 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
108056 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
108057 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
108058 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
108059 +read_file_slot_50111 read_file_slot 3 50111 NULL
108060 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
108061 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
108062 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
108063 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
108064 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
108065 +copy_items_50140 copy_items 6 50140 NULL
108066 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
108067 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
108068 +kmalloc_node_50163 kmalloc_node 1 50163 NULL
108069 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
108070 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
108071 +odev_update_50169 odev_update 2 50169 NULL
108072 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
108073 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
108074 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
108075 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
108076 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
108077 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
108078 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
108079 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
108080 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
108081 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
108082 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
108083 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
108084 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108085 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
108086 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108087 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108088 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
108089 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108090 +do_launder_page_50329 do_launder_page 0 50329 NULL
108091 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108092 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108093 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108094 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108095 +tpm_read_50344 tpm_read 3 50344 NULL
108096 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108097 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
108098 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108099 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108100 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
108101 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
108102 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108103 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108104 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108105 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108106 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
108107 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108108 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108109 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108110 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
108111 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
108112 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108113 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108114 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
108115 +force_mapping_50464 force_mapping 2 50464 NULL
108116 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
108117 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108118 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108119 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108120 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
108121 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108122 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
108123 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
108124 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
108125 +fat_readpages_50582 fat_readpages 4 50582 NULL
108126 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108127 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108128 +xillybus_write_50605 xillybus_write 3 50605 NULL
108129 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108130 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
108131 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
108132 +__ffs_50625 __ffs 0-1 50625 NULL
108133 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108134 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108135 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
108136 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
108137 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108138 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
108139 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
108140 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
108141 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108142 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108143 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
108144 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108145 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108146 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
108147 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108148 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108149 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
108150 +tpm_write_50798 tpm_write 3 50798 NULL
108151 +write_flush_50803 write_flush 3 50803 NULL
108152 +dvb_play_50814 dvb_play 3 50814 NULL
108153 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108154 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108155 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108156 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835 nohasharray
108157 +mask_from_50835 mask_from 0-1-2 50835 &create_mem_extents_50835
108158 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
108159 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
108160 +self_check_write_50856 self_check_write 0-5 50856 NULL
108161 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108162 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
108163 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
108164 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108165 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108166 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
108167 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108168 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108169 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108170 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
108171 +show_device_status_50947 show_device_status 0 50947 NULL
108172 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
108173 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
108174 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
108175 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
108176 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
108177 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
108178 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
108179 +timeout_write_50991 timeout_write 3 50991 NULL
108180 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
108181 +proc_write_51003 proc_write 3 51003 NULL
108182 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
108183 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
108184 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
108185 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
108186 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
108187 +dump_midi_51040 dump_midi 3 51040 NULL
108188 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
108189 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
108190 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
108191 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
108192 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
108193 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
108194 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
108195 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
108196 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
108197 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
108198 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
108199 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
108200 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
108201 +set_dirty_51144 set_dirty 3 51144 NULL
108202 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
108203 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
108204 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
108205 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
108206 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
108207 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
108208 +tipc_send_51238 tipc_send 4 51238 NULL
108209 +drm_property_create_51239 drm_property_create 4 51239 NULL
108210 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
108211 +st_read_51251 st_read 3 51251 NULL
108212 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
108213 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
108214 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
108215 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
108216 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
108217 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
108218 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
108219 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
108220 +get_cell_51316 get_cell 2 51316 NULL
108221 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
108222 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
108223 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
108224 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
108225 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
108226 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
108227 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
108228 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
108229 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
108230 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
108231 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
108232 +get_first_ref_51413 get_first_ref 0 51413 NULL
108233 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
108234 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
108235 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
108236 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
108237 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
108238 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
108239 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
108240 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
108241 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
108242 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
108243 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
108244 +key_search_51533 key_search 0 51533 NULL
108245 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
108246 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
108247 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
108248 +get_cur_path_51589 get_cur_path 0 51589 NULL nohasharray
108249 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 &get_cur_path_51589
108250 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
108251 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
108252 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
108253 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
108254 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
108255 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
108256 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
108257 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
108258 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
108259 +sel_write_access_51704 sel_write_access 3 51704 NULL
108260 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
108261 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
108262 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
108263 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
108264 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
108265 +cm4040_read_51732 cm4040_read 3 51732 NULL
108266 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
108267 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
108268 +if_write_51756 if_write 3 51756 NULL
108269 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
108270 +__fswab32_51781 __fswab32 0 51781 NULL
108271 +to_ratio_51809 to_ratio 1-2 51809 NULL
108272 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
108273 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
108274 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
108275 +ioread32_51847 ioread32 0 51847 NULL nohasharray
108276 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
108277 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
108278 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
108279 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
108280 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
108281 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
108282 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
108283 +user_read_51881 user_read 3 51881 NULL
108284 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
108285 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 NULL nohasharray
108286 +virt_to_phys_51896 virt_to_phys 0 51896 &SyS_mq_timedsend_51896
108287 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
108288 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
108289 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
108290 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
108291 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
108292 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
108293 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
108294 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
108295 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
108296 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
108297 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
108298 +get_zone_51981 get_zone 0-1 51981 NULL
108299 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
108300 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
108301 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
108302 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
108303 +rdmalt_52022 rdmalt 0 52022 NULL
108304 +override_release_52032 override_release 2 52032 NULL
108305 +end_port_52042 end_port 0 52042 NULL
108306 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
108307 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
108308 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
108309 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
108310 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
108311 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
108312 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
108313 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
108314 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
108315 +retry_count_read_52129 retry_count_read 3 52129 NULL
108316 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
108317 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
108318 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
108319 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
108320 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
108321 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
108322 +htable_size_52148 htable_size 0-1 52148 NULL
108323 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
108324 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
108325 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
108326 +print_prefix_52176 print_prefix 0 52176 NULL
108327 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
108328 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
108329 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
108330 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
108331 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
108332 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
108333 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
108334 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
108335 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
108336 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
108337 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
108338 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
108339 +atomic64_read_52300 atomic64_read 0 52300 NULL
108340 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
108341 +read_file_reset_52310 read_file_reset 3 52310 NULL
108342 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
108343 +hwflags_read_52318 hwflags_read 3 52318 NULL
108344 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
108345 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
108346 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
108347 +hur_len_52339 hur_len 0 52339 NULL
108348 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
108349 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
108350 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
108351 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
108352 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
108353 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
108354 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
108355 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
108356 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
108357 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
108358 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
108359 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
108360 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
108361 +delay_status_52431 delay_status 5 52431 NULL
108362 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
108363 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
108364 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
108365 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
108366 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
108367 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
108368 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
108369 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
108370 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
108371 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
108372 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
108373 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
108374 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
108375 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
108376 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
108377 +from_oblock_52546 from_oblock 0-1 52546 NULL
108378 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
108379 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
108380 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
108381 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
108382 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
108383 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
108384 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
108385 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
108386 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
108387 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
108388 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
108389 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
108390 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
108391 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
108392 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
108393 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
108394 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
108395 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
108396 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
108397 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
108398 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
108399 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
108400 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
108401 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
108402 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
108403 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
108404 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
108405 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
108406 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
108407 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
108408 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
108409 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
108410 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
108411 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
108412 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
108413 +twlreg_write_52880 twlreg_write 3 52880 NULL
108414 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
108415 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
108416 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
108417 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
108418 +create_vtbl_52909 create_vtbl 0 52909 NULL
108419 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
108420 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
108421 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
108422 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
108423 +send_packet_52960 send_packet 4 52960 NULL
108424 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
108425 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
108426 +num_node_state_52989 num_node_state 0 52989 NULL
108427 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
108428 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
108429 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
108430 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
108431 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
108432 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
108433 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
108434 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
108435 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
108436 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
108437 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
108438 +page_to_nid_53085 page_to_nid 0 53085 NULL
108439 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
108440 +insert_new_root_53097 insert_new_root 0 53097 NULL
108441 +verity_status_53120 verity_status 5 53120 NULL
108442 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
108443 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
108444 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
108445 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
108446 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
108447 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
108448 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
108449 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
108450 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
108451 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
108452 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
108453 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
108454 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
108455 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
108456 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
108457 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
108458 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
108459 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
108460 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
108461 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
108462 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
108463 +vm_mmap_53339 vm_mmap 0 53339 NULL
108464 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
108465 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
108466 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
108467 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
108468 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
108469 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
108470 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
108471 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
108472 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
108473 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
108474 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
108475 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
108476 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
108477 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
108478 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
108479 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
108480 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
108481 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
108482 +check_acl_53512 check_acl 0 53512 NULL
108483 +send_utimes_53516 send_utimes 0 53516 NULL
108484 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
108485 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
108486 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
108487 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
108488 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
108489 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
108490 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
108491 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
108492 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
108493 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
108494 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
108495 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
108496 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
108497 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 &bdev_logical_block_size_53690
108498 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
108499 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
108500 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
108501 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
108502 +wdm_write_53735 wdm_write 3 53735 NULL
108503 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
108504 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
108505 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
108506 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
108507 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
108508 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
108509 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
108510 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
108511 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
108512 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
108513 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
108514 +setup_data_read_53822 setup_data_read 3 53822 NULL
108515 +pms_read_53873 pms_read 3 53873 NULL
108516 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
108517 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
108518 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
108519 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
108520 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
108521 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
108522 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
108523 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
108524 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
108525 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
108526 +send_clone_54011 send_clone 0 54011 NULL
108527 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
108528 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
108529 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
108530 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
108531 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
108532 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
108533 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
108534 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
108535 +_malloc_54077 _malloc 1 54077 NULL
108536 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
108537 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
108538 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
108539 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
108540 +strn_len_54122 strn_len 0 54122 NULL
108541 +isku_receive_54130 isku_receive 4 54130 NULL
108542 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
108543 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
108544 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
108545 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
108546 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
108547 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
108548 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
108549 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
108550 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
108551 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
108552 +reada_add_block_54247 reada_add_block 2 54247 NULL
108553 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
108554 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
108555 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
108556 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
108557 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
108558 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
108559 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
108560 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
108561 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
108562 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
108563 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
108564 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
108565 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
108566 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
108567 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
108568 +sprintf_54306 sprintf 0 54306 NULL
108569 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
108570 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
108571 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
108572 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
108573 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
108574 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
108575 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
108576 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
108577 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
108578 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
108579 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
108580 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
108581 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
108582 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
108583 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
108584 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
108585 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
108586 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4 54485 NULL
108587 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
108588 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
108589 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
108590 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
108591 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
108592 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
108593 +viacam_read_54526 viacam_read 3 54526 NULL
108594 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
108595 +setsockopt_54539 setsockopt 5 54539 NULL
108596 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
108597 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
108598 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 NULL
108599 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
108600 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
108601 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
108602 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
108603 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
108604 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
108605 +port_fops_write_54627 port_fops_write 3 54627 NULL
108606 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
108607 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
108608 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
108609 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
108610 +bus_add_device_54665 bus_add_device 0 54665 NULL
108611 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
108612 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
108613 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
108614 +evm_read_key_54674 evm_read_key 3 54674 NULL
108615 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
108616 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
108617 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
108618 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
108619 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
108620 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
108621 +kzalloc_54740 kzalloc 1 54740 NULL
108622 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
108623 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
108624 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
108625 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
108626 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
108627 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
108628 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
108629 +domain_init_54797 domain_init 2 54797 NULL
108630 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
108631 +get_dev_size_54807 get_dev_size 0 54807 NULL
108632 +nfsd_write_54809 nfsd_write 6 54809 NULL
108633 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
108634 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
108635 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
108636 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
108637 +write_rio_54837 write_rio 3 54837 NULL
108638 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
108639 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
108640 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
108641 +printer_read_54851 printer_read 3 54851 NULL
108642 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
108643 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
108644 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
108645 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
108646 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
108647 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
108648 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
108649 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
108650 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
108651 +add_port_54941 add_port 2 54941 NULL
108652 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
108653 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
108654 +c4_add_card_54968 c4_add_card 3 54968 NULL
108655 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
108656 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
108657 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
108658 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
108659 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
108660 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
108661 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
108662 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
108663 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
108664 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
108665 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
108666 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
108667 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
108668 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
108669 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
108670 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
108671 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
108672 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
108673 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
108674 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
108675 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
108676 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
108677 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
108678 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
108679 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
108680 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
108681 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
108682 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
108683 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
108684 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
108685 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
108686 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
108687 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
108688 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
108689 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
108690 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
108691 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
108692 +ptrace_request_55288 ptrace_request 3 55288 NULL
108693 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
108694 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
108695 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
108696 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
108697 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 NULL
108698 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
108699 +do_shmat_55336 do_shmat 5 55336 NULL
108700 +vme_user_read_55338 vme_user_read 3 55338 NULL
108701 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
108702 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
108703 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
108704 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
108705 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
108706 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
108707 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
108708 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
108709 +SyS_read_55449 SyS_read 3 55449 NULL
108710 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
108711 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
108712 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
108713 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
108714 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
108715 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
108716 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
108717 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
108718 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
108719 +ea_get_55522 ea_get 3-0 55522 NULL
108720 +buffer_size_55534 buffer_size 0 55534 NULL
108721 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
108722 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
108723 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
108724 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
108725 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
108726 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
108727 +add_partition_55588 add_partition 2 55588 NULL
108728 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
108729 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
108730 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
108731 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
108732 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
108733 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
108734 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
108735 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
108736 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
108737 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
108738 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
108739 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
108740 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
108741 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
108742 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
108743 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
108744 +get_info_55681 get_info 3 55681 NULL
108745 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
108746 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
108747 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
108748 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
108749 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
108750 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
108751 +set_local_name_55757 set_local_name 4 55757 NULL
108752 +strlen_55778 strlen 0 55778 NULL nohasharray
108753 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
108754 +set_spte_55783 set_spte 4-5 55783 NULL
108755 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
108756 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
108757 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
108758 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
108759 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
108760 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
108761 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
108762 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
108763 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
108764 +hsc_write_55875 hsc_write 3 55875 NULL
108765 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
108766 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
108767 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
108768 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
108769 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
108770 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
108771 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
108772 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
108773 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
108774 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
108775 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
108776 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
108777 +__set_discard_56081 __set_discard 2 56081 NULL
108778 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
108779 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
108780 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
108781 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
108782 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
108783 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
108784 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
108785 +create_irq_nr_56180 create_irq_nr 1-0 56180 NULL
108786 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
108787 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
108788 +update_space_info_56213 update_space_info 0 56213 NULL
108789 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
108790 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
108791 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
108792 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
108793 +fd_copyin_56247 fd_copyin 3 56247 NULL
108794 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
108795 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
108796 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
108797 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
108798 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
108799 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
108800 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
108801 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
108802 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
108803 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
108804 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
108805 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
108806 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
108807 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
108808 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
108809 +dev_read_56369 dev_read 3 56369 NULL
108810 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
108811 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
108812 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
108813 +write_gssp_56404 write_gssp 3 56404 NULL
108814 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
108815 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
108816 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
108817 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
108818 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
108819 +fl_create_56435 fl_create 5 56435 NULL
108820 +gnttab_map_56439 gnttab_map 2 56439 NULL
108821 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
108822 +set_connectable_56458 set_connectable 4 56458 NULL
108823 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
108824 +putused_user_56467 putused_user 3 56467 NULL
108825 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
108826 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
108827 +global_rt_period_56476 global_rt_period 0 56476 NULL
108828 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
108829 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
108830 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
108831 +init_map_ip_56508 init_map_ip 5 56508 NULL
108832 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
108833 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
108834 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
108835 +ip_options_get_56538 ip_options_get 4 56538 NULL
108836 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
108837 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
108838 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
108839 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
108840 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
108841 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
108842 +event_filter_write_56609 event_filter_write 3 56609 NULL
108843 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
108844 +gather_array_56641 gather_array 3 56641 NULL
108845 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
108846 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
108847 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
108848 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
108849 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
108850 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
108851 +build_map_info_56696 build_map_info 2 56696 NULL
108852 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
108853 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
108854 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
108855 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
108856 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
108857 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
108858 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
108859 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
108860 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
108861 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
108862 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
108863 +do_syslog_56807 do_syslog 3 56807 NULL
108864 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
108865 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
108866 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
108867 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
108868 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
108869 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
108870 +wb_lookup_56858 wb_lookup 2 56858 NULL
108871 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
108872 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
108873 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
108874 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
108875 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
108876 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
108877 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
108878 +strcspn_56913 strcspn 0 56913 NULL
108879 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
108880 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 NULL nohasharray
108881 +journal_init_revoke_56933 journal_init_revoke 2 56933 &CopyBufferToControlPacket_56933
108882 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
108883 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
108884 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
108885 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
108886 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
108887 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
108888 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
108889 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
108890 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
108891 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
108892 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
108893 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
108894 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
108895 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
108896 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
108897 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
108898 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
108899 +altera_get_note_57099 altera_get_note 6 57099 NULL
108900 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
108901 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
108902 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
108903 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
108904 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
108905 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
108906 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
108907 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
108908 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
108909 +changed_inode_57156 changed_inode 0 57156 NULL
108910 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
108911 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
108912 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
108913 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
108914 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
108915 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
108916 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
108917 +flush_space_57241 flush_space 3-0 57241 NULL
108918 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
108919 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
108920 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
108921 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
108922 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
108923 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
108924 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
108925 +fw_file_size_57307 fw_file_size 0 57307 NULL
108926 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
108927 +write_file_regval_57313 write_file_regval 3 57313 NULL
108928 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
108929 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
108930 +usblp_read_57342 usblp_read 3 57342 NULL
108931 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
108932 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
108933 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
108934 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
108935 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
108936 +read_file_blob_57406 read_file_blob 3 57406 NULL
108937 +enclosure_register_57412 enclosure_register 3 57412 NULL
108938 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
108939 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
108940 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
108941 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
108942 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
108943 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
108944 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
108945 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
108946 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
108947 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
108948 +skb_headlen_57501 skb_headlen 0 57501 NULL
108949 +copy_in_user_57502 copy_in_user 3 57502 NULL
108950 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
108951 +init_tag_map_57515 init_tag_map 3 57515 NULL
108952 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
108953 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
108954 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
108955 +cmm_read_57520 cmm_read 3 57520 NULL
108956 +inode_permission_57531 inode_permission 0 57531 NULL
108957 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
108958 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
108959 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
108960 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
108961 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
108962 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
108963 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
108964 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
108965 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
108966 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
108967 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
108968 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
108969 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
108970 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
108971 +mem_read_57631 mem_read 3 57631 NULL
108972 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
108973 +r3964_write_57662 r3964_write 4 57662 NULL
108974 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
108975 +__lgwrite_57669 __lgwrite 4 57669 NULL
108976 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
108977 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
108978 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
108979 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
108980 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
108981 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
108982 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
108983 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
108984 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
108985 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
108986 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
108987 +ld2_57794 ld2 0 57794 NULL
108988 +ivtv_read_57796 ivtv_read 3 57796 NULL
108989 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
108990 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
108991 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
108992 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
108993 +flash_read_57843 flash_read 3 57843 NULL
108994 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
108995 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
108996 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
108997 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL nohasharray
108998 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 &iio_read_first_n_kfifo_57910
108999 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
109000 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
109001 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
109002 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
109003 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
109004 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
109005 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
109006 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
109007 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
109008 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
109009 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
109010 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
109011 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
109012 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
109013 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
109014 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
109015 +mce_async_out_58056 mce_async_out 3 58056 NULL
109016 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
109017 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
109018 +cm4040_write_58079 cm4040_write 3 58079 NULL
109019 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
109020 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
109021 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
109022 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
109023 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
109024 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
109025 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
109026 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
109027 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
109028 +read_file_debug_58256 read_file_debug 3 58256 NULL
109029 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
109030 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
109031 +profile_load_58267 profile_load 3 58267 NULL
109032 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
109033 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
109034 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
109035 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
109036 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
109037 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
109038 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
109039 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3 58331 NULL
109040 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
109041 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
109042 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
109043 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
109044 +save_hint_58359 save_hint 2 58359 NULL
109045 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
109046 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
109047 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
109048 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
109049 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
109050 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
109051 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
109052 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
109053 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
109054 +capabilities_read_58457 capabilities_read 3 58457 NULL
109055 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
109056 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
109057 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
109058 +nv_rd08_58472 nv_rd08 0 58472 NULL
109059 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
109060 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
109061 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
109062 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
109063 +__clear_discard_58546 __clear_discard 2 58546 NULL
109064 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
109065 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
109066 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
109067 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
109068 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
109069 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
109070 +xip_file_read_58592 xip_file_read 3 58592 NULL
109071 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
109072 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
109073 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
109074 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
109075 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
109076 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
109077 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
109078 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
109079 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
109080 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
109081 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
109082 +find_zero_58685 find_zero 0-1 58685 NULL
109083 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
109084 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
109085 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
109086 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
109087 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
109088 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
109089 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
109090 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
109091 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
109092 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
109093 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
109094 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
109095 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
109096 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
109097 +write_file_58812 write_file 4 58812 NULL
109098 +ep_read_58813 ep_read 3 58813 NULL
109099 +command_write_58841 command_write 3 58841 NULL
109100 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
109101 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
109102 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
109103 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
109104 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
109105 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
109106 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
109107 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
109108 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
109109 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
109110 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
109111 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
109112 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
109113 +ep_write_59008 ep_write 3 59008 NULL
109114 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
109115 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
109116 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
109117 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
109118 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
109119 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
109120 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
109121 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
109122 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
109123 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
109124 +init_status_page_59124 init_status_page 0 59124 NULL
109125 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
109126 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
109127 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
109128 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
109129 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
109130 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
109131 +ksize_59176 ksize 0 59176 NULL
109132 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
109133 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
109134 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
109135 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
109136 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
109137 +dt3155_read_59226 dt3155_read 3 59226 NULL
109138 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
109139 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
109140 +nla_len_59258 nla_len 0 59258 NULL
109141 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
109142 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
109143 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
109144 +fd_copyout_59323 fd_copyout 3 59323 NULL
109145 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
109146 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
109147 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
109148 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
109149 +__map_request_59350 __map_request 0 59350 NULL
109150 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
109151 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
109152 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
109153 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
109154 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
109155 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
109156 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
109157 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
109158 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
109159 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
109160 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
109161 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
109162 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
109163 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
109164 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
109165 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
109166 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
109167 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
109168 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
109169 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
109170 +tunables_write_59563 tunables_write 3 59563 NULL
109171 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
109172 +write_pbl_59583 write_pbl 4 59583 NULL
109173 +memdup_user_59590 memdup_user 2 59590 NULL
109174 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
109175 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
109176 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
109177 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
109178 +mtrr_write_59622 mtrr_write 3 59622 NULL
109179 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
109180 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
109181 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
109182 +hidraw_read_59650 hidraw_read 3 59650 NULL
109183 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
109184 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
109185 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
109186 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
109187 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
109188 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
109189 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
109190 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
109191 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
109192 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
109193 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
109194 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
109195 +strnlen_59746 strnlen 0 59746 NULL
109196 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
109197 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
109198 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
109199 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
109200 +venus_remove_59781 venus_remove 4 59781 NULL
109201 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
109202 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
109203 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
109204 +ipw_write_59807 ipw_write 3 59807 NULL
109205 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
109206 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
109207 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
109208 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
109209 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
109210 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
109211 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
109212 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
109213 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
109214 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
109215 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
109216 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
109217 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
109218 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
109219 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
109220 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
109221 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
109222 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
109223 +lookup_node_59953 lookup_node 2 59953 NULL
109224 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
109225 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
109226 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
109227 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
109228 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
109229 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
109230 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
109231 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
109232 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
109233 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
109234 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
109235 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
109236 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
109237 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
109238 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
109239 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
109240 +compat_writev_60063 compat_writev 3 60063 NULL
109241 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
109242 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
109243 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
109244 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
109245 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
109246 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
109247 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
109248 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
109249 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
109250 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
109251 +init_state_60165 init_state 2 60165 NULL
109252 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
109253 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
109254 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
109255 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
109256 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
109257 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
109258 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
109259 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
109260 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
109261 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
109262 +printer_write_60276 printer_write 3 60276 NULL
109263 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
109264 +getDataLength_60301 getDataLength 0 60301 NULL
109265 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
109266 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
109267 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
109268 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
109269 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
109270 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
109271 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
109272 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
109273 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
109274 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
109275 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
109276 +driver_names_read_60399 driver_names_read 3 60399 NULL
109277 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
109278 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
109279 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
109280 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
109281 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
109282 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
109283 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
109284 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
109285 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
109286 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
109287 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
109288 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
109289 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
109290 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
109291 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
109292 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
109293 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
109294 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
109295 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
109296 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
109297 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
109298 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
109299 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
109300 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
109301 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
109302 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
109303 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
109304 +init_data_container_60709 init_data_container 1 60709 NULL
109305 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
109306 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
109307 +raid_status_60755 raid_status 5 60755 NULL
109308 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
109309 +opticon_write_60775 opticon_write 4 60775 NULL
109310 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
109311 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
109312 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
109313 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
109314 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
109315 +generic_writepages_60871 generic_writepages 0 60871 NULL
109316 +tipc_createport_60875 tipc_createport 4 60875 NULL
109317 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
109318 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
109319 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
109320 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
109321 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
109322 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
109323 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
109324 +pti_char_write_60960 pti_char_write 3 60960 NULL
109325 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
109326 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
109327 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
109328 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
109329 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
109330 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
109331 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
109332 +symtab_init_61050 symtab_init 2 61050 NULL
109333 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
109334 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
109335 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
109336 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
109337 +journal_stop_61080 journal_stop 0 61080 NULL
109338 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
109339 +get_derived_key_61100 get_derived_key 4 61100 NULL
109340 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
109341 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
109342 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
109343 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
109344 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
109345 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
109346 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
109347 +__vmalloc_61168 __vmalloc 1 61168 NULL
109348 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
109349 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
109350 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
109351 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
109352 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
109353 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
109354 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
109355 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
109356 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
109357 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
109358 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
109359 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
109360 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
109361 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
109362 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
109363 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
109364 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
109365 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
109366 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
109367 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
109368 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
109369 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
109370 +__fls_61340 __fls 0 61340 NULL nohasharray
109371 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
109372 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
109373 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
109374 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
109375 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
109376 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
109377 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
109378 +get_inode_info_61387 get_inode_info 0 61387 NULL
109379 +system_enable_write_61396 system_enable_write 3 61396 NULL
109380 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
109381 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
109382 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
109383 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
109384 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
109385 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
109386 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
109387 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
109388 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
109389 +erst_errno_61526 erst_errno 0 61526 NULL
109390 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
109391 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
109392 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
109393 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
109394 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
109395 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
109396 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
109397 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
109398 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
109399 +seq_open_private_61589 seq_open_private 3 61589 NULL
109400 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
109401 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
109402 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
109403 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
109404 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
109405 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
109406 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
109407 +resize_stripes_61650 resize_stripes 2 61650 NULL
109408 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
109409 +insert_one_name_61668 insert_one_name 7 61668 NULL
109410 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
109411 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
109412 +lock_loop_61681 lock_loop 1 61681 NULL
109413 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
109414 +filter_read_61692 filter_read 3 61692 NULL
109415 +prog_page_61711 prog_page 2 61711 NULL
109416 +iov_length_61716 iov_length 0 61716 NULL
109417 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
109418 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
109419 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
109420 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
109421 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
109422 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
109423 +num_counter_active_61789 num_counter_active 0 61789 NULL
109424 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
109425 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
109426 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
109427 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
109428 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
109429 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
109430 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
109431 +get_fw_name_61874 get_fw_name 3 61874 NULL
109432 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
109433 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
109434 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
109435 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
109436 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
109437 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
109438 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
109439 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
109440 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
109441 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
109442 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
109443 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
109444 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
109445 +fix_read_error_61965 fix_read_error 4 61965 NULL
109446 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
109447 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
109448 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
109449 +cow_file_range_61979 cow_file_range 3 61979 NULL
109450 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
109451 +dequeue_event_62000 dequeue_event 3 62000 NULL
109452 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
109453 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
109454 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
109455 +SYSC_select_62024 SYSC_select 1 62024 NULL
109456 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
109457 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
109458 +do_pselect_62061 do_pselect 1 62061 NULL
109459 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
109460 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
109461 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
109462 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
109463 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
109464 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
109465 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
109466 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
109467 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
109468 +ql_status_62135 ql_status 5 62135 NULL nohasharray
109469 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
109470 +video_usercopy_62151 video_usercopy 2 62151 NULL
109471 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
109472 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
109473 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
109474 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
109475 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
109476 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
109477 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
109478 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
109479 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
109480 +allocate_partition_62245 allocate_partition 4 62245 NULL
109481 +security_file_permission_62278 security_file_permission 0 62278 NULL
109482 +get_random_int_62279 get_random_int 0 62279 NULL
109483 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
109484 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
109485 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
109486 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
109487 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
109488 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
109489 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
109490 +subseq_list_62332 subseq_list 3-0 62332 NULL
109491 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
109492 +flash_write_62354 flash_write 3 62354 NULL
109493 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
109494 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
109495 +altera_irscan_62396 altera_irscan 2 62396 NULL
109496 +set_ssp_62411 set_ssp 4 62411 NULL
109497 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
109498 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
109499 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
109500 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
109501 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
109502 +debugfs_read_62535 debugfs_read 3 62535 NULL
109503 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
109504 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
109505 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
109506 +get_subdir_62581 get_subdir 3 62581 NULL
109507 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
109508 +get_desc_base_62617 get_desc_base 0 62617 NULL
109509 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
109510 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
109511 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
109512 +write_62671 write 3 62671 NULL
109513 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
109514 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
109515 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
109516 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
109517 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
109518 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
109519 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
109520 +rdm_62719 rdm 0 62719 NULL
109521 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
109522 +key_replays_read_62746 key_replays_read 3 62746 NULL
109523 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
109524 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
109525 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
109526 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
109527 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
109528 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
109529 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
109530 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
109531 +is_first_ref_62805 is_first_ref 0 62805 NULL
109532 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
109533 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
109534 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
109535 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
109536 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
109537 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
109538 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
109539 +set_swbp_62853 set_swbp 3 62853 NULL
109540 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
109541 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
109542 +aoechr_write_62883 aoechr_write 3 62883 NULL
109543 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
109544 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
109545 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
109546 +getdqbuf_62908 getdqbuf 1 62908 NULL
109547 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
109548 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
109549 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
109550 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
109551 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
109552 +send_write_62969 send_write 0-3 62969 NULL
109553 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
109554 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
109555 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
109556 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
109557 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
109558 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
109559 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
109560 +unlink1_63059 unlink1 3 63059 NULL
109561 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
109562 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
109563 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
109564 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
109565 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
109566 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
109567 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
109568 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
109569 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
109570 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
109571 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
109572 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
109573 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
109574 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
109575 +vme_master_read_63221 vme_master_read 0 63221 NULL
109576 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
109577 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
109578 +ptp_read_63251 ptp_read 4 63251 NULL
109579 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
109580 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
109581 +raid5_resize_63306 raid5_resize 2 63306 NULL
109582 +proc_info_read_63344 proc_info_read 3 63344 NULL
109583 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
109584 +idmouse_read_63374 idmouse_read 3 63374 NULL
109585 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
109586 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
109587 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
109588 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
109589 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
109590 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
109591 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
109592 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
109593 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
109594 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
109595 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
109596 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
109597 +do_work_63483 do_work 0 63483 NULL
109598 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
109599 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
109600 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
109601 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
109602 +save_hint_63497 save_hint 2 63497 NULL
109603 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
109604 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
109605 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
109606 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
109607 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
109608 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
109609 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
109610 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
109611 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
109612 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
109613 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
109614 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
109615 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
109616 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
109617 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
109618 +write_debug_level_63613 write_debug_level 3 63613 NULL
109619 +module_alloc_63630 module_alloc 1 63630 NULL
109620 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
109621 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
109622 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
109623 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
109624 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
109625 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
109626 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
109627 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
109628 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
109629 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
109630 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
109631 +bin_search_63697 bin_search 0 63697 NULL
109632 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
109633 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
109634 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
109635 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
109636 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
109637 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
109638 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
109639 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
109640 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
109641 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
109642 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
109643 +prepare_copy_63826 prepare_copy 2 63826 NULL
109644 +sel_write_load_63830 sel_write_load 3 63830 NULL
109645 +ll_readlink_63836 ll_readlink 3 63836 NULL
109646 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
109647 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
109648 +divas_write_63901 divas_write 3 63901 NULL
109649 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
109650 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
109651 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
109652 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
109653 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
109654 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
109655 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
109656 +__team_options_register_63941 __team_options_register 3 63941 NULL
109657 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
109658 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
109659 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
109660 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
109661 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
109662 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
109663 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
109664 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
109665 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
109666 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
109667 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
109668 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
109669 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
109670 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
109671 +__sock_create_64069 __sock_create 0 64069 NULL
109672 +get_u8_64076 get_u8 0 64076 NULL
109673 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
109674 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
109675 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
109676 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
109677 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
109678 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
109679 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
109680 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
109681 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
109682 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
109683 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
109684 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
109685 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
109686 +init_bch_64130 init_bch 2-1 64130 NULL
109687 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
109688 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
109689 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
109690 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
109691 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
109692 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
109693 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
109694 +read_pulse_64227 read_pulse 0-3 64227 NULL
109695 +ea_len_64229 ea_len 0 64229 NULL
109696 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
109697 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
109698 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
109699 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
109700 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
109701 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
109702 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
109703 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
109704 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
109705 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
109706 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
109707 +ffz_64324 ffz 0-1 64324 NULL
109708 +map_region_64328 map_region 1 64328 NULL
109709 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
109710 +ts_write_64336 ts_write 3 64336 NULL
109711 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
109712 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
109713 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
109714 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
109715 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
109716 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
109717 +reg_create_64372 reg_create 5 64372 NULL
109718 +ilo_write_64378 ilo_write 3 64378 NULL
109719 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
109720 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
109721 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
109722 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
109723 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
109724 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
109725 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
109726 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
109727 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
109728 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
109729 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
109730 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
109731 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
109732 +single_open_size_64483 single_open_size 4 64483 NULL
109733 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
109734 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
109735 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
109736 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
109737 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
109738 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
109739 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
109740 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
109741 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
109742 +SyS_bind_64544 SyS_bind 3 64544 NULL
109743 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
109744 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
109745 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
109746 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
109747 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
109748 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
109749 +do_erase_64574 do_erase 4 64574 NULL
109750 +fanotify_write_64623 fanotify_write 3 64623 NULL
109751 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
109752 +to_dblock_64655 to_dblock 0-1 64655 NULL
109753 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
109754 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
109755 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
109756 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
109757 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
109758 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
109759 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
109760 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
109761 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
109762 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
109763 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
109764 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
109765 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
109766 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
109767 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
109768 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
109769 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
109770 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
109771 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
109772 +message_for_md_64777 message_for_md 5 64777 NULL
109773 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
109774 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
109775 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
109776 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
109777 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
109778 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
109779 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
109780 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
109781 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
109782 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
109783 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
109784 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
109785 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
109786 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
109787 +mk_pid_64894 mk_pid 0-3 64894 NULL
109788 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
109789 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
109790 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
109791 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
109792 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
109793 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
109794 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
109795 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
109796 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
109797 +insert_dent_65034 insert_dent 7 65034 NULL
109798 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
109799 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
109800 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
109801 +make_idx_node_65068 make_idx_node 0 65068 NULL
109802 +count_run_65072 count_run 0-2-4-5 65072 NULL
109803 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
109804 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
109805 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
109806 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
109807 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
109808 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
109809 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
109810 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
109811 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
109812 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
109813 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
109814 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
109815 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
109816 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
109817 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
109818 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
109819 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
109820 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
109821 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
109822 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
109823 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
109824 +get_var_len_65304 get_var_len 0 65304 NULL
109825 +unpack_array_65318 unpack_array 0 65318 NULL
109826 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
109827 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
109828 +init_list_set_65351 init_list_set 3-2 65351 NULL
109829 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
109830 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
109831 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
109832 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
109833 +SyS_writev_65372 SyS_writev 3 65372 NULL
109834 +mi_set_context_65395 mi_set_context 0 65395 NULL
109835 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
109836 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
109837 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
109838 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
109839 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
109840 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
109841 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
109842 +device_add_groups_65423 device_add_groups 0 65423 NULL
109843 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
109844 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
109845 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
109846 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
109847 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
109848 +clear_user_65470 clear_user 2 65470 NULL
109849 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
109850 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
109851 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
109852 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
109853 new file mode 100644
109854 index 0000000..87dd5e2
109855 --- /dev/null
109856 +++ b/tools/gcc/size_overflow_plugin.c
109857 @@ -0,0 +1,3840 @@
109858 +/*
109859 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
109860 + * Licensed under the GPL v2, or (at your option) v3
109861 + *
109862 + * Homepage:
109863 + * http://www.grsecurity.net/~ephox/overflow_plugin/
109864 + *
109865 + * Documentation:
109866 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
109867 + *
109868 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
109869 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
109870 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
109871 + *
109872 + * Usage:
109873 + * $ 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
109874 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
109875 + */
109876 +
109877 +#include "gcc-plugin.h"
109878 +#include "config.h"
109879 +#include "system.h"
109880 +#include "coretypes.h"
109881 +#include "tree.h"
109882 +#include "tree-pass.h"
109883 +#include "intl.h"
109884 +#include "plugin-version.h"
109885 +#include "tm.h"
109886 +#include "toplev.h"
109887 +#include "function.h"
109888 +#include "tree-flow.h"
109889 +#include "plugin.h"
109890 +#include "gimple.h"
109891 +#include "diagnostic.h"
109892 +#include "cfgloop.h"
109893 +
109894 +#if BUILDING_GCC_VERSION >= 4008
109895 +#define TODO_dump_func 0
109896 +#define TODO_dump_cgraph 0
109897 +#endif
109898 +
109899 +#define __unused __attribute__((__unused__))
109900 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
109901 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
109902 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
109903 +#define BEFORE_STMT true
109904 +#define AFTER_STMT false
109905 +#define CREATE_NEW_VAR NULL_TREE
109906 +#define CODES_LIMIT 32
109907 +#define MAX_PARAM 31
109908 +#define VEC_LEN 128
109909 +#define MY_STMT GF_PLF_1
109910 +#define NO_CAST_CHECK GF_PLF_2
109911 +#define RET_CHECK NULL_TREE
109912 +#define CANNOT_FIND_ARG 32
109913 +#define WRONG_NODE 32
109914 +#define NOT_INTENTIONAL_ASM NULL
109915 +#define MIN_CHECK true
109916 +#define MAX_CHECK false
109917 +
109918 +#if BUILDING_GCC_VERSION == 4005
109919 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
109920 +#endif
109921 +
109922 +struct size_overflow_hash {
109923 + const struct size_overflow_hash * const next;
109924 + const char * const name;
109925 + const unsigned int param;
109926 +};
109927 +
109928 +#include "size_overflow_hash.h"
109929 +
109930 +enum mark {
109931 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
109932 +};
109933 +
109934 +static unsigned int call_count;
109935 +
109936 +struct visited {
109937 + struct visited *next;
109938 + const_tree fndecl;
109939 + unsigned int num;
109940 + const_gimple first_stmt;
109941 +};
109942 +
109943 +struct next_cgraph_node {
109944 + struct next_cgraph_node *next;
109945 + struct cgraph_node *current_function;
109946 + tree callee_fndecl;
109947 + unsigned int num;
109948 +};
109949 +
109950 +struct interesting_node {
109951 + struct interesting_node *next;
109952 + gimple first_stmt;
109953 + const_tree fndecl;
109954 + tree node;
109955 +#if BUILDING_GCC_VERSION <= 4007
109956 + VEC(tree, gc) *last_nodes;
109957 +#else
109958 + vec<tree, va_gc> *last_nodes;
109959 +#endif
109960 + unsigned int num;
109961 + enum mark intentional_attr_decl;
109962 + enum mark intentional_attr_cur_fndecl;
109963 + gimple intentional_mark_from_gimple;
109964 +};
109965 +
109966 +int plugin_is_GPL_compatible;
109967 +void debug_gimple_stmt(gimple gs);
109968 +
109969 +static tree report_size_overflow_decl;
109970 +static const_tree const_char_ptr_type_node;
109971 +
109972 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
109973 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
109974 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
109975 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
109976 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
109977 +
109978 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
109979 +static tree get_size_overflow_type(gimple stmt, const_tree node);
109980 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
109981 +
109982 +static struct plugin_info size_overflow_plugin_info = {
109983 + .version = "20131120beta",
109984 + .help = "no-size-overflow\tturn off size overflow checking\n",
109985 +};
109986 +
109987 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
109988 +{
109989 + unsigned int arg_count;
109990 + enum tree_code code = TREE_CODE(*node);
109991 +
109992 + switch (code) {
109993 + case FUNCTION_DECL:
109994 + arg_count = type_num_arguments(TREE_TYPE(*node));
109995 + break;
109996 + case FUNCTION_TYPE:
109997 + case METHOD_TYPE:
109998 + arg_count = type_num_arguments(*node);
109999 + break;
110000 + default:
110001 + *no_add_attrs = true;
110002 + error("%s: %qE attribute only applies to functions", __func__, name);
110003 + return NULL_TREE;
110004 + }
110005 +
110006 + for (; args; args = TREE_CHAIN(args)) {
110007 + tree position = TREE_VALUE(args);
110008 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110009 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110010 + *no_add_attrs = true;
110011 + }
110012 + }
110013 + return NULL_TREE;
110014 +}
110015 +
110016 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110017 +{
110018 + unsigned int arg_count;
110019 + enum tree_code code = TREE_CODE(*node);
110020 +
110021 + switch (code) {
110022 + case FUNCTION_DECL:
110023 + arg_count = type_num_arguments(TREE_TYPE(*node));
110024 + break;
110025 + case FUNCTION_TYPE:
110026 + case METHOD_TYPE:
110027 + arg_count = type_num_arguments(*node);
110028 + break;
110029 + case FIELD_DECL:
110030 + return NULL_TREE;
110031 + default:
110032 + *no_add_attrs = true;
110033 + error("%qE attribute only applies to functions", name);
110034 + return NULL_TREE;
110035 + }
110036 +
110037 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
110038 + return NULL_TREE;
110039 +
110040 + for (; args; args = TREE_CHAIN(args)) {
110041 + tree position = TREE_VALUE(args);
110042 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110043 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110044 + *no_add_attrs = true;
110045 + }
110046 + }
110047 + return NULL_TREE;
110048 +}
110049 +
110050 +static struct attribute_spec size_overflow_attr = {
110051 + .name = "size_overflow",
110052 + .min_length = 1,
110053 + .max_length = -1,
110054 + .decl_required = true,
110055 + .type_required = false,
110056 + .function_type_required = false,
110057 + .handler = handle_size_overflow_attribute,
110058 +#if BUILDING_GCC_VERSION >= 4007
110059 + .affects_type_identity = false
110060 +#endif
110061 +};
110062 +
110063 +static struct attribute_spec intentional_overflow_attr = {
110064 + .name = "intentional_overflow",
110065 + .min_length = 1,
110066 + .max_length = -1,
110067 + .decl_required = true,
110068 + .type_required = false,
110069 + .function_type_required = false,
110070 + .handler = handle_intentional_overflow_attribute,
110071 +#if BUILDING_GCC_VERSION >= 4007
110072 + .affects_type_identity = false
110073 +#endif
110074 +};
110075 +
110076 +static void register_attributes(void __unused *event_data, void __unused *data)
110077 +{
110078 + register_attribute(&size_overflow_attr);
110079 + register_attribute(&intentional_overflow_attr);
110080 +}
110081 +
110082 +static bool is_bool(const_tree node)
110083 +{
110084 + const_tree type;
110085 +
110086 + if (node == NULL_TREE)
110087 + return false;
110088 +
110089 + type = TREE_TYPE(node);
110090 + if (!INTEGRAL_TYPE_P(type))
110091 + return false;
110092 + if (TREE_CODE(type) == BOOLEAN_TYPE)
110093 + return true;
110094 + if (TYPE_PRECISION(type) == 1)
110095 + return true;
110096 + return false;
110097 +}
110098 +
110099 +static bool skip_types(const_tree var)
110100 +{
110101 + tree type;
110102 + enum tree_code code;
110103 +
110104 + if (is_gimple_constant(var))
110105 + return true;
110106 +
110107 + switch (TREE_CODE(var)) {
110108 + case ADDR_EXPR:
110109 +#if BUILDING_GCC_VERSION >= 4006
110110 + case MEM_REF:
110111 +#endif
110112 + case ARRAY_REF:
110113 + case BIT_FIELD_REF:
110114 + case INDIRECT_REF:
110115 + case TARGET_MEM_REF:
110116 + case COMPONENT_REF:
110117 + case VAR_DECL:
110118 + case VIEW_CONVERT_EXPR:
110119 + return true;
110120 + default:
110121 + break;
110122 + }
110123 +
110124 + code = TREE_CODE(var);
110125 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
110126 +
110127 + type = TREE_TYPE(var);
110128 + switch (TREE_CODE(type)) {
110129 + case INTEGER_TYPE:
110130 + case ENUMERAL_TYPE:
110131 + return false;
110132 + case BOOLEAN_TYPE:
110133 + return is_bool(var);
110134 + default:
110135 + return true;
110136 + }
110137 +}
110138 +
110139 +static inline gimple get_def_stmt(const_tree node)
110140 +{
110141 + gcc_assert(node != NULL_TREE);
110142 +
110143 + if (skip_types(node))
110144 + return NULL;
110145 +
110146 + if (TREE_CODE(node) != SSA_NAME)
110147 + return NULL;
110148 + return SSA_NAME_DEF_STMT(node);
110149 +}
110150 +
110151 +static unsigned char get_tree_code(const_tree type)
110152 +{
110153 + switch (TREE_CODE(type)) {
110154 + case ARRAY_TYPE:
110155 + return 0;
110156 + case BOOLEAN_TYPE:
110157 + return 1;
110158 + case ENUMERAL_TYPE:
110159 + return 2;
110160 + case FUNCTION_TYPE:
110161 + return 3;
110162 + case INTEGER_TYPE:
110163 + return 4;
110164 + case POINTER_TYPE:
110165 + return 5;
110166 + case RECORD_TYPE:
110167 + return 6;
110168 + case UNION_TYPE:
110169 + return 7;
110170 + case VOID_TYPE:
110171 + return 8;
110172 + case REAL_TYPE:
110173 + return 9;
110174 + case VECTOR_TYPE:
110175 + return 10;
110176 + case REFERENCE_TYPE:
110177 + return 11;
110178 + case OFFSET_TYPE:
110179 + return 12;
110180 + case COMPLEX_TYPE:
110181 + return 13;
110182 + default:
110183 + debug_tree((tree)type);
110184 + gcc_unreachable();
110185 + }
110186 +}
110187 +
110188 +struct function_hash {
110189 + size_t tree_codes_len;
110190 + unsigned char tree_codes[CODES_LIMIT];
110191 + tree fndecl;
110192 + unsigned int hash;
110193 +};
110194 +
110195 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
110196 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
110197 +{
110198 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
110199 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
110200 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
110201 +
110202 + unsigned int m = 0x57559429;
110203 + unsigned int n = 0x5052acdb;
110204 + const unsigned int *key4 = (const unsigned int *)key;
110205 + unsigned int h = len;
110206 + unsigned int k = len + seed + n;
110207 + unsigned long long p;
110208 +
110209 + while (len >= 8) {
110210 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
110211 + len -= 8;
110212 + }
110213 + if (len >= 4) {
110214 + cwmixb(key4[0]) key4 += 1;
110215 + len -= 4;
110216 + }
110217 + if (len)
110218 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
110219 + cwmixb(h ^ (k + n));
110220 + return k ^ h;
110221 +
110222 +#undef cwfold
110223 +#undef cwmixa
110224 +#undef cwmixb
110225 +}
110226 +
110227 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
110228 +{
110229 + unsigned int fn, codes, seed = 0;
110230 +
110231 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
110232 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
110233 +
110234 + fn_hash_data->hash = fn ^ codes;
110235 +}
110236 +
110237 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
110238 +{
110239 + gcc_assert(type != NULL_TREE);
110240 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
110241 +
110242 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
110243 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
110244 + fn_hash_data->tree_codes_len++;
110245 + type = TREE_TYPE(type);
110246 + }
110247 +}
110248 +
110249 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
110250 +{
110251 + const_tree result;
110252 +
110253 + gcc_assert(node != NULL_TREE);
110254 +
110255 + if (DECL_P(node)) {
110256 + result = DECL_RESULT(node);
110257 + if (result != NULL_TREE)
110258 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
110259 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110260 + }
110261 +
110262 + gcc_assert(TYPE_P(node));
110263 +
110264 + if (TREE_CODE(node) == FUNCTION_TYPE)
110265 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110266 +
110267 + return set_node_codes(node, fn_hash_data);
110268 +}
110269 +
110270 +static void set_function_codes(struct function_hash *fn_hash_data)
110271 +{
110272 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
110273 + enum tree_code code = TREE_CODE(type);
110274 +
110275 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
110276 +
110277 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
110278 +
110279 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
110280 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
110281 +}
110282 +
110283 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
110284 +{
110285 + const struct size_overflow_hash *entry;
110286 + struct function_hash fn_hash_data;
110287 + const char *func_name;
110288 +
110289 + // skip builtins __builtin_constant_p
110290 + if (DECL_BUILT_IN(fndecl))
110291 + return NULL;
110292 +
110293 + fn_hash_data.fndecl = fndecl;
110294 + fn_hash_data.tree_codes_len = 0;
110295 +
110296 + set_function_codes(&fn_hash_data);
110297 + gcc_assert(fn_hash_data.tree_codes_len != 0);
110298 +
110299 + func_name = ASM_NAME(fn_hash_data.fndecl);
110300 + set_hash(func_name, &fn_hash_data);
110301 +
110302 + entry = size_overflow_hash[fn_hash_data.hash];
110303 +
110304 + while (entry) {
110305 + if (!strcmp(entry->name, func_name))
110306 + return entry;
110307 + entry = entry->next;
110308 + }
110309 + return NULL;
110310 +}
110311 +
110312 +static void print_missing_msg(tree func, unsigned int argnum)
110313 +{
110314 + location_t loc;
110315 + const char *curfunc;
110316 + struct function_hash fn_hash_data;
110317 +
110318 + fn_hash_data.fndecl = DECL_ORIGIN(func);
110319 + fn_hash_data.tree_codes_len = 0;
110320 +
110321 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
110322 + curfunc = ASM_NAME(fn_hash_data.fndecl);
110323 +
110324 + set_function_codes(&fn_hash_data);
110325 + set_hash(curfunc, &fn_hash_data);
110326 +
110327 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
110328 +}
110329 +
110330 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
110331 +{
110332 + tree var;
110333 + unsigned int argnum = 1;
110334 +
110335 + if (TREE_CODE(arg) == SSA_NAME)
110336 + arg = SSA_NAME_VAR(arg);
110337 +
110338 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
110339 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
110340 + continue;
110341 + if (!skip_types(var))
110342 + return argnum;
110343 + }
110344 +
110345 + return CANNOT_FIND_ARG;
110346 +}
110347 +
110348 +static tree create_new_var(tree type)
110349 +{
110350 + tree new_var = create_tmp_var(type, "cicus");
110351 +
110352 +#if BUILDING_GCC_VERSION <= 4007
110353 + add_referenced_var(new_var);
110354 +#endif
110355 + return new_var;
110356 +}
110357 +
110358 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
110359 +{
110360 + gimple assign;
110361 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110362 + tree type = TREE_TYPE(rhs1);
110363 + tree lhs = create_new_var(type);
110364 +
110365 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
110366 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
110367 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110368 +
110369 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
110370 + update_stmt(assign);
110371 + gimple_set_plf(assign, MY_STMT, true);
110372 + return assign;
110373 +}
110374 +
110375 +static tree cast_a_tree(tree type, tree var)
110376 +{
110377 + gcc_assert(type != NULL_TREE);
110378 + gcc_assert(var != NULL_TREE);
110379 + gcc_assert(fold_convertible_p(type, var));
110380 +
110381 + return fold_convert(type, var);
110382 +}
110383 +
110384 +static tree get_lhs(const_gimple stmt)
110385 +{
110386 + switch (gimple_code(stmt)) {
110387 + case GIMPLE_ASSIGN:
110388 + case GIMPLE_CALL:
110389 + return gimple_get_lhs(stmt);
110390 + case GIMPLE_PHI:
110391 + return gimple_phi_result(stmt);
110392 + default:
110393 + return NULL_TREE;
110394 + }
110395 +}
110396 +
110397 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
110398 +{
110399 + const_gimple def_stmt = get_def_stmt(rhs);
110400 +
110401 + if (force)
110402 + return false;
110403 +
110404 + if (is_gimple_constant(rhs))
110405 + return false;
110406 +
110407 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110408 + return false;
110409 +
110410 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
110411 + return false;
110412 +
110413 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
110414 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110415 + return false;
110416 +
110417 + return true;
110418 +}
110419 +
110420 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
110421 +{
110422 + gimple assign, def_stmt;
110423 +
110424 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
110425 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
110426 + gcc_unreachable();
110427 +
110428 + def_stmt = get_def_stmt(rhs);
110429 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
110430 + return def_stmt;
110431 +
110432 + if (lhs == CREATE_NEW_VAR)
110433 + lhs = create_new_var(dst_type);
110434 +
110435 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
110436 +
110437 + if (!gsi_end_p(*gsi)) {
110438 + location_t loc = gimple_location(gsi_stmt(*gsi));
110439 + gimple_set_location(assign, loc);
110440 + }
110441 +
110442 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110443 +
110444 + if (before)
110445 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
110446 + else
110447 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
110448 + update_stmt(assign);
110449 + return assign;
110450 +}
110451 +
110452 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
110453 +{
110454 + gimple_stmt_iterator gsi;
110455 + tree lhs;
110456 + gimple new_stmt;
110457 +
110458 + if (rhs == NULL_TREE)
110459 + return NULL_TREE;
110460 +
110461 + gsi = gsi_for_stmt(stmt);
110462 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110463 + gimple_set_plf(new_stmt, MY_STMT, true);
110464 +
110465 + lhs = get_lhs(new_stmt);
110466 + gcc_assert(lhs != NULL_TREE);
110467 + return lhs;
110468 +}
110469 +
110470 +static tree cast_to_TI_type(gimple stmt, tree node)
110471 +{
110472 + gimple_stmt_iterator gsi;
110473 + gimple cast_stmt;
110474 + tree type = TREE_TYPE(node);
110475 +
110476 + if (types_compatible_p(type, intTI_type_node))
110477 + return node;
110478 +
110479 + gsi = gsi_for_stmt(stmt);
110480 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110481 + gimple_set_plf(cast_stmt, MY_STMT, true);
110482 + return gimple_assign_lhs(cast_stmt);
110483 +}
110484 +
110485 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
110486 +{
110487 + tree lhs, new_lhs;
110488 + gimple_stmt_iterator gsi;
110489 +
110490 + if (rhs1 == NULL_TREE) {
110491 + debug_gimple_stmt(oldstmt);
110492 + error("%s: rhs1 is NULL_TREE", __func__);
110493 + gcc_unreachable();
110494 + }
110495 +
110496 + switch (gimple_code(oldstmt)) {
110497 + case GIMPLE_ASM:
110498 + lhs = rhs1;
110499 + break;
110500 + case GIMPLE_CALL:
110501 + case GIMPLE_ASSIGN:
110502 + lhs = gimple_get_lhs(oldstmt);
110503 + break;
110504 + default:
110505 + debug_gimple_stmt(oldstmt);
110506 + gcc_unreachable();
110507 + }
110508 +
110509 + gsi = gsi_for_stmt(oldstmt);
110510 + pointer_set_insert(visited, oldstmt);
110511 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
110512 + basic_block next_bb, cur_bb;
110513 + const_edge e;
110514 +
110515 + gcc_assert(before == false);
110516 + gcc_assert(stmt_can_throw_internal(oldstmt));
110517 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
110518 + gcc_assert(!gsi_end_p(gsi));
110519 +
110520 + cur_bb = gimple_bb(oldstmt);
110521 + next_bb = cur_bb->next_bb;
110522 + e = find_edge(cur_bb, next_bb);
110523 + gcc_assert(e != NULL);
110524 + gcc_assert(e->flags & EDGE_FALLTHRU);
110525 +
110526 + gsi = gsi_after_labels(next_bb);
110527 + gcc_assert(!gsi_end_p(gsi));
110528 +
110529 + before = true;
110530 + oldstmt = gsi_stmt(gsi);
110531 + }
110532 +
110533 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
110534 + return new_lhs;
110535 +}
110536 +
110537 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
110538 +{
110539 + gimple stmt;
110540 + gimple_stmt_iterator gsi;
110541 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
110542 +
110543 + if (gimple_plf(oldstmt, MY_STMT))
110544 + return lhs;
110545 +
110546 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
110547 + rhs1 = gimple_assign_rhs1(oldstmt);
110548 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
110549 + }
110550 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
110551 + rhs2 = gimple_assign_rhs2(oldstmt);
110552 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
110553 + }
110554 +
110555 + stmt = gimple_copy(oldstmt);
110556 + gimple_set_location(stmt, gimple_location(oldstmt));
110557 + gimple_set_plf(stmt, MY_STMT, true);
110558 +
110559 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
110560 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
110561 +
110562 + size_overflow_type = get_size_overflow_type(oldstmt, node);
110563 +
110564 + new_var = create_new_var(size_overflow_type);
110565 + new_var = make_ssa_name(new_var, stmt);
110566 + gimple_assign_set_lhs(stmt, new_var);
110567 +
110568 + if (rhs1 != NULL_TREE)
110569 + gimple_assign_set_rhs1(stmt, rhs1);
110570 +
110571 + if (rhs2 != NULL_TREE)
110572 + gimple_assign_set_rhs2(stmt, rhs2);
110573 +#if BUILDING_GCC_VERSION >= 4007
110574 + if (rhs3 != NULL_TREE)
110575 + gimple_assign_set_rhs3(stmt, rhs3);
110576 +#endif
110577 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
110578 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
110579 +
110580 + gsi = gsi_for_stmt(oldstmt);
110581 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
110582 + update_stmt(stmt);
110583 + pointer_set_insert(visited, oldstmt);
110584 + return gimple_assign_lhs(stmt);
110585 +}
110586 +
110587 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
110588 +{
110589 + gimple assign;
110590 + gimple_stmt_iterator gsi;
110591 + basic_block first_bb;
110592 +
110593 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
110594 +
110595 + if (bb->index == 0) {
110596 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110597 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110598 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
110599 + bb = first_bb;
110600 + }
110601 +
110602 + gsi = gsi_after_labels(bb);
110603 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110604 + gimple_set_plf(assign, MY_STMT, true);
110605 +
110606 + return gimple_assign_lhs(assign);
110607 +}
110608 +
110609 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
110610 +{
110611 + gimple_stmt_iterator gsi;
110612 + gimple assign, def_stmt = get_def_stmt(new_arg);
110613 +
110614 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
110615 + gsi = gsi_after_labels(gimple_bb(def_stmt));
110616 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
110617 + } else {
110618 + gsi = gsi_for_stmt(def_stmt);
110619 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
110620 + }
110621 +
110622 + gimple_set_plf(assign, MY_STMT, true);
110623 + return gimple_assign_lhs(assign);
110624 +}
110625 +
110626 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
110627 +{
110628 + basic_block bb;
110629 + gimple_stmt_iterator gsi;
110630 + const_gimple def_stmt;
110631 + gimple assign;
110632 +
110633 + def_stmt = get_def_stmt(arg);
110634 + bb = gimple_bb(def_stmt);
110635 + gcc_assert(bb->index != 0);
110636 + gsi = gsi_after_labels(bb);
110637 +
110638 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
110639 + gimple_set_plf(assign, MY_STMT, true);
110640 + return gimple_assign_lhs(assign);
110641 +}
110642 +
110643 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
110644 +{
110645 + tree size_overflow_type;
110646 + tree arg;
110647 + const_gimple def_stmt;
110648 +
110649 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
110650 + return new_arg;
110651 +
110652 + arg = gimple_phi_arg_def(oldstmt, i);
110653 + def_stmt = get_def_stmt(arg);
110654 + gcc_assert(def_stmt != NULL);
110655 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
110656 +
110657 + switch (gimple_code(def_stmt)) {
110658 + case GIMPLE_PHI:
110659 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
110660 + case GIMPLE_NOP: {
110661 + basic_block bb;
110662 +
110663 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
110664 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
110665 + }
110666 + case GIMPLE_ASM: {
110667 + gimple_stmt_iterator gsi;
110668 + gimple assign, stmt = get_def_stmt(arg);
110669 +
110670 + gsi = gsi_for_stmt(stmt);
110671 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
110672 + gimple_set_plf(assign, MY_STMT, true);
110673 + return gimple_assign_lhs(assign);
110674 + }
110675 + default:
110676 + gcc_assert(new_arg != NULL_TREE);
110677 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
110678 + return use_phi_ssa_name(ssa_name_var, new_arg);
110679 + }
110680 +}
110681 +
110682 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
110683 +{
110684 + basic_block bb;
110685 + gimple phi;
110686 + gimple_seq seq;
110687 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
110688 +
110689 + bb = gsi_bb(gsi);
110690 +
110691 + if (result == NULL_TREE) {
110692 + tree old_result = gimple_phi_result(oldstmt);
110693 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
110694 +
110695 + result = create_new_var(size_overflow_type);
110696 + }
110697 +
110698 + phi = create_phi_node(result, bb);
110699 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
110700 + seq = phi_nodes(bb);
110701 + gsi = gsi_last(seq);
110702 + gsi_remove(&gsi, false);
110703 +
110704 + gsi = gsi_for_stmt(oldstmt);
110705 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
110706 + gimple_set_bb(phi, bb);
110707 + gimple_set_plf(phi, MY_STMT, true);
110708 + return phi;
110709 +}
110710 +
110711 +#if BUILDING_GCC_VERSION <= 4007
110712 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
110713 +#else
110714 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
110715 +#endif
110716 +{
110717 + gimple new_phi;
110718 + unsigned int i;
110719 + tree arg, result;
110720 + location_t loc = gimple_location(oldstmt);
110721 +
110722 +#if BUILDING_GCC_VERSION <= 4007
110723 + gcc_assert(!VEC_empty(tree, args));
110724 +#else
110725 + gcc_assert(!args->is_empty());
110726 +#endif
110727 +
110728 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
110729 + result = gimple_phi_result(new_phi);
110730 + ssa_name_var = SSA_NAME_VAR(result);
110731 +
110732 +
110733 +#if BUILDING_GCC_VERSION == 4005
110734 + for (i = 0; i < VEC_length(tree, args); i++) {
110735 + arg = VEC_index(tree, args, i);
110736 +#elif BUILDING_GCC_VERSION <= 4007
110737 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
110738 +#else
110739 + FOR_EACH_VEC_ELT(*args, i, arg) {
110740 +#endif
110741 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
110742 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
110743 + }
110744 +
110745 +#if BUILDING_GCC_VERSION <= 4007
110746 + VEC_free(tree, gc, args);
110747 +#else
110748 + vec_free(args);
110749 +#endif
110750 + update_stmt(new_phi);
110751 + return result;
110752 +}
110753 +
110754 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
110755 +{
110756 + tree ssa_name_var = NULL_TREE;
110757 +#if BUILDING_GCC_VERSION <= 4007
110758 + VEC(tree, gc) *args;
110759 +#else
110760 + vec<tree, va_gc> *args;
110761 +#endif
110762 + gimple oldstmt = get_def_stmt(orig_result);
110763 + unsigned int i, len = gimple_phi_num_args(oldstmt);
110764 +
110765 + pointer_set_insert(visited, oldstmt);
110766 +#if BUILDING_GCC_VERSION <= 4007
110767 + args = VEC_alloc(tree, gc, len);
110768 +#else
110769 + vec_alloc(args, len);
110770 +#endif
110771 + for (i = 0; i < len; i++) {
110772 + tree arg, new_arg;
110773 +
110774 + arg = gimple_phi_arg_def(oldstmt, i);
110775 + new_arg = expand(visited, caller_node, arg);
110776 +
110777 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
110778 + ssa_name_var = SSA_NAME_VAR(new_arg);
110779 +
110780 + if (is_gimple_constant(arg)) {
110781 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
110782 +
110783 + new_arg = cast_a_tree(size_overflow_type, arg);
110784 + }
110785 +
110786 +#if BUILDING_GCC_VERSION <= 4007
110787 + VEC_safe_push(tree, gc, args, new_arg);
110788 +#else
110789 + vec_safe_push(args, new_arg);
110790 +#endif
110791 + }
110792 +
110793 + return create_new_phi_node(args, ssa_name_var, oldstmt);
110794 +}
110795 +
110796 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
110797 +{
110798 + gimple assign;
110799 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110800 + tree origtype = TREE_TYPE(orig_rhs);
110801 +
110802 + gcc_assert(is_gimple_assign(stmt));
110803 +
110804 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110805 + gimple_set_plf(assign, MY_STMT, true);
110806 + return gimple_assign_lhs(assign);
110807 +}
110808 +
110809 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
110810 +{
110811 + const_tree rhs1, lhs, rhs1_type, lhs_type;
110812 + enum machine_mode lhs_mode, rhs_mode;
110813 + gimple def_stmt = get_def_stmt(no_const_rhs);
110814 +
110815 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110816 + return false;
110817 +
110818 + rhs1 = gimple_assign_rhs1(def_stmt);
110819 + lhs = gimple_assign_lhs(def_stmt);
110820 + rhs1_type = TREE_TYPE(rhs1);
110821 + lhs_type = TREE_TYPE(lhs);
110822 + rhs_mode = TYPE_MODE(rhs1_type);
110823 + lhs_mode = TYPE_MODE(lhs_type);
110824 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
110825 + return false;
110826 +
110827 + return true;
110828 +}
110829 +
110830 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
110831 +{
110832 + tree rhs1 = gimple_assign_rhs1(stmt);
110833 + tree lhs = gimple_assign_lhs(stmt);
110834 + const_tree rhs1_type = TREE_TYPE(rhs1);
110835 + const_tree lhs_type = TREE_TYPE(lhs);
110836 +
110837 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
110838 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110839 +
110840 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
110841 +}
110842 +
110843 +static bool no_uses(tree node)
110844 +{
110845 + imm_use_iterator imm_iter;
110846 + use_operand_p use_p;
110847 +
110848 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
110849 + const_gimple use_stmt = USE_STMT(use_p);
110850 +
110851 + if (use_stmt == NULL)
110852 + return true;
110853 + if (is_gimple_debug(use_stmt))
110854 + continue;
110855 + return false;
110856 + }
110857 + return true;
110858 +}
110859 +
110860 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
110861 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
110862 +{
110863 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
110864 + gimple def_stmt = get_def_stmt(lhs);
110865 +
110866 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110867 + return false;
110868 +
110869 + rhs1 = gimple_assign_rhs1(def_stmt);
110870 + rhs_type = TREE_TYPE(rhs1);
110871 + lhs_type = TREE_TYPE(lhs);
110872 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
110873 + return false;
110874 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
110875 + return false;
110876 +
110877 + def_stmt = get_def_stmt(rhs1);
110878 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
110879 + return false;
110880 +
110881 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
110882 + return false;
110883 +
110884 + rhs1 = gimple_assign_rhs1(def_stmt);
110885 + rhs2 = gimple_assign_rhs2(def_stmt);
110886 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
110887 + return false;
110888 +
110889 + if (is_gimple_constant(rhs2))
110890 + not_const_rhs = rhs1;
110891 + else
110892 + not_const_rhs = rhs2;
110893 +
110894 + return no_uses(not_const_rhs);
110895 +}
110896 +
110897 +static bool skip_lhs_cast_check(const_gimple stmt)
110898 +{
110899 + const_tree rhs = gimple_assign_rhs1(stmt);
110900 + const_gimple def_stmt = get_def_stmt(rhs);
110901 +
110902 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
110903 + if (gimple_code(def_stmt) == GIMPLE_ASM)
110904 + return true;
110905 +
110906 + if (is_const_plus_unsigned_signed_truncation(rhs))
110907 + return true;
110908 +
110909 + return false;
110910 +}
110911 +
110912 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
110913 +{
110914 + bool cast_lhs, cast_rhs;
110915 + tree lhs = gimple_assign_lhs(stmt);
110916 + tree rhs = gimple_assign_rhs1(stmt);
110917 + const_tree lhs_type = TREE_TYPE(lhs);
110918 + const_tree rhs_type = TREE_TYPE(rhs);
110919 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
110920 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
110921 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
110922 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
110923 +
110924 + static bool check_lhs[3][4] = {
110925 + // ss su us uu
110926 + { false, true, true, false }, // lhs > rhs
110927 + { false, false, false, false }, // lhs = rhs
110928 + { true, true, true, true }, // lhs < rhs
110929 + };
110930 +
110931 + static bool check_rhs[3][4] = {
110932 + // ss su us uu
110933 + { true, false, true, true }, // lhs > rhs
110934 + { true, false, true, true }, // lhs = rhs
110935 + { true, false, true, true }, // lhs < rhs
110936 + };
110937 +
110938 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
110939 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
110940 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110941 +
110942 + if (lhs_size > rhs_size) {
110943 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110944 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110945 + } else if (lhs_size == rhs_size) {
110946 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110947 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110948 + } else {
110949 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110950 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110951 + }
110952 +
110953 + if (!cast_lhs && !cast_rhs)
110954 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110955 +
110956 + if (cast_lhs && !skip_lhs_cast_check(stmt))
110957 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
110958 +
110959 + if (cast_rhs)
110960 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
110961 +
110962 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110963 +}
110964 +
110965 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
110966 +{
110967 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
110968 +
110969 + if (gimple_plf(stmt, MY_STMT))
110970 + return lhs;
110971 +
110972 + rhs1 = gimple_assign_rhs1(stmt);
110973 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
110974 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110975 +
110976 + new_rhs1 = expand(visited, caller_node, rhs1);
110977 +
110978 + if (new_rhs1 == NULL_TREE)
110979 + return create_cast_assign(visited, stmt);
110980 +
110981 + if (gimple_plf(stmt, NO_CAST_CHECK))
110982 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110983 +
110984 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
110985 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
110986 +
110987 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
110988 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
110989 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110990 + }
110991 +
110992 + if (!gimple_assign_cast_p(stmt))
110993 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110994 +
110995 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
110996 +}
110997 +
110998 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
110999 +{
111000 + tree rhs1, lhs = gimple_assign_lhs(stmt);
111001 + gimple def_stmt = get_def_stmt(lhs);
111002 +
111003 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
111004 + rhs1 = gimple_assign_rhs1(def_stmt);
111005 +
111006 + if (is_gimple_constant(rhs1))
111007 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111008 +
111009 + switch (TREE_CODE(rhs1)) {
111010 + case SSA_NAME:
111011 + return handle_unary_rhs(visited, caller_node, def_stmt);
111012 + case ARRAY_REF:
111013 + case BIT_FIELD_REF:
111014 + case ADDR_EXPR:
111015 + case COMPONENT_REF:
111016 + case INDIRECT_REF:
111017 +#if BUILDING_GCC_VERSION >= 4006
111018 + case MEM_REF:
111019 +#endif
111020 + case TARGET_MEM_REF:
111021 + case VIEW_CONVERT_EXPR:
111022 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111023 + case PARM_DECL:
111024 + case VAR_DECL:
111025 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111026 +
111027 + default:
111028 + debug_gimple_stmt(def_stmt);
111029 + debug_tree(rhs1);
111030 + gcc_unreachable();
111031 + }
111032 +}
111033 +
111034 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
111035 +{
111036 + gimple cond_stmt;
111037 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
111038 +
111039 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
111040 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
111041 + update_stmt(cond_stmt);
111042 +}
111043 +
111044 +static tree create_string_param(tree string)
111045 +{
111046 + tree i_type, a_type;
111047 + const int length = TREE_STRING_LENGTH(string);
111048 +
111049 + gcc_assert(length > 0);
111050 +
111051 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
111052 + a_type = build_array_type(char_type_node, i_type);
111053 +
111054 + TREE_TYPE(string) = a_type;
111055 + TREE_CONSTANT(string) = 1;
111056 + TREE_READONLY(string) = 1;
111057 +
111058 + return build1(ADDR_EXPR, ptr_type_node, string);
111059 +}
111060 +
111061 +#if BUILDING_GCC_VERSION <= 4006
111062 +struct cgraph_node *cgraph_get_create_node(tree decl);
111063 +
111064 +struct cgraph_node *cgraph_get_create_node(tree decl)
111065 +{
111066 + struct cgraph_node *node;
111067 +
111068 + node = cgraph_get_node(decl);
111069 + if (node)
111070 + return node;
111071 + return cgraph_node(decl);
111072 +}
111073 +#endif
111074 +
111075 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
111076 +{
111077 + gimple func_stmt;
111078 + const_gimple def_stmt;
111079 + const_tree loc_line;
111080 + tree loc_file, ssa_name, current_func;
111081 + expanded_location xloc;
111082 + char *ssa_name_buf;
111083 + int len;
111084 + struct cgraph_edge *edge;
111085 + struct cgraph_node *callee_node;
111086 + int frequency;
111087 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
111088 +
111089 + def_stmt = get_def_stmt(arg);
111090 + xloc = expand_location(gimple_location(def_stmt));
111091 +
111092 + if (!gimple_has_location(def_stmt)) {
111093 + xloc = expand_location(gimple_location(stmt));
111094 + if (!gimple_has_location(stmt))
111095 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
111096 + }
111097 +
111098 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
111099 +
111100 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
111101 + loc_file = create_string_param(loc_file);
111102 +
111103 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
111104 + current_func = create_string_param(current_func);
111105 +
111106 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
111107 + call_count++;
111108 + 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);
111109 + gcc_assert(len > 0);
111110 + ssa_name = build_string(len + 1, ssa_name_buf);
111111 + free(ssa_name_buf);
111112 + ssa_name = create_string_param(ssa_name);
111113 +
111114 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
111115 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
111116 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
111117 +
111118 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
111119 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
111120 +
111121 +#if BUILDING_GCC_VERSION <= 4006
111122 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
111123 +#else
111124 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
111125 +#endif
111126 + gcc_assert(edge != NULL);
111127 +}
111128 +
111129 +static void __unused print_the_code_insertions(const_gimple stmt)
111130 +{
111131 + location_t loc = gimple_location(stmt);
111132 +
111133 + inform(loc, "Integer size_overflow check applied here.");
111134 +}
111135 +
111136 +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)
111137 +{
111138 + basic_block cond_bb, join_bb, bb_true;
111139 + edge e;
111140 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111141 +
111142 + cond_bb = gimple_bb(stmt);
111143 + if (before)
111144 + gsi_prev(&gsi);
111145 + if (gsi_end_p(gsi))
111146 + e = split_block_after_labels(cond_bb);
111147 + else
111148 + e = split_block(cond_bb, gsi_stmt(gsi));
111149 + cond_bb = e->src;
111150 + join_bb = e->dest;
111151 + e->flags = EDGE_FALSE_VALUE;
111152 + e->probability = REG_BR_PROB_BASE;
111153 +
111154 + bb_true = create_empty_bb(cond_bb);
111155 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
111156 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
111157 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
111158 +
111159 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111160 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
111161 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
111162 +
111163 + if (current_loops != NULL) {
111164 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
111165 + add_bb_to_loop(bb_true, cond_bb->loop_father);
111166 + }
111167 +
111168 + insert_cond(cond_bb, arg, cond_code, type_value);
111169 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
111170 +
111171 +// print_the_code_insertions(stmt);
111172 +}
111173 +
111174 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
111175 +{
111176 + const_tree rhs_type = TREE_TYPE(rhs);
111177 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
111178 +
111179 + gcc_assert(rhs_type != NULL_TREE);
111180 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
111181 + return;
111182 +
111183 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
111184 +
111185 + if (is_const_plus_unsigned_signed_truncation(rhs))
111186 + return;
111187 +
111188 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
111189 + // typemax (-1) < typemin (0)
111190 + if (TREE_OVERFLOW(type_max))
111191 + return;
111192 +
111193 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
111194 +
111195 + cast_rhs_type = TREE_TYPE(cast_rhs);
111196 + type_max_type = TREE_TYPE(type_max);
111197 + type_min_type = TREE_TYPE(type_min);
111198 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
111199 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
111200 +
111201 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
111202 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
111203 +}
111204 +
111205 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
111206 +{
111207 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
111208 + return false;
111209 + if (!is_gimple_constant(rhs))
111210 + return false;
111211 + return true;
111212 +}
111213 +
111214 +static tree get_def_stmt_rhs(const_tree var)
111215 +{
111216 + tree rhs1, def_stmt_rhs1;
111217 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
111218 +
111219 + def_stmt = get_def_stmt(var);
111220 + if (!gimple_assign_cast_p(def_stmt))
111221 + return NULL_TREE;
111222 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
111223 +
111224 + rhs1 = gimple_assign_rhs1(def_stmt);
111225 + rhs1_def_stmt = get_def_stmt(rhs1);
111226 + if (!gimple_assign_cast_p(rhs1_def_stmt))
111227 + return rhs1;
111228 +
111229 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111230 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
111231 +
111232 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
111233 + case GIMPLE_CALL:
111234 + case GIMPLE_NOP:
111235 + case GIMPLE_ASM:
111236 + case GIMPLE_PHI:
111237 + return def_stmt_rhs1;
111238 + case GIMPLE_ASSIGN:
111239 + return rhs1;
111240 + default:
111241 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
111242 + gcc_unreachable();
111243 + }
111244 +}
111245 +
111246 +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)
111247 +{
111248 + tree new_rhs, orig_rhs;
111249 + void (*gimple_assign_set_rhs)(gimple, tree);
111250 + tree rhs1 = gimple_assign_rhs1(stmt);
111251 + tree rhs2 = gimple_assign_rhs2(stmt);
111252 + tree lhs = gimple_assign_lhs(stmt);
111253 +
111254 + if (!check_overflow)
111255 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111256 +
111257 + if (change_rhs == NULL_TREE)
111258 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111259 +
111260 + if (new_rhs2 == NULL_TREE) {
111261 + orig_rhs = rhs1;
111262 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
111263 + } else {
111264 + orig_rhs = rhs2;
111265 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
111266 + }
111267 +
111268 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
111269 +
111270 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
111271 + gimple_assign_set_rhs(stmt, new_rhs);
111272 + update_stmt(stmt);
111273 +
111274 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111275 +}
111276 +
111277 +static bool is_subtraction_special(const_gimple stmt)
111278 +{
111279 + gimple rhs1_def_stmt, rhs2_def_stmt;
111280 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
111281 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
111282 + const_tree rhs1 = gimple_assign_rhs1(stmt);
111283 + const_tree rhs2 = gimple_assign_rhs2(stmt);
111284 +
111285 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
111286 + return false;
111287 +
111288 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
111289 +
111290 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
111291 + return false;
111292 +
111293 + rhs1_def_stmt = get_def_stmt(rhs1);
111294 + rhs2_def_stmt = get_def_stmt(rhs2);
111295 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
111296 + return false;
111297 +
111298 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111299 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
111300 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
111301 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
111302 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
111303 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
111304 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
111305 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
111306 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
111307 + return false;
111308 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
111309 + return false;
111310 +
111311 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
111312 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
111313 + return true;
111314 +}
111315 +
111316 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
111317 +{
111318 + tree new_rhs1, new_rhs2;
111319 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
111320 + gimple assign, stmt = get_def_stmt(lhs);
111321 + tree rhs1 = gimple_assign_rhs1(stmt);
111322 + tree rhs2 = gimple_assign_rhs2(stmt);
111323 +
111324 + if (!is_subtraction_special(stmt))
111325 + return NULL_TREE;
111326 +
111327 + new_rhs1 = expand(visited, caller_node, rhs1);
111328 + new_rhs2 = expand(visited, caller_node, rhs2);
111329 +
111330 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
111331 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
111332 +
111333 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
111334 + return NULL_TREE;
111335 +
111336 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
111337 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
111338 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
111339 + }
111340 +
111341 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
111342 + new_lhs = gimple_assign_lhs(assign);
111343 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
111344 +
111345 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111346 +}
111347 +
111348 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
111349 +{
111350 + const_gimple def_stmt;
111351 +
111352 + if (TREE_CODE(rhs) != SSA_NAME)
111353 + return false;
111354 +
111355 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
111356 + return false;
111357 +
111358 + def_stmt = get_def_stmt(rhs);
111359 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
111360 + return false;
111361 +
111362 + return true;
111363 +}
111364 +
111365 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111366 +{
111367 + tree rhs1, rhs2, new_lhs;
111368 + gimple def_stmt = get_def_stmt(lhs);
111369 + tree new_rhs1 = NULL_TREE;
111370 + tree new_rhs2 = NULL_TREE;
111371 +
111372 + rhs1 = gimple_assign_rhs1(def_stmt);
111373 + rhs2 = gimple_assign_rhs2(def_stmt);
111374 +
111375 + /* no DImode/TImode division in the 32/64 bit kernel */
111376 + switch (gimple_assign_rhs_code(def_stmt)) {
111377 + case RDIV_EXPR:
111378 + case TRUNC_DIV_EXPR:
111379 + case CEIL_DIV_EXPR:
111380 + case FLOOR_DIV_EXPR:
111381 + case ROUND_DIV_EXPR:
111382 + case TRUNC_MOD_EXPR:
111383 + case CEIL_MOD_EXPR:
111384 + case FLOOR_MOD_EXPR:
111385 + case ROUND_MOD_EXPR:
111386 + case EXACT_DIV_EXPR:
111387 + case POINTER_PLUS_EXPR:
111388 + case BIT_AND_EXPR:
111389 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111390 + default:
111391 + break;
111392 + }
111393 +
111394 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
111395 + if (new_lhs != NULL_TREE)
111396 + return new_lhs;
111397 +
111398 + if (TREE_CODE(rhs1) == SSA_NAME)
111399 + new_rhs1 = expand(visited, caller_node, rhs1);
111400 + if (TREE_CODE(rhs2) == SSA_NAME)
111401 + new_rhs2 = expand(visited, caller_node, rhs2);
111402 +
111403 + if (is_a_neg_overflow(def_stmt, rhs2))
111404 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
111405 + if (is_a_neg_overflow(def_stmt, rhs1))
111406 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
111407 +
111408 +
111409 + if (is_a_constant_overflow(def_stmt, rhs2))
111410 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
111411 + if (is_a_constant_overflow(def_stmt, rhs1))
111412 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
111413 +
111414 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111415 +}
111416 +
111417 +#if BUILDING_GCC_VERSION >= 4007
111418 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
111419 +{
111420 + if (is_gimple_constant(rhs))
111421 + return cast_a_tree(size_overflow_type, rhs);
111422 + if (TREE_CODE(rhs) != SSA_NAME)
111423 + return NULL_TREE;
111424 + return expand(visited, caller_node, rhs);
111425 +}
111426 +
111427 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111428 +{
111429 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
111430 + gimple def_stmt = get_def_stmt(lhs);
111431 +
111432 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
111433 +
111434 + rhs1 = gimple_assign_rhs1(def_stmt);
111435 + rhs2 = gimple_assign_rhs2(def_stmt);
111436 + rhs3 = gimple_assign_rhs3(def_stmt);
111437 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
111438 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
111439 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
111440 +
111441 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
111442 +}
111443 +#endif
111444 +
111445 +static tree get_size_overflow_type(gimple stmt, const_tree node)
111446 +{
111447 + const_tree type;
111448 + tree new_type;
111449 +
111450 + gcc_assert(node != NULL_TREE);
111451 +
111452 + type = TREE_TYPE(node);
111453 +
111454 + if (gimple_plf(stmt, MY_STMT))
111455 + return TREE_TYPE(node);
111456 +
111457 + switch (TYPE_MODE(type)) {
111458 + case QImode:
111459 + new_type = intHI_type_node;
111460 + break;
111461 + case HImode:
111462 + new_type = intSI_type_node;
111463 + break;
111464 + case SImode:
111465 + new_type = intDI_type_node;
111466 + break;
111467 + case DImode:
111468 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111469 + new_type = intDI_type_node;
111470 + else
111471 + new_type = intTI_type_node;
111472 + break;
111473 + case TImode:
111474 + gcc_assert(!TYPE_UNSIGNED(type));
111475 + new_type = intTI_type_node;
111476 + break;
111477 + default:
111478 + debug_tree((tree)node);
111479 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
111480 + gcc_unreachable();
111481 + }
111482 +
111483 + if (TYPE_QUALS(type) != 0)
111484 + return build_qualified_type(new_type, TYPE_QUALS(type));
111485 + return new_type;
111486 +}
111487 +
111488 +static tree expand_visited(gimple def_stmt)
111489 +{
111490 + const_gimple next_stmt;
111491 + gimple_stmt_iterator gsi;
111492 + enum gimple_code code = gimple_code(def_stmt);
111493 +
111494 + if (code == GIMPLE_ASM)
111495 + return NULL_TREE;
111496 +
111497 + gsi = gsi_for_stmt(def_stmt);
111498 + gsi_next(&gsi);
111499 +
111500 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111501 + return NULL_TREE;
111502 + gcc_assert(!gsi_end_p(gsi));
111503 + next_stmt = gsi_stmt(gsi);
111504 +
111505 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
111506 + return NULL_TREE;
111507 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
111508 +
111509 + return get_lhs(next_stmt);
111510 +}
111511 +
111512 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111513 +{
111514 + gimple def_stmt;
111515 +
111516 + def_stmt = get_def_stmt(lhs);
111517 +
111518 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111519 + return NULL_TREE;
111520 +
111521 + if (gimple_plf(def_stmt, MY_STMT))
111522 + return lhs;
111523 +
111524 + if (pointer_set_contains(visited, def_stmt))
111525 + return expand_visited(def_stmt);
111526 +
111527 + switch (gimple_code(def_stmt)) {
111528 + case GIMPLE_PHI:
111529 + return handle_phi(visited, caller_node, lhs);
111530 + case GIMPLE_CALL:
111531 + case GIMPLE_ASM:
111532 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111533 + case GIMPLE_ASSIGN:
111534 + switch (gimple_num_ops(def_stmt)) {
111535 + case 2:
111536 + return handle_unary_ops(visited, caller_node, def_stmt);
111537 + case 3:
111538 + return handle_binary_ops(visited, caller_node, lhs);
111539 +#if BUILDING_GCC_VERSION >= 4007
111540 + case 4:
111541 + return handle_ternary_ops(visited, caller_node, lhs);
111542 +#endif
111543 + }
111544 + default:
111545 + debug_gimple_stmt(def_stmt);
111546 + error("%s: unknown gimple code", __func__);
111547 + gcc_unreachable();
111548 + }
111549 +}
111550 +
111551 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
111552 +{
111553 + const_gimple assign;
111554 + tree orig_type = TREE_TYPE(orig_node);
111555 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111556 +
111557 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111558 + return gimple_assign_lhs(assign);
111559 +}
111560 +
111561 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
111562 +{
111563 + void (*set_rhs)(gimple, tree);
111564 + gimple stmt = cur_node->first_stmt;
111565 + const_tree orig_node = cur_node->node;
111566 +
111567 + switch (gimple_code(stmt)) {
111568 + case GIMPLE_RETURN:
111569 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111570 + break;
111571 + case GIMPLE_CALL:
111572 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
111573 + break;
111574 + case GIMPLE_ASSIGN:
111575 + switch (cur_node->num) {
111576 + case 1:
111577 + set_rhs = &gimple_assign_set_rhs1;
111578 + break;
111579 + case 2:
111580 + set_rhs = &gimple_assign_set_rhs2;
111581 + break;
111582 +#if BUILDING_GCC_VERSION > 4005
111583 + case 3:
111584 + set_rhs = &gimple_assign_set_rhs3;
111585 + break;
111586 +#endif
111587 + default:
111588 + gcc_unreachable();
111589 + }
111590 +
111591 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111592 + break;
111593 + default:
111594 + debug_gimple_stmt(stmt);
111595 + gcc_unreachable();
111596 + }
111597 +
111598 + update_stmt(stmt);
111599 +}
111600 +
111601 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
111602 +{
111603 + const struct size_overflow_hash *hash;
111604 + unsigned int new_argnum;
111605 + tree arg;
111606 + const_tree origarg;
111607 +
111608 + if (argnum == 0)
111609 + return argnum;
111610 +
111611 + hash = get_function_hash(fndecl);
111612 + if (hash && hash->param & (1U << argnum))
111613 + return argnum;
111614 +
111615 + if (DECL_EXTERNAL(fndecl))
111616 + return argnum;
111617 +
111618 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
111619 + argnum--;
111620 + while (origarg && argnum) {
111621 + origarg = TREE_CHAIN(origarg);
111622 + argnum--;
111623 + }
111624 + gcc_assert(argnum == 0);
111625 + gcc_assert(origarg != NULL_TREE);
111626 +
111627 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
111628 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
111629 + return new_argnum;
111630 +
111631 + return CANNOT_FIND_ARG;
111632 +}
111633 +
111634 +// Don't want to duplicate entries in next_cgraph_node
111635 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
111636 +{
111637 + const_tree new_callee_fndecl;
111638 + struct next_cgraph_node *cur_node;
111639 +
111640 + if (fndecl == RET_CHECK)
111641 +#if BUILDING_GCC_VERSION <= 4007
111642 + new_callee_fndecl = node->decl;
111643 +#else
111644 + new_callee_fndecl = node->symbol.decl;
111645 +#endif
111646 + else
111647 + new_callee_fndecl = fndecl;
111648 +
111649 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
111650 +#if BUILDING_GCC_VERSION <= 4007
111651 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
111652 +#else
111653 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
111654 +#endif
111655 + continue;
111656 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
111657 + continue;
111658 + if (num == cur_node->num)
111659 + return true;
111660 + }
111661 + return false;
111662 +}
111663 +
111664 +/* Add a next_cgraph_node into the list for handle_function().
111665 + * handle_function() iterates over all the next cgraph nodes and
111666 + * starts the overflow check insertion process.
111667 + */
111668 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
111669 +{
111670 + struct next_cgraph_node *new_node;
111671 +
111672 + if (is_in_next_cgraph_node(head, node, fndecl, num))
111673 + return head;
111674 +
111675 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
111676 + new_node->current_function = node;
111677 + new_node->next = NULL;
111678 + new_node->num = num;
111679 + if (fndecl == RET_CHECK)
111680 +#if BUILDING_GCC_VERSION <= 4007
111681 + new_node->callee_fndecl = node->decl;
111682 +#else
111683 + new_node->callee_fndecl = node->symbol.decl;
111684 +#endif
111685 + else
111686 + new_node->callee_fndecl = fndecl;
111687 +
111688 + if (!head)
111689 + return new_node;
111690 +
111691 + new_node->next = head;
111692 + return new_node;
111693 +}
111694 +
111695 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
111696 +{
111697 + struct cgraph_edge *e;
111698 +
111699 + if (num == 0)
111700 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
111701 +
111702 + for (e = node->callers; e; e = e->next_caller) {
111703 + tree fndecl = gimple_call_fndecl(e->call_stmt);
111704 +
111705 + gcc_assert(fndecl != NULL_TREE);
111706 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
111707 + }
111708 +
111709 + return head;
111710 +}
111711 +
111712 +static bool is_a_return_check(const_tree node)
111713 +{
111714 + if (TREE_CODE(node) == FUNCTION_DECL)
111715 + return true;
111716 +
111717 + gcc_assert(TREE_CODE(node) == PARM_DECL);
111718 + return false;
111719 +}
111720 +
111721 +static bool is_in_hash_table(tree fndecl, unsigned int num)
111722 +{
111723 + const struct size_overflow_hash *hash;
111724 +
111725 + hash = get_function_hash(fndecl);
111726 + if (hash && (hash->param & (1U << num)))
111727 + return true;
111728 + return false;
111729 +}
111730 +
111731 +struct missing_functions {
111732 + struct missing_functions *next;
111733 + const_tree node;
111734 + tree fndecl;
111735 +};
111736 +
111737 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
111738 +{
111739 + struct missing_functions *new_function;
111740 +
111741 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
111742 + new_function->node = node;
111743 + new_function->next = NULL;
111744 +
111745 + if (TREE_CODE(node) == FUNCTION_DECL)
111746 + new_function->fndecl = node;
111747 + else
111748 + new_function->fndecl = current_function_decl;
111749 + gcc_assert(new_function->fndecl);
111750 +
111751 + if (!missing_fn_head)
111752 + return new_function;
111753 +
111754 + new_function->next = missing_fn_head;
111755 + return new_function;
111756 +}
111757 +
111758 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
111759 + * If the function is missing everywhere then print the missing message into stderr.
111760 + */
111761 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
111762 +{
111763 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
111764 +#if BUILDING_GCC_VERSION >= 4008
111765 + case BUILT_IN_BSWAP16:
111766 +#endif
111767 + case BUILT_IN_BSWAP32:
111768 + case BUILT_IN_BSWAP64:
111769 + case BUILT_IN_EXPECT:
111770 + case BUILT_IN_MEMCMP:
111771 + return false;
111772 + default:
111773 + break;
111774 + }
111775 +
111776 + // skip test.c
111777 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
111778 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
111779 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
111780 + }
111781 +
111782 + if (is_in_hash_table(orig_fndecl, num))
111783 + return false;
111784 +
111785 + print_missing_msg(orig_fndecl, num);
111786 + return true;
111787 +}
111788 +
111789 +// Get the argnum of a function decl, if node is a return then the argnum is 0
111790 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
111791 +{
111792 + if (is_a_return_check(node))
111793 + return 0;
111794 + else
111795 + return find_arg_number_tree(node, orig_fndecl);
111796 +}
111797 +
111798 +/* If the function is missing from the hash table and it is a static function
111799 + * then create a next_cgraph_node from it for handle_function()
111800 + */
111801 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
111802 +{
111803 + unsigned int num;
111804 + tree orig_fndecl;
111805 + struct cgraph_node *next_node = NULL;
111806 +
111807 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
111808 +
111809 + num = get_function_num(missing_fn_head->node, orig_fndecl);
111810 + if (num == CANNOT_FIND_ARG)
111811 + return cnodes;
111812 +
111813 + if (!is_missing_function(orig_fndecl, num))
111814 + return cnodes;
111815 +
111816 + next_node = cgraph_get_node(missing_fn_head->fndecl);
111817 + if (next_node && next_node->local.local)
111818 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
111819 + return cnodes;
111820 +}
111821 +
111822 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
111823 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
111824 + */
111825 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
111826 +{
111827 + unsigned int i;
111828 + tree node;
111829 + struct missing_functions *cur, *missing_fn_head = NULL;
111830 +
111831 +#if BUILDING_GCC_VERSION == 4005
111832 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
111833 + node = VEC_index(tree, cur_node->last_nodes, i);
111834 +#elif BUILDING_GCC_VERSION <= 4007
111835 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
111836 +#else
111837 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
111838 +#endif
111839 + switch (TREE_CODE(node)) {
111840 + case PARM_DECL:
111841 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
111842 + break;
111843 + case FUNCTION_DECL:
111844 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
111845 + break;
111846 + default:
111847 + break;
111848 + }
111849 + }
111850 +
111851 + while (missing_fn_head) {
111852 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
111853 +
111854 + cur = missing_fn_head->next;
111855 + free(missing_fn_head);
111856 + missing_fn_head = cur;
111857 + }
111858 +
111859 + return cnodes;
111860 +}
111861 +
111862 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
111863 +{
111864 + gimple phi = get_def_stmt(result);
111865 + unsigned int i, n = gimple_phi_num_args(phi);
111866 +
111867 + pointer_set_insert(visited, phi);
111868 + for (i = 0; i < n; i++) {
111869 + const_tree arg = gimple_phi_arg_def(phi, i);
111870 +
111871 + set_conditions(visited, interesting_conditions, arg);
111872 + }
111873 +}
111874 +
111875 +enum conditions {
111876 + FROM_CONST, NOT_UNARY, CAST
111877 +};
111878 +
111879 +// Search for constants, cast assignments and binary/ternary assignments
111880 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
111881 +{
111882 + gimple def_stmt = get_def_stmt(lhs);
111883 +
111884 + if (is_gimple_constant(lhs)) {
111885 + interesting_conditions[FROM_CONST] = true;
111886 + return;
111887 + }
111888 +
111889 + if (!def_stmt)
111890 + return;
111891 +
111892 + if (pointer_set_contains(visited, def_stmt))
111893 + return;
111894 +
111895 + switch (gimple_code(def_stmt)) {
111896 + case GIMPLE_NOP:
111897 + case GIMPLE_CALL:
111898 + case GIMPLE_ASM:
111899 + return;
111900 + case GIMPLE_PHI:
111901 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
111902 + case GIMPLE_ASSIGN:
111903 + if (gimple_num_ops(def_stmt) == 2) {
111904 + const_tree rhs = gimple_assign_rhs1(def_stmt);
111905 +
111906 + if (gimple_assign_cast_p(def_stmt))
111907 + interesting_conditions[CAST] = true;
111908 +
111909 + return set_conditions(visited, interesting_conditions, rhs);
111910 + } else {
111911 + interesting_conditions[NOT_UNARY] = true;
111912 + return;
111913 + }
111914 + default:
111915 + debug_gimple_stmt(def_stmt);
111916 + gcc_unreachable();
111917 + }
111918 +}
111919 +
111920 +// determine whether duplication will be necessary or not.
111921 +static void search_interesting_conditions(const_tree arg, bool *interesting_conditions)
111922 +{
111923 + struct pointer_set_t *visited;
111924 +
111925 + visited = pointer_set_create();
111926 + set_conditions(visited, interesting_conditions, arg);
111927 + pointer_set_destroy(visited);
111928 +}
111929 +
111930 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
111931 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
111932 +{
111933 + gimple assign;
111934 + gimple_stmt_iterator gsi;
111935 +
111936 + // already removed
111937 + if (gimple_bb(asm_stmt) == NULL)
111938 + return;
111939 + gsi = gsi_for_stmt(asm_stmt);
111940 +
111941 + assign = gimple_build_assign(lhs, rhs);
111942 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
111943 + SSA_NAME_DEF_STMT(lhs) = assign;
111944 +
111945 + gsi_remove(&gsi, true);
111946 +}
111947 +
111948 +// Get the field decl of a component ref for intentional_overflow checking
111949 +static const_tree search_field_decl(const_tree comp_ref)
111950 +{
111951 + const_tree field = NULL_TREE;
111952 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
111953 +
111954 + for (i = 0; i < len; i++) {
111955 + field = TREE_OPERAND(comp_ref, i);
111956 + if (TREE_CODE(field) == FIELD_DECL)
111957 + break;
111958 + }
111959 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
111960 + return field;
111961 +}
111962 +
111963 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
111964 + * stmt is a return otherwise it is the callee function.
111965 + */
111966 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
111967 +{
111968 + const_tree fndecl;
111969 +
111970 + if (argnum == 0)
111971 + fndecl = current_function_decl;
111972 + else
111973 + fndecl = gimple_call_fndecl(stmt);
111974 +
111975 + if (fndecl == NULL_TREE)
111976 + return NULL_TREE;
111977 +
111978 + return DECL_ORIGIN(fndecl);
111979 +}
111980 +
111981 +/* Get the param of the intentional_overflow attribute.
111982 + * * 0: MARK_NOT_INTENTIONAL
111983 + * * 1..MAX_PARAM: MARK_YES
111984 + * * -1: MARK_TURN_OFF
111985 + */
111986 +static tree get_attribute_param(const_tree decl)
111987 +{
111988 + const_tree attr;
111989 +
111990 + if (decl == NULL_TREE)
111991 + return NULL_TREE;
111992 +
111993 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
111994 + if (!attr || !TREE_VALUE(attr))
111995 + return NULL_TREE;
111996 +
111997 + return TREE_VALUE(attr);
111998 +}
111999 +
112000 +// MARK_TURN_OFF
112001 +static bool is_turn_off_intentional_attr(const_tree decl)
112002 +{
112003 + const_tree param_head;
112004 +
112005 + param_head = get_attribute_param(decl);
112006 + if (param_head == NULL_TREE)
112007 + return false;
112008 +
112009 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
112010 + return true;
112011 + return false;
112012 +}
112013 +
112014 +// MARK_NOT_INTENTIONAL
112015 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
112016 +{
112017 + const_tree param_head;
112018 +
112019 + if (argnum == 0)
112020 + return false;
112021 +
112022 + param_head = get_attribute_param(decl);
112023 + if (param_head == NULL_TREE)
112024 + return false;
112025 +
112026 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
112027 + return true;
112028 + return false;
112029 +}
112030 +
112031 +// MARK_YES
112032 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
112033 +{
112034 + tree param, param_head;
112035 +
112036 + if (argnum == 0)
112037 + return false;
112038 +
112039 + param_head = get_attribute_param(decl);
112040 + for (param = param_head; param; param = TREE_CHAIN(param))
112041 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
112042 + return true;
112043 + return false;
112044 +}
112045 +
112046 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
112047 +{
112048 + const char *str;
112049 +
112050 + if (!stmt)
112051 + return false;
112052 +
112053 + str = gimple_asm_string(stmt);
112054 + return !strcmp(str, "# size_overflow MARK_TURN_OFF\n\t");
112055 +}
112056 +
112057 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
112058 +{
112059 + const char *str;
112060 +
112061 + if (!stmt)
112062 + return false;
112063 +
112064 + str = gimple_asm_string(stmt);
112065 + return !strcmp(str, "# size_overflow MARK_YES\n\t");
112066 +}
112067 +
112068 +static bool is_size_overflow_asm(const_gimple stmt)
112069 +{
112070 + const char *str;
112071 +
112072 + if (!stmt)
112073 + return false;
112074 +
112075 + str = gimple_asm_string(stmt);
112076 + return !strncmp(str, "# size_overflow", 15);
112077 +}
112078 +
112079 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
112080 +{
112081 + location_t loc;
112082 +
112083 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
112084 + return;
112085 +
112086 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
112087 + return;
112088 +
112089 + loc = DECL_SOURCE_LOCATION(decl);
112090 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
112091 +}
112092 +
112093 +/* Get the type of the intentional_overflow attribute of a node
112094 + * * MARK_TURN_OFF
112095 + * * MARK_YES
112096 + * * MARK_NO
112097 + * * MARK_NOT_INTENTIONAL
112098 + */
112099 +static enum mark get_intentional_attr_type(const_tree node)
112100 +{
112101 + const_tree cur_decl;
112102 +
112103 + if (node == NULL_TREE)
112104 + return MARK_NO;
112105 +
112106 + switch (TREE_CODE(node)) {
112107 + case COMPONENT_REF:
112108 + cur_decl = search_field_decl(node);
112109 + if (is_turn_off_intentional_attr(cur_decl))
112110 + return MARK_TURN_OFF;
112111 + if (is_end_intentional_intentional_attr(cur_decl, 1))
112112 + return MARK_YES;
112113 + break;
112114 + case PARM_DECL: {
112115 + unsigned int argnum;
112116 +
112117 + cur_decl = DECL_ORIGIN(current_function_decl);
112118 + argnum = find_arg_number_tree(node, cur_decl);
112119 + if (argnum == CANNOT_FIND_ARG)
112120 + return MARK_NO;
112121 + if (is_yes_intentional_attr(cur_decl, argnum))
112122 + return MARK_YES;
112123 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
112124 + return MARK_NOT_INTENTIONAL;
112125 + break;
112126 + }
112127 + case FUNCTION_DECL:
112128 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
112129 + return MARK_TURN_OFF;
112130 + break;
112131 + default:
112132 + break;
112133 + }
112134 + return MARK_NO;
112135 +}
112136 +
112137 +// Search for the intentional_overflow attribute on the last nodes
112138 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
112139 +{
112140 + unsigned int i;
112141 + tree last_node;
112142 + enum mark mark = MARK_NO;
112143 +
112144 +#if BUILDING_GCC_VERSION == 4005
112145 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112146 + last_node = VEC_index(tree, cur_node->last_nodes, i);
112147 +#elif BUILDING_GCC_VERSION <= 4007
112148 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
112149 +#else
112150 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
112151 +#endif
112152 + mark = get_intentional_attr_type(last_node);
112153 + if (mark != MARK_NO)
112154 + break;
112155 + }
112156 + return mark;
112157 +}
112158 +
112159 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
112160 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
112161 + */
112162 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
112163 +{
112164 + const_tree input, output;
112165 +
112166 + if (!cur_node->intentional_mark_from_gimple)
112167 + return false;
112168 +
112169 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
112170 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
112171 + else
112172 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112173 +
112174 + // skip param decls
112175 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
112176 + return true;
112177 + input = gimple_asm_input_op(cur_node->intentional_mark_from_gimple, 0);
112178 + output = gimple_asm_output_op(cur_node->intentional_mark_from_gimple, 0);
112179 +
112180 + replace_size_overflow_asm_with_assign(cur_node->intentional_mark_from_gimple, TREE_VALUE(output), TREE_VALUE(input));
112181 + return true;
112182 +}
112183 +
112184 +/* Search intentional_overflow attribute on caller and on callee too.
112185 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
112186 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
112187 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
112188 +*/
112189 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
112190 +{
112191 + const_tree fndecl;
112192 +
112193 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
112194 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112195 + return;
112196 + }
112197 +
112198 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
112199 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
112200 + return;
112201 + }
112202 +
112203 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
112204 + return;
112205 +
112206 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
112207 + if (is_turn_off_intentional_attr(fndecl)) {
112208 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
112209 + return;
112210 + }
112211 +
112212 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
112213 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
112214 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
112215 + cur_node->intentional_attr_decl = MARK_YES;
112216 +
112217 + if (is_intentional_attribute_from_gimple(cur_node))
112218 + return;
112219 +
112220 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
112221 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
112222 +}
112223 +
112224 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
112225 +static bool skip_asm(const_tree arg)
112226 +{
112227 + gimple def_stmt = get_def_stmt(arg);
112228 +
112229 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112230 + return false;
112231 +
112232 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
112233 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
112234 +}
112235 +
112236 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
112237 +{
112238 + gimple phi = get_def_stmt(result);
112239 + unsigned int i, n = gimple_phi_num_args(phi);
112240 +
112241 + pointer_set_insert(visited, phi);
112242 + for (i = 0; i < n; i++) {
112243 + tree arg = gimple_phi_arg_def(phi, i);
112244 +
112245 + walk_use_def(visited, cur_node, arg);
112246 + }
112247 +}
112248 +
112249 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112250 +{
112251 + gimple def_stmt = get_def_stmt(lhs);
112252 + tree rhs1, rhs2;
112253 +
112254 + rhs1 = gimple_assign_rhs1(def_stmt);
112255 + rhs2 = gimple_assign_rhs2(def_stmt);
112256 +
112257 + walk_use_def(visited, cur_node, rhs1);
112258 + walk_use_def(visited, cur_node, rhs2);
112259 +}
112260 +
112261 +static void insert_last_node(struct interesting_node *cur_node, tree node)
112262 +{
112263 + unsigned int i;
112264 + tree element;
112265 + enum tree_code code;
112266 +
112267 + gcc_assert(node != NULL_TREE);
112268 +
112269 + if (is_gimple_constant(node))
112270 + return;
112271 +
112272 + code = TREE_CODE(node);
112273 + if (code == VAR_DECL) {
112274 + node = DECL_ORIGIN(node);
112275 + code = TREE_CODE(node);
112276 + }
112277 +
112278 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
112279 + return;
112280 +
112281 +#if BUILDING_GCC_VERSION == 4005
112282 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112283 + element = VEC_index(tree, cur_node->last_nodes, i);
112284 +#elif BUILDING_GCC_VERSION <= 4007
112285 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
112286 +#else
112287 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
112288 +#endif
112289 + if (operand_equal_p(node, element, 0))
112290 + return;
112291 + }
112292 +
112293 +#if BUILDING_GCC_VERSION <= 4007
112294 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
112295 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
112296 +#else
112297 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
112298 + vec_safe_push(cur_node->last_nodes, node);
112299 +#endif
112300 +}
112301 +
112302 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
112303 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
112304 +{
112305 + const_tree asm_lhs;
112306 +
112307 + if (!is_size_overflow_asm(stmt))
112308 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112309 +
112310 + asm_lhs = gimple_asm_input_op(stmt, 0);
112311 + walk_use_def(visited, cur_node, TREE_VALUE(asm_lhs));
112312 +}
112313 +
112314 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
112315 + * and component refs (for checking the intentional_overflow attribute).
112316 + */
112317 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112318 +{
112319 + const_gimple def_stmt;
112320 +
112321 + if (TREE_CODE(lhs) != SSA_NAME) {
112322 + insert_last_node(cur_node, lhs);
112323 + return;
112324 + }
112325 +
112326 + def_stmt = get_def_stmt(lhs);
112327 + if (!def_stmt)
112328 + return;
112329 +
112330 + if (pointer_set_insert(visited, def_stmt))
112331 + return;
112332 +
112333 + switch (gimple_code(def_stmt)) {
112334 + case GIMPLE_NOP:
112335 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112336 + case GIMPLE_ASM:
112337 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
112338 + case GIMPLE_CALL: {
112339 + tree fndecl = gimple_call_fndecl(def_stmt);
112340 +
112341 + if (fndecl == NULL_TREE)
112342 + return;
112343 + insert_last_node(cur_node, fndecl);
112344 + return;
112345 + }
112346 + case GIMPLE_PHI:
112347 + return walk_use_def_phi(visited, cur_node, lhs);
112348 + case GIMPLE_ASSIGN:
112349 + switch (gimple_num_ops(def_stmt)) {
112350 + case 2:
112351 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
112352 + case 3:
112353 + return walk_use_def_binary(visited, cur_node, lhs);
112354 + }
112355 + default:
112356 + debug_gimple_stmt((gimple)def_stmt);
112357 + error("%s: unknown gimple code", __func__);
112358 + gcc_unreachable();
112359 + }
112360 +}
112361 +
112362 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
112363 +static void set_last_nodes(struct interesting_node *cur_node)
112364 +{
112365 + struct pointer_set_t *visited;
112366 +
112367 + visited = pointer_set_create();
112368 + walk_use_def(visited, cur_node, cur_node->node);
112369 + pointer_set_destroy(visited);
112370 +}
112371 +
112372 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
112373 + * 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
112374 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
112375 + * 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.
112376 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
112377 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
112378 + * 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.
112379 + */
112380 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
112381 +{
112382 + struct pointer_set_t *visited;
112383 + bool interesting_conditions[3] = {false, false, false};
112384 + tree new_node, orig_node = cur_node->node;
112385 +
112386 + set_last_nodes(cur_node);
112387 +
112388 + check_intentional_attribute_ipa(cur_node);
112389 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
112390 + return cnodes;
112391 +
112392 + search_interesting_conditions(orig_node, interesting_conditions);
112393 +
112394 + // error code
112395 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
112396 + return cnodes;
112397 +
112398 + cnodes = search_overflow_attribute(cnodes, cur_node);
112399 +
112400 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
112401 + return cnodes;
112402 +
112403 + // unnecessary overflow check
112404 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
112405 + return cnodes;
112406 +
112407 + visited = pointer_set_create();
112408 + new_node = expand(visited, caller_node, orig_node);
112409 + pointer_set_destroy(visited);
112410 +
112411 + if (new_node == NULL_TREE)
112412 + return cnodes;
112413 +
112414 + change_orig_node(cur_node, new_node);
112415 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
112416 +
112417 + return cnodes;
112418 +}
112419 +
112420 +// Check visited interesting nodes.
112421 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
112422 +{
112423 + struct interesting_node *cur;
112424 +
112425 + for (cur = head; cur; cur = cur->next) {
112426 + if (!operand_equal_p(node, cur->node, 0))
112427 + continue;
112428 + if (num != cur->num)
112429 + continue;
112430 + if (first_stmt == cur->first_stmt)
112431 + return true;
112432 + }
112433 + return false;
112434 +}
112435 +
112436 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
112437 + 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
112438 + 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
112439 + the intentional_overflow attribute check. They are collected by set_last_nodes().
112440 + num: arg count of a call stmt or 0 when it is a ret
112441 + node: the recursion starts from here, it is a call arg or a return value
112442 + 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.
112443 + intentional_attr_decl: intentional_overflow attribute of the callee function
112444 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
112445 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
112446 + */
112447 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
112448 +{
112449 + struct interesting_node *new_node;
112450 + tree fndecl;
112451 + enum gimple_code code;
112452 +
112453 + gcc_assert(node != NULL_TREE);
112454 + code = gimple_code(first_stmt);
112455 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
112456 +
112457 + if (num == CANNOT_FIND_ARG)
112458 + return head;
112459 +
112460 + if (skip_types(node))
112461 + return head;
112462 +
112463 + if (skip_asm(node))
112464 + return head;
112465 +
112466 + if (is_gimple_call(first_stmt))
112467 + fndecl = gimple_call_fndecl(first_stmt);
112468 + else
112469 + fndecl = current_function_decl;
112470 +
112471 + if (fndecl == NULL_TREE)
112472 + return head;
112473 +
112474 + if (is_in_interesting_node(head, first_stmt, node, num))
112475 + return head;
112476 +
112477 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
112478 +
112479 + new_node->next = NULL;
112480 + new_node->first_stmt = first_stmt;
112481 +#if BUILDING_GCC_VERSION <= 4007
112482 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
112483 +#else
112484 + vec_alloc(new_node->last_nodes, VEC_LEN);
112485 +#endif
112486 + new_node->num = num;
112487 + new_node->node = node;
112488 + new_node->fndecl = fndecl;
112489 + new_node->intentional_attr_decl = MARK_NO;
112490 + new_node->intentional_attr_cur_fndecl = MARK_NO;
112491 + new_node->intentional_mark_from_gimple = asm_stmt;
112492 +
112493 + if (!head)
112494 + return new_node;
112495 +
112496 + new_node->next = head;
112497 + return new_node;
112498 +}
112499 +
112500 +/* 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).
112501 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
112502 + */
112503 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112504 +{
112505 + struct next_cgraph_node *cur_node;
112506 + tree ret = gimple_return_retval(stmt);
112507 +
112508 + if (ret == NULL_TREE)
112509 + return head;
112510 +
112511 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112512 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
112513 + continue;
112514 + if (cur_node->num == 0)
112515 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
112516 + }
112517 +
112518 + return head;
112519 +}
112520 +
112521 +/* 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).
112522 + * If the call stmt is in the next cgraph node list then it's an interesting call.
112523 + */
112524 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112525 +{
112526 + unsigned int argnum;
112527 + tree fndecl, arg;
112528 + struct next_cgraph_node *cur_node;
112529 +
112530 + fndecl = gimple_call_fndecl(stmt);
112531 + if (fndecl == NULL_TREE)
112532 + return head;
112533 +
112534 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112535 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
112536 + continue;
112537 + argnum = get_correct_arg_count(cur_node->num, fndecl);
112538 + gcc_assert(argnum != CANNOT_FIND_ARG);
112539 + if (argnum == 0)
112540 + continue;
112541 +
112542 + arg = gimple_call_arg(stmt, argnum - 1);
112543 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
112544 + }
112545 +
112546 + return head;
112547 +}
112548 +
112549 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
112550 +{
112551 + if (!operand_equal_p(orig_node, node, 0))
112552 + return WRONG_NODE;
112553 + if (skip_types(node))
112554 + return WRONG_NODE;
112555 + return ret_count;
112556 +}
112557 +
112558 +// Get the index of the rhs node in an assignment
112559 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
112560 +{
112561 + const_tree rhs1, rhs2;
112562 + unsigned int ret;
112563 +
112564 + gcc_assert(stmt);
112565 + gcc_assert(is_gimple_assign(stmt));
112566 +
112567 + rhs1 = gimple_assign_rhs1(stmt);
112568 + gcc_assert(rhs1 != NULL_TREE);
112569 +
112570 + switch (gimple_num_ops(stmt)) {
112571 + case 2:
112572 + return check_ops(node, rhs1, 1);
112573 + case 3:
112574 + ret = check_ops(node, rhs1, 1);
112575 + if (ret != WRONG_NODE)
112576 + return ret;
112577 +
112578 + rhs2 = gimple_assign_rhs2(stmt);
112579 + gcc_assert(rhs2 != NULL_TREE);
112580 + return check_ops(node, rhs2, 2);
112581 + default:
112582 + gcc_unreachable();
112583 + }
112584 +}
112585 +
112586 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
112587 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
112588 +{
112589 + unsigned int i;
112590 +
112591 + if (gimple_call_fndecl(stmt) == NULL_TREE)
112592 + return CANNOT_FIND_ARG;
112593 +
112594 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
112595 + tree node;
112596 +
112597 + node = gimple_call_arg(stmt, i);
112598 + if (!operand_equal_p(arg, node, 0))
112599 + continue;
112600 + if (!skip_types(node))
112601 + return i + 1;
112602 + }
112603 +
112604 + return CANNOT_FIND_ARG;
112605 +}
112606 +
112607 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
112608 + * any of return, call or assignment stmts (because of inlining).
112609 + */
112610 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
112611 +{
112612 + use_operand_p use_p;
112613 + imm_use_iterator imm_iter;
112614 + unsigned int argnum;
112615 +
112616 + if (is_size_overflow_intentional_asm_turn_off(intentional_asm))
112617 + return head;
112618 +
112619 + gcc_assert(TREE_CODE(node) == SSA_NAME);
112620 +
112621 + if (pointer_set_insert(visited, node))
112622 + return head;
112623 +
112624 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112625 + gimple stmt = USE_STMT(use_p);
112626 +
112627 + if (stmt == NULL)
112628 + return head;
112629 + if (is_gimple_debug(stmt))
112630 + continue;
112631 +
112632 + switch (gimple_code(stmt)) {
112633 + case GIMPLE_CALL:
112634 + argnum = find_arg_number_gimple(node, stmt);
112635 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112636 + break;
112637 + case GIMPLE_RETURN:
112638 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
112639 + break;
112640 + case GIMPLE_ASSIGN:
112641 + argnum = get_assign_ops_count(stmt, node);
112642 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112643 + break;
112644 + case GIMPLE_PHI: {
112645 + tree result = gimple_phi_result(stmt);
112646 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
112647 + break;
112648 + }
112649 + case GIMPLE_ASM:
112650 + if (gimple_asm_noutputs(stmt) != 0)
112651 + break;
112652 + if (!is_size_overflow_asm(stmt))
112653 + break;
112654 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
112655 + break;
112656 + case GIMPLE_COND:
112657 + case GIMPLE_SWITCH:
112658 + break;
112659 + default:
112660 + debug_gimple_stmt(stmt);
112661 + gcc_unreachable();
112662 + break;
112663 + }
112664 + }
112665 + return head;
112666 +}
112667 +
112668 +static void remove_size_overflow_asm(gimple stmt)
112669 +{
112670 + gimple_stmt_iterator gsi;
112671 +
112672 + gcc_assert(gimple_code(stmt) == GIMPLE_ASM);
112673 + gsi = gsi_for_stmt(stmt);
112674 + gsi_remove(&gsi, true);
112675 +}
112676 +
112677 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
112678 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
112679 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
112680 + */
112681 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
112682 +{
112683 + const_tree output, input;
112684 + struct pointer_set_t *visited;
112685 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
112686 +
112687 + if (!is_size_overflow_asm(stmt))
112688 + return head;
112689 +
112690 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
112691 + intentional_asm = stmt;
112692 +
112693 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
112694 + input = gimple_asm_input_op(stmt, 0);
112695 +
112696 + if (gimple_asm_noutputs(stmt) == 0) {
112697 + remove_size_overflow_asm(stmt);
112698 + if (is_gimple_constant(TREE_VALUE(input)))
112699 + return head;
112700 +
112701 + visited = pointer_set_create();
112702 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
112703 + pointer_set_destroy(visited);
112704 + return head;
112705 + }
112706 +
112707 + output = gimple_asm_output_op(stmt, 0);
112708 +
112709 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
112710 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
112711 +
112712 + visited = pointer_set_create();
112713 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
112714 + pointer_set_destroy(visited);
112715 + return head;
112716 +}
112717 +
112718 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
112719 + * or a call stmt or a return stmt and store them in the interesting_node list
112720 + */
112721 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
112722 +{
112723 + basic_block bb;
112724 + struct interesting_node *head = NULL;
112725 +
112726 + FOR_ALL_BB(bb) {
112727 + gimple_stmt_iterator gsi;
112728 +
112729 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112730 + enum gimple_code code;
112731 + gimple stmt = gsi_stmt(gsi);
112732 +
112733 + code = gimple_code(stmt);
112734 +
112735 + if (code == GIMPLE_ASM)
112736 + head = handle_stmt_by_size_overflow_asm(stmt, head);
112737 +
112738 + if (!next_node)
112739 + continue;
112740 + if (code == GIMPLE_CALL)
112741 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
112742 + if (code == GIMPLE_RETURN)
112743 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
112744 + }
112745 + }
112746 + return head;
112747 +}
112748 +
112749 +static void set_current_function_decl(tree fndecl)
112750 +{
112751 + gcc_assert(fndecl != NULL_TREE);
112752 +
112753 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
112754 + calculate_dominance_info(CDI_DOMINATORS);
112755 + current_function_decl = fndecl;
112756 +}
112757 +
112758 +static void unset_current_function_decl(void)
112759 +{
112760 + free_dominance_info(CDI_DOMINATORS);
112761 + pop_cfun();
112762 + current_function_decl = NULL_TREE;
112763 +}
112764 +
112765 +static void free_interesting_node(struct interesting_node *head)
112766 +{
112767 + struct interesting_node *cur;
112768 +
112769 + while (head) {
112770 + cur = head->next;
112771 +#if BUILDING_GCC_VERSION <= 4007
112772 + VEC_free(tree, gc, head->last_nodes);
112773 +#else
112774 + vec_free(head->last_nodes);
112775 +#endif
112776 + free(head);
112777 + head = cur;
112778 + }
112779 +}
112780 +
112781 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
112782 +{
112783 + struct visited *new_visited;
112784 +
112785 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
112786 + new_visited->fndecl = cur_node->fndecl;
112787 + new_visited->num = cur_node->num;
112788 + new_visited->first_stmt = cur_node->first_stmt;
112789 + new_visited->next = NULL;
112790 +
112791 + if (!head)
112792 + return new_visited;
112793 +
112794 + new_visited->next = head;
112795 + return new_visited;
112796 +}
112797 +
112798 +/* 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
112799 + * it is a visited function.
112800 + */
112801 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
112802 +{
112803 + struct visited *cur;
112804 +
112805 + if (!head)
112806 + return false;
112807 +
112808 + for (cur = head; cur; cur = cur->next) {
112809 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
112810 + continue;
112811 + if (cur_node->num != cur->num)
112812 + continue;
112813 + if (cur_node->first_stmt == cur->first_stmt)
112814 + return true;
112815 + }
112816 + return false;
112817 +}
112818 +
112819 +static void free_next_cgraph_node(struct next_cgraph_node *head)
112820 +{
112821 + struct next_cgraph_node *cur;
112822 +
112823 + while (head) {
112824 + cur = head->next;
112825 + free(head);
112826 + head = cur;
112827 + }
112828 +}
112829 +
112830 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
112831 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
112832 + * the newly collected interesting functions (they are interesting if there is control flow between
112833 + * the interesting stmts and them).
112834 + */
112835 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
112836 +{
112837 + struct interesting_node *head, *cur_node;
112838 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
112839 +
112840 +#if BUILDING_GCC_VERSION <= 4007
112841 + set_current_function_decl(node->decl);
112842 +#else
112843 + set_current_function_decl(node->symbol.decl);
112844 +#endif
112845 + call_count = 0;
112846 +
112847 + head = collect_interesting_stmts(next_node);
112848 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
112849 + if (is_visited_function(visited, cur_node))
112850 + continue;
112851 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
112852 + visited = insert_visited_function(visited, cur_node);
112853 + }
112854 +
112855 + free_interesting_node(head);
112856 + unset_current_function_decl();
112857 +
112858 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
112859 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
112860 +
112861 + free_next_cgraph_node(cnodes_head);
112862 + return visited;
112863 +}
112864 +
112865 +static void free_visited(struct visited *head)
112866 +{
112867 + struct visited *cur;
112868 +
112869 + while (head) {
112870 + cur = head->next;
112871 + free(head);
112872 + head = cur;
112873 + }
112874 +}
112875 +
112876 +// erase the local flag
112877 +static void set_plf_false(void)
112878 +{
112879 + basic_block bb;
112880 +
112881 + FOR_ALL_BB(bb) {
112882 + gimple_stmt_iterator si;
112883 +
112884 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
112885 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
112886 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
112887 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
112888 + }
112889 +}
112890 +
112891 +#if BUILDING_GCC_VERSION <= 4006
112892 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
112893 +{
112894 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
112895 +}
112896 +
112897 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
112898 +{
112899 + struct cgraph_node *node;
112900 +
112901 + for (node = cgraph_nodes; node; node = node->next) {
112902 + if (cgraph_function_with_gimple_body_p(node))
112903 + return node;
112904 + }
112905 + return NULL;
112906 +}
112907 +
112908 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
112909 +{
112910 + for (node = node->next; node; node = node->next) {
112911 + if (cgraph_function_with_gimple_body_p(node))
112912 + return node;
112913 + }
112914 + return NULL;
112915 +}
112916 +
112917 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
112918 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
112919 + (node) = cgraph_next_function_with_gimple_body (node))
112920 +
112921 +#endif
112922 +
112923 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
112924 +static unsigned int search_function(void)
112925 +{
112926 + struct cgraph_node *node;
112927 + struct visited *visited = NULL;
112928 +
112929 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
112930 +#if BUILDING_GCC_VERSION <= 4007
112931 + set_current_function_decl(node->decl);
112932 +#else
112933 + set_current_function_decl(node->symbol.decl);
112934 +#endif
112935 + set_plf_false();
112936 + unset_current_function_decl();
112937 + }
112938 +
112939 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
112940 + gcc_assert(cgraph_function_flags_ready);
112941 +#if BUILDING_GCC_VERSION <= 4007
112942 + gcc_assert(node->reachable);
112943 +#endif
112944 +
112945 + visited = handle_function(node, NULL, visited);
112946 + }
112947 +
112948 + free_visited(visited);
112949 + return 0;
112950 +}
112951 +
112952 +static struct ipa_opt_pass_d pass_ipa = {
112953 + .pass = {
112954 + .type = SIMPLE_IPA_PASS,
112955 + .name = "size_overflow",
112956 +#if BUILDING_GCC_VERSION >= 4008
112957 + .optinfo_flags = OPTGROUP_NONE,
112958 +#endif
112959 + .gate = NULL,
112960 + .execute = search_function,
112961 + .sub = NULL,
112962 + .next = NULL,
112963 + .static_pass_number = 0,
112964 + .tv_id = TV_NONE,
112965 + .properties_required = 0,
112966 + .properties_provided = 0,
112967 + .properties_destroyed = 0,
112968 + .todo_flags_start = 0,
112969 + .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,
112970 + },
112971 + .generate_summary = NULL,
112972 + .write_summary = NULL,
112973 + .read_summary = NULL,
112974 +#if BUILDING_GCC_VERSION >= 4006
112975 + .write_optimization_summary = NULL,
112976 + .read_optimization_summary = NULL,
112977 +#endif
112978 + .stmt_fixup = NULL,
112979 + .function_transform_todo_flags_start = 0,
112980 + .function_transform = NULL,
112981 + .variable_transform = NULL,
112982 +};
112983 +
112984 +// data for the size_overflow asm stmt
112985 +struct asm_data {
112986 + gimple def_stmt;
112987 + tree input;
112988 + tree output;
112989 +};
112990 +
112991 +#if BUILDING_GCC_VERSION <= 4007
112992 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
112993 +#else
112994 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
112995 +#endif
112996 +{
112997 + tree list;
112998 +#if BUILDING_GCC_VERSION <= 4007
112999 + VEC(tree, gc) *vec_list = NULL;
113000 +#else
113001 + vec<tree, va_gc> *vec_list = NULL;
113002 +#endif
113003 +
113004 + list = build_tree_list(NULL_TREE, string);
113005 + list = chainon(NULL_TREE, build_tree_list(list, io));
113006 +#if BUILDING_GCC_VERSION <= 4007
113007 + VEC_safe_push(tree, gc, vec_list, list);
113008 +#else
113009 + vec_safe_push(vec_list, list);
113010 +#endif
113011 + return vec_list;
113012 +}
113013 +
113014 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
113015 +{
113016 + gimple asm_stmt;
113017 + gimple_stmt_iterator gsi;
113018 +#if BUILDING_GCC_VERSION <= 4007
113019 + VEC(tree, gc) *input, *output = NULL;
113020 +#else
113021 + vec<tree, va_gc> *input, *output = NULL;
113022 +#endif
113023 +
113024 + input = create_asm_io_list(str_input, asm_data->input);
113025 +
113026 + if (asm_data->output)
113027 + output = create_asm_io_list(str_output, asm_data->output);
113028 +
113029 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
113030 + gsi = gsi_for_stmt(asm_data->def_stmt);
113031 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
113032 +
113033 + if (asm_data->output)
113034 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
113035 +}
113036 +
113037 +static void replace_call_lhs(const struct asm_data *asm_data)
113038 +{
113039 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
113040 + update_stmt(asm_data->def_stmt);
113041 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
113042 +}
113043 +
113044 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
113045 +{
113046 + enum mark cur_fndecl_attr;
113047 + gimple phi = get_def_stmt(result);
113048 + unsigned int i, n = gimple_phi_num_args(phi);
113049 +
113050 + pointer_set_insert(visited, phi);
113051 + for (i = 0; i < n; i++) {
113052 + tree arg = gimple_phi_arg_def(phi, i);
113053 +
113054 + cur_fndecl_attr = search_intentional(visited, arg);
113055 + if (cur_fndecl_attr != MARK_NO)
113056 + return cur_fndecl_attr;
113057 + }
113058 + return MARK_NO;
113059 +}
113060 +
113061 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
113062 +{
113063 + enum mark cur_fndecl_attr;
113064 + const_tree rhs1, rhs2;
113065 + gimple def_stmt = get_def_stmt(lhs);
113066 +
113067 + rhs1 = gimple_assign_rhs1(def_stmt);
113068 + rhs2 = gimple_assign_rhs2(def_stmt);
113069 +
113070 + cur_fndecl_attr = search_intentional(visited, rhs1);
113071 + if (cur_fndecl_attr != MARK_NO)
113072 + return cur_fndecl_attr;
113073 + return search_intentional(visited, rhs2);
113074 +}
113075 +
113076 +// Look up the intentional_overflow attribute on the caller and the callee functions.
113077 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
113078 +{
113079 + const_gimple def_stmt;
113080 +
113081 + if (TREE_CODE(lhs) != SSA_NAME)
113082 + return get_intentional_attr_type(lhs);
113083 +
113084 + def_stmt = get_def_stmt(lhs);
113085 + if (!def_stmt)
113086 + return MARK_NO;
113087 +
113088 + if (pointer_set_contains(visited, def_stmt))
113089 + return MARK_NO;
113090 +
113091 + switch (gimple_code(def_stmt)) {
113092 + case GIMPLE_NOP:
113093 + return search_intentional(visited, SSA_NAME_VAR(lhs));
113094 + case GIMPLE_ASM:
113095 + case GIMPLE_CALL:
113096 + return MARK_NO;
113097 + case GIMPLE_PHI:
113098 + return search_intentional_phi(visited, lhs);
113099 + case GIMPLE_ASSIGN:
113100 + switch (gimple_num_ops(def_stmt)) {
113101 + case 2:
113102 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
113103 + case 3:
113104 + return search_intentional_binary(visited, lhs);
113105 + }
113106 + case GIMPLE_RETURN:
113107 + return MARK_NO;
113108 + default:
113109 + debug_gimple_stmt((gimple)def_stmt);
113110 + error("%s: unknown gimple code", __func__);
113111 + gcc_unreachable();
113112 + }
113113 +}
113114 +
113115 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
113116 +static const char *check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
113117 +{
113118 + const_tree fndecl;
113119 + const char *asm_str;
113120 + struct pointer_set_t *visited;
113121 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
113122 +
113123 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
113124 + if (is_end_intentional_intentional_attr(fndecl, argnum))
113125 + decl_attr = MARK_NOT_INTENTIONAL;
113126 + else if (is_yes_intentional_attr(fndecl, argnum))
113127 + decl_attr = MARK_YES;
113128 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113129 + return "# size_overflow MARK_TURN_OFF\n\t";
113130 + }
113131 +
113132 + visited = pointer_set_create();
113133 + cur_fndecl_attr = search_intentional(visited, arg);
113134 + pointer_set_destroy(visited);
113135 +
113136 + switch (cur_fndecl_attr) {
113137 + case MARK_NO:
113138 + asm_str = "# size_overflow\n\t";
113139 + break;
113140 + case MARK_TURN_OFF:
113141 + asm_str = "# size_overflow MARK_TURN_OFF\n\t";
113142 + break;
113143 + default:
113144 + asm_str = "# size_overflow MARK_YES\n\t";
113145 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
113146 + break;
113147 + }
113148 +
113149 + return asm_str;
113150 +}
113151 +
113152 +static void check_missing_size_overflow_attribute(tree var)
113153 +{
113154 + tree orig_fndecl;
113155 + unsigned int num;
113156 +
113157 + if (is_a_return_check(var))
113158 + orig_fndecl = DECL_ORIGIN(var);
113159 + else
113160 + orig_fndecl = DECL_ORIGIN(current_function_decl);
113161 +
113162 + num = get_function_num(var, orig_fndecl);
113163 + if (num == CANNOT_FIND_ARG)
113164 + return;
113165 +
113166 + is_missing_function(orig_fndecl, num);
113167 +}
113168 +
113169 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
113170 +{
113171 + gimple phi = get_def_stmt(result);
113172 + unsigned int i, n = gimple_phi_num_args(phi);
113173 +
113174 + pointer_set_insert(visited, phi);
113175 + for (i = 0; i < n; i++) {
113176 + tree arg = gimple_phi_arg_def(phi, i);
113177 +
113178 + search_size_overflow_attribute(visited, arg);
113179 + }
113180 +}
113181 +
113182 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
113183 +{
113184 + const_gimple def_stmt = get_def_stmt(lhs);
113185 + tree rhs1, rhs2;
113186 +
113187 + rhs1 = gimple_assign_rhs1(def_stmt);
113188 + rhs2 = gimple_assign_rhs2(def_stmt);
113189 +
113190 + search_size_overflow_attribute(visited, rhs1);
113191 + search_size_overflow_attribute(visited, rhs2);
113192 +}
113193 +
113194 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
113195 +{
113196 + const_gimple def_stmt;
113197 +
113198 + if (TREE_CODE(lhs) == PARM_DECL) {
113199 + check_missing_size_overflow_attribute(lhs);
113200 + return;
113201 + }
113202 +
113203 + def_stmt = get_def_stmt(lhs);
113204 + if (!def_stmt)
113205 + return;
113206 +
113207 + if (pointer_set_insert(visited, def_stmt))
113208 + return;
113209 +
113210 + switch (gimple_code(def_stmt)) {
113211 + case GIMPLE_NOP:
113212 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
113213 + case GIMPLE_ASM:
113214 + return;
113215 + case GIMPLE_CALL: {
113216 + tree fndecl = gimple_call_fndecl(def_stmt);
113217 +
113218 + if (fndecl == NULL_TREE)
113219 + return;
113220 + check_missing_size_overflow_attribute(fndecl);
113221 + return;
113222 + }
113223 + case GIMPLE_PHI:
113224 + return search_size_overflow_attribute_phi(visited, lhs);
113225 + case GIMPLE_ASSIGN:
113226 + switch (gimple_num_ops(def_stmt)) {
113227 + case 2:
113228 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
113229 + case 3:
113230 + return search_size_overflow_attribute_binary(visited, lhs);
113231 + }
113232 + default:
113233 + debug_gimple_stmt((gimple)def_stmt);
113234 + error("%s: unknown gimple code", __func__);
113235 + gcc_unreachable();
113236 + }
113237 +}
113238 +
113239 +// Search missing entries in the hash table (invoked from the gimple pass)
113240 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
113241 +{
113242 + tree fndecl = NULL_TREE;
113243 + tree lhs;
113244 + struct pointer_set_t *visited;
113245 +
113246 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
113247 + return;
113248 +
113249 + if (num == 0) {
113250 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
113251 + lhs = gimple_return_retval(stmt);
113252 + } else {
113253 + gcc_assert(is_gimple_call(stmt));
113254 + lhs = gimple_call_arg(stmt, num - 1);
113255 + fndecl = gimple_call_fndecl(stmt);
113256 + }
113257 +
113258 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
113259 + return;
113260 +
113261 + visited = pointer_set_create();
113262 + search_size_overflow_attribute(visited, lhs);
113263 + pointer_set_destroy(visited);
113264 +}
113265 +
113266 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113267 +{
113268 + gimple_stmt_iterator gsi;
113269 + gimple assign;
113270 +
113271 + assign = gimple_build_assign(asm_data->input, asm_data->output);
113272 + gsi = gsi_for_stmt(stmt);
113273 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
113274 + asm_data->def_stmt = assign;
113275 +
113276 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
113277 + asm_data->output = make_ssa_name(asm_data->output, stmt);
113278 + if (gimple_code(stmt) == GIMPLE_RETURN)
113279 + gimple_return_set_retval(stmt, asm_data->output);
113280 + else
113281 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
113282 + update_stmt(stmt);
113283 +}
113284 +
113285 +/* Create the input of the size_overflow asm stmt.
113286 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
113287 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113288 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
113289 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
113290 + */
113291 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113292 +{
113293 + if (!asm_data->def_stmt) {
113294 + asm_data->input = NULL_TREE;
113295 + return;
113296 + }
113297 +
113298 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
113299 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
113300 +
113301 + switch (gimple_code(asm_data->def_stmt)) {
113302 + case GIMPLE_ASSIGN:
113303 + case GIMPLE_CALL:
113304 + replace_call_lhs(asm_data);
113305 + break;
113306 + case GIMPLE_PHI:
113307 + create_output_from_phi(stmt, argnum, asm_data);
113308 + break;
113309 + case GIMPLE_NOP: {
113310 + const char *str = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
113311 +
113312 + asm_data->input = asm_data->output;
113313 + asm_data->output = NULL;
113314 + asm_data->def_stmt = stmt;
113315 +
113316 + create_asm_stmt(str, build_string(2, "rm"), NULL, asm_data);
113317 + asm_data->input = NULL_TREE;
113318 + break;
113319 + }
113320 + case GIMPLE_ASM:
113321 + if (is_size_overflow_asm(asm_data->def_stmt)) {
113322 + asm_data->input = NULL_TREE;
113323 + break;
113324 + }
113325 + default:
113326 + debug_gimple_stmt(asm_data->def_stmt);
113327 + gcc_unreachable();
113328 + }
113329 +}
113330 +
113331 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
113332 + * is of the right kind create the appropriate size_overflow asm stmts:
113333 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
113334 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113335 + */
113336 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
113337 +{
113338 + struct asm_data asm_data;
113339 + const char *str;
113340 +
113341 + if (is_gimple_constant(output_node))
113342 + return;
113343 +
113344 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
113345 +
113346 + asm_data.output = output_node;
113347 + asm_data.def_stmt = get_def_stmt(asm_data.output);
113348 + create_asm_input(stmt, argnum, &asm_data);
113349 + if (asm_data.input == NULL_TREE)
113350 + return;
113351 +
113352 + str = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
113353 + create_asm_stmt(str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
113354 +}
113355 +
113356 +// Determine the return value and insert the asm stmt to mark the return stmt.
113357 +static void insert_asm_ret(gimple stmt)
113358 +{
113359 + tree ret;
113360 +
113361 + ret = gimple_return_retval(stmt);
113362 + create_size_overflow_asm(stmt, ret, 0);
113363 +}
113364 +
113365 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
113366 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
113367 +{
113368 + tree arg;
113369 + unsigned int argnum;
113370 +
113371 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
113372 + gcc_assert(argnum != 0);
113373 + if (argnum == CANNOT_FIND_ARG)
113374 + return;
113375 +
113376 + arg = gimple_call_arg(stmt, argnum - 1);
113377 + gcc_assert(arg != NULL_TREE);
113378 + create_size_overflow_asm(stmt, arg, argnum);
113379 +}
113380 +
113381 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
113382 +static void set_argnum_attribute(const_tree attr, bool *argnums)
113383 +{
113384 + unsigned int argnum;
113385 + tree attr_value;
113386 +
113387 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
113388 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
113389 + argnums[argnum] = true;
113390 + }
113391 +}
113392 +
113393 +// If a function arg or the return value is in the hash table then set its index in the array.
113394 +static void set_argnum_hash(tree fndecl, bool *argnums)
113395 +{
113396 + unsigned int num;
113397 + const struct size_overflow_hash *hash;
113398 +
113399 + hash = get_function_hash(DECL_ORIGIN(fndecl));
113400 + if (!hash)
113401 + return;
113402 +
113403 + for (num = 0; num <= MAX_PARAM; num++) {
113404 + if (!(hash->param & (1U << num)))
113405 + continue;
113406 +
113407 + argnums[num] = true;
113408 + }
113409 +}
113410 +
113411 +static bool is_all_the_argnums_empty(bool *argnums)
113412 +{
113413 + unsigned int i;
113414 +
113415 + for (i = 0; i <= MAX_PARAM; i++)
113416 + if (argnums[i])
113417 + return false;
113418 + return true;
113419 +}
113420 +
113421 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
113422 +static void search_interesting_args(tree fndecl, bool *argnums)
113423 +{
113424 + const_tree attr;
113425 +
113426 + set_argnum_hash(fndecl, argnums);
113427 + if (!is_all_the_argnums_empty(argnums))
113428 + return;
113429 +
113430 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
113431 + if (attr && TREE_VALUE(attr))
113432 + set_argnum_attribute(attr, argnums);
113433 +}
113434 +
113435 +/*
113436 + * Look up the intentional_overflow attribute that turns off ipa based duplication
113437 + * on the callee function, if found insert an asm stmt with "MARK_TURN_OFF".
113438 + */
113439 +static bool create_mark_turn_off_asm(gimple stmt)
113440 +{
113441 + enum mark mark;
113442 + struct asm_data asm_data;
113443 + const_tree fndecl = gimple_call_fndecl(stmt);
113444 +
113445 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
113446 + if (mark != MARK_TURN_OFF)
113447 + return false;
113448 +
113449 + asm_data.input = gimple_call_lhs(stmt);
113450 + if (asm_data.input == NULL_TREE) {
113451 + asm_data.input = gimple_call_arg(stmt, 0);
113452 + if (is_gimple_constant(asm_data.input))
113453 + return false;
113454 + }
113455 +
113456 + asm_data.output = NULL;
113457 + asm_data.def_stmt = stmt;
113458 + create_asm_stmt("# size_overflow MARK_TURN_OFF\n\t", build_string(2, "rm"), NULL, &asm_data);
113459 + return true;
113460 +}
113461 +
113462 +// 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
113463 +static void handle_interesting_function(gimple stmt)
113464 +{
113465 + unsigned int argnum;
113466 + tree fndecl;
113467 + bool orig_argnums[MAX_PARAM + 1] = {false};
113468 +
113469 + if (gimple_call_num_args(stmt) == 0)
113470 + return;
113471 + fndecl = gimple_call_fndecl(stmt);
113472 + if (fndecl == NULL_TREE)
113473 + return;
113474 + fndecl = DECL_ORIGIN(fndecl);
113475 +
113476 + if (create_mark_turn_off_asm(stmt))
113477 + return;
113478 +
113479 + search_interesting_args(fndecl, orig_argnums);
113480 +
113481 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
113482 + if (orig_argnums[argnum])
113483 + insert_asm_arg(stmt, argnum);
113484 +}
113485 +
113486 +// 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
113487 +static void handle_interesting_ret(gimple stmt)
113488 +{
113489 + bool orig_argnums[MAX_PARAM + 1] = {false};
113490 +
113491 + search_interesting_args(current_function_decl, orig_argnums);
113492 +
113493 + if (orig_argnums[0])
113494 + insert_asm_ret(stmt);
113495 +}
113496 +
113497 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
113498 +static unsigned int search_interesting_functions(void)
113499 +{
113500 + basic_block bb;
113501 +
113502 + FOR_ALL_BB(bb) {
113503 + gimple_stmt_iterator gsi;
113504 +
113505 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113506 + gimple stmt = gsi_stmt(gsi);
113507 +
113508 + if (is_gimple_call(stmt))
113509 + handle_interesting_function(stmt);
113510 + else if (gimple_code(stmt) == GIMPLE_RETURN)
113511 + handle_interesting_ret(stmt);
113512 + }
113513 + }
113514 + return 0;
113515 +}
113516 +
113517 +/*
113518 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
113519 + * this pass inserts asm stmts to mark the interesting args
113520 + * that the ipa pass will detect and insert the size overflow checks for.
113521 + */
113522 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
113523 + .pass = {
113524 + .type = GIMPLE_PASS,
113525 + .name = "insert_size_overflow_asm",
113526 +#if BUILDING_GCC_VERSION >= 4008
113527 + .optinfo_flags = OPTGROUP_NONE,
113528 +#endif
113529 + .gate = NULL,
113530 + .execute = search_interesting_functions,
113531 + .sub = NULL,
113532 + .next = NULL,
113533 + .static_pass_number = 0,
113534 + .tv_id = TV_NONE,
113535 + .properties_required = PROP_cfg,
113536 + .properties_provided = 0,
113537 + .properties_destroyed = 0,
113538 + .todo_flags_start = 0,
113539 + .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
113540 + }
113541 +};
113542 +
113543 +// Create the noreturn report_size_overflow() function decl.
113544 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
113545 +{
113546 + tree fntype;
113547 +
113548 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
113549 +
113550 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
113551 + fntype = build_function_type_list(void_type_node,
113552 + const_char_ptr_type_node,
113553 + unsigned_type_node,
113554 + const_char_ptr_type_node,
113555 + const_char_ptr_type_node,
113556 + NULL_TREE);
113557 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
113558 +
113559 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
113560 + TREE_PUBLIC(report_size_overflow_decl) = 1;
113561 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
113562 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
113563 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
113564 +}
113565 +
113566 +static unsigned int dump_functions(void)
113567 +{
113568 + struct cgraph_node *node;
113569 +
113570 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113571 + basic_block bb;
113572 +
113573 +#if BUILDING_GCC_VERSION <= 4007
113574 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
113575 + current_function_decl = node->decl;
113576 +#else
113577 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
113578 + current_function_decl = node->symbol.decl;
113579 +#endif
113580 +
113581 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
113582 +
113583 + FOR_ALL_BB(bb) {
113584 + gimple_stmt_iterator si;
113585 +
113586 + fprintf(stderr, "<bb %u>:\n", bb->index);
113587 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113588 + debug_gimple_stmt(gsi_stmt(si));
113589 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113590 + debug_gimple_stmt(gsi_stmt(si));
113591 + fprintf(stderr, "\n");
113592 + }
113593 +
113594 + fprintf(stderr, "-------------------------------------------------------------------------\n");
113595 +
113596 + pop_cfun();
113597 + current_function_decl = NULL_TREE;
113598 + }
113599 +
113600 + fprintf(stderr, "###############################################################################\n");
113601 +
113602 + return 0;
113603 +}
113604 +
113605 +static struct ipa_opt_pass_d pass_dump = {
113606 + .pass = {
113607 + .type = SIMPLE_IPA_PASS,
113608 + .name = "dump",
113609 +#if BUILDING_GCC_VERSION >= 4008
113610 + .optinfo_flags = OPTGROUP_NONE,
113611 +#endif
113612 + .gate = NULL,
113613 + .execute = dump_functions,
113614 + .sub = NULL,
113615 + .next = NULL,
113616 + .static_pass_number = 0,
113617 + .tv_id = TV_NONE,
113618 + .properties_required = 0,
113619 + .properties_provided = 0,
113620 + .properties_destroyed = 0,
113621 + .todo_flags_start = 0,
113622 + .todo_flags_finish = 0,
113623 + },
113624 + .generate_summary = NULL,
113625 + .write_summary = NULL,
113626 + .read_summary = NULL,
113627 +#if BUILDING_GCC_VERSION >= 4006
113628 + .write_optimization_summary = NULL,
113629 + .read_optimization_summary = NULL,
113630 +#endif
113631 + .stmt_fixup = NULL,
113632 + .function_transform_todo_flags_start = 0,
113633 + .function_transform = NULL,
113634 + .variable_transform = NULL,
113635 +};
113636 +
113637 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
113638 +{
113639 + int i;
113640 + const char * const plugin_name = plugin_info->base_name;
113641 + const int argc = plugin_info->argc;
113642 + const struct plugin_argument * const argv = plugin_info->argv;
113643 + bool enable = true;
113644 +
113645 + struct register_pass_info insert_size_overflow_asm_pass_info = {
113646 + .pass = &insert_size_overflow_asm_pass.pass,
113647 + .reference_pass_name = "ssa",
113648 + .ref_pass_instance_number = 1,
113649 + .pos_op = PASS_POS_INSERT_AFTER
113650 + };
113651 +
113652 + struct register_pass_info __unused dump_before_pass_info = {
113653 + .pass = &pass_dump.pass,
113654 + .reference_pass_name = "increase_alignment",
113655 + .ref_pass_instance_number = 1,
113656 + .pos_op = PASS_POS_INSERT_BEFORE
113657 + };
113658 +
113659 + struct register_pass_info ipa_pass_info = {
113660 + .pass = &pass_ipa.pass,
113661 + .reference_pass_name = "increase_alignment",
113662 + .ref_pass_instance_number = 1,
113663 + .pos_op = PASS_POS_INSERT_BEFORE
113664 + };
113665 +
113666 + struct register_pass_info __unused dump_after_pass_info = {
113667 + .pass = &pass_dump.pass,
113668 + .reference_pass_name = "increase_alignment",
113669 + .ref_pass_instance_number = 1,
113670 + .pos_op = PASS_POS_INSERT_BEFORE
113671 + };
113672 +
113673 + if (!plugin_default_version_check(version, &gcc_version)) {
113674 + error(G_("incompatible gcc/plugin versions"));
113675 + return 1;
113676 + }
113677 +
113678 + for (i = 0; i < argc; ++i) {
113679 + if (!strcmp(argv[i].key, "no-size-overflow")) {
113680 + enable = false;
113681 + continue;
113682 + }
113683 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
113684 + }
113685 +
113686 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
113687 + if (enable) {
113688 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
113689 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
113690 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
113691 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
113692 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
113693 + }
113694 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
113695 +
113696 + return 0;
113697 +}
113698 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
113699 new file mode 100644
113700 index 0000000..ac2901e
113701 --- /dev/null
113702 +++ b/tools/gcc/stackleak_plugin.c
113703 @@ -0,0 +1,327 @@
113704 +/*
113705 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
113706 + * Licensed under the GPL v2
113707 + *
113708 + * Note: the choice of the license means that the compilation process is
113709 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
113710 + * but for the kernel it doesn't matter since it doesn't link against
113711 + * any of the gcc libraries
113712 + *
113713 + * gcc plugin to help implement various PaX features
113714 + *
113715 + * - track lowest stack pointer
113716 + *
113717 + * TODO:
113718 + * - initialize all local variables
113719 + *
113720 + * BUGS:
113721 + * - none known
113722 + */
113723 +#include "gcc-plugin.h"
113724 +#include "config.h"
113725 +#include "system.h"
113726 +#include "coretypes.h"
113727 +#include "tree.h"
113728 +#include "tree-pass.h"
113729 +#include "flags.h"
113730 +#include "intl.h"
113731 +#include "toplev.h"
113732 +#include "plugin.h"
113733 +//#include "expr.h" where are you...
113734 +#include "diagnostic.h"
113735 +#include "plugin-version.h"
113736 +#include "tm.h"
113737 +#include "function.h"
113738 +#include "basic-block.h"
113739 +#include "gimple.h"
113740 +#include "rtl.h"
113741 +#include "emit-rtl.h"
113742 +
113743 +#if BUILDING_GCC_VERSION >= 4008
113744 +#define TODO_dump_func 0
113745 +#endif
113746 +
113747 +extern void print_gimple_stmt(FILE *, gimple, int, int);
113748 +
113749 +int plugin_is_GPL_compatible;
113750 +
113751 +static int track_frame_size = -1;
113752 +static const char track_function[] = "pax_track_stack";
113753 +static const char check_function[] = "pax_check_alloca";
113754 +static bool init_locals;
113755 +
113756 +static struct plugin_info stackleak_plugin_info = {
113757 + .version = "201302112000",
113758 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
113759 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
113760 +};
113761 +
113762 +static bool gate_stackleak_track_stack(void);
113763 +static unsigned int execute_stackleak_tree_instrument(void);
113764 +static unsigned int execute_stackleak_final(void);
113765 +
113766 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
113767 + .pass = {
113768 + .type = GIMPLE_PASS,
113769 + .name = "stackleak_tree_instrument",
113770 +#if BUILDING_GCC_VERSION >= 4008
113771 + .optinfo_flags = OPTGROUP_NONE,
113772 +#endif
113773 + .gate = gate_stackleak_track_stack,
113774 + .execute = execute_stackleak_tree_instrument,
113775 + .sub = NULL,
113776 + .next = NULL,
113777 + .static_pass_number = 0,
113778 + .tv_id = TV_NONE,
113779 + .properties_required = PROP_gimple_leh | PROP_cfg,
113780 + .properties_provided = 0,
113781 + .properties_destroyed = 0,
113782 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
113783 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
113784 + }
113785 +};
113786 +
113787 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
113788 + .pass = {
113789 + .type = RTL_PASS,
113790 + .name = "stackleak_final",
113791 +#if BUILDING_GCC_VERSION >= 4008
113792 + .optinfo_flags = OPTGROUP_NONE,
113793 +#endif
113794 + .gate = gate_stackleak_track_stack,
113795 + .execute = execute_stackleak_final,
113796 + .sub = NULL,
113797 + .next = NULL,
113798 + .static_pass_number = 0,
113799 + .tv_id = TV_NONE,
113800 + .properties_required = 0,
113801 + .properties_provided = 0,
113802 + .properties_destroyed = 0,
113803 + .todo_flags_start = 0,
113804 + .todo_flags_finish = TODO_dump_func
113805 + }
113806 +};
113807 +
113808 +static bool gate_stackleak_track_stack(void)
113809 +{
113810 + return track_frame_size >= 0;
113811 +}
113812 +
113813 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
113814 +{
113815 + gimple check_alloca;
113816 + tree fntype, fndecl, alloca_size;
113817 +
113818 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
113819 + fndecl = build_fn_decl(check_function, fntype);
113820 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
113821 +
113822 + // insert call to void pax_check_alloca(unsigned long size)
113823 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
113824 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
113825 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
113826 +}
113827 +
113828 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
113829 +{
113830 + gimple track_stack;
113831 + tree fntype, fndecl;
113832 +
113833 + fntype = build_function_type_list(void_type_node, NULL_TREE);
113834 + fndecl = build_fn_decl(track_function, fntype);
113835 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
113836 +
113837 + // insert call to void pax_track_stack(void)
113838 + track_stack = gimple_build_call(fndecl, 0);
113839 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
113840 +}
113841 +
113842 +#if BUILDING_GCC_VERSION == 4005
113843 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
113844 +{
113845 + tree fndecl;
113846 +
113847 + if (!is_gimple_call(stmt))
113848 + return false;
113849 + fndecl = gimple_call_fndecl(stmt);
113850 + if (!fndecl)
113851 + return false;
113852 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
113853 + return false;
113854 +// print_node(stderr, "pax", fndecl, 4);
113855 + return DECL_FUNCTION_CODE(fndecl) == code;
113856 +}
113857 +#endif
113858 +
113859 +static bool is_alloca(gimple stmt)
113860 +{
113861 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
113862 + return true;
113863 +
113864 +#if BUILDING_GCC_VERSION >= 4007
113865 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
113866 + return true;
113867 +#endif
113868 +
113869 + return false;
113870 +}
113871 +
113872 +static unsigned int execute_stackleak_tree_instrument(void)
113873 +{
113874 + basic_block bb, entry_bb;
113875 + bool prologue_instrumented = false, is_leaf = true;
113876 +
113877 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
113878 +
113879 + // 1. loop through BBs and GIMPLE statements
113880 + FOR_EACH_BB(bb) {
113881 + gimple_stmt_iterator gsi;
113882 +
113883 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113884 + gimple stmt;
113885 +
113886 + stmt = gsi_stmt(gsi);
113887 +
113888 + if (is_gimple_call(stmt))
113889 + is_leaf = false;
113890 +
113891 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
113892 + if (!is_alloca(stmt))
113893 + continue;
113894 +
113895 + // 2. insert stack overflow check before each __builtin_alloca call
113896 + stackleak_check_alloca(&gsi);
113897 +
113898 + // 3. insert track call after each __builtin_alloca call
113899 + stackleak_add_instrumentation(&gsi);
113900 + if (bb == entry_bb)
113901 + prologue_instrumented = true;
113902 + }
113903 + }
113904 +
113905 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
113906 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
113907 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
113908 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
113909 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
113910 + return 0;
113911 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
113912 + return 0;
113913 +
113914 + // 4. insert track call at the beginning
113915 + if (!prologue_instrumented) {
113916 + gimple_stmt_iterator gsi;
113917 +
113918 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
113919 + if (dom_info_available_p(CDI_DOMINATORS))
113920 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
113921 + gsi = gsi_start_bb(bb);
113922 + stackleak_add_instrumentation(&gsi);
113923 + }
113924 +
113925 + return 0;
113926 +}
113927 +
113928 +static unsigned int execute_stackleak_final(void)
113929 +{
113930 + rtx insn, next;
113931 +
113932 + if (cfun->calls_alloca)
113933 + return 0;
113934 +
113935 + // keep calls only if function frame is big enough
113936 + if (get_frame_size() >= track_frame_size)
113937 + return 0;
113938 +
113939 + // 1. find pax_track_stack calls
113940 + for (insn = get_insns(); insn; insn = next) {
113941 + // 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))
113942 + rtx body;
113943 +
113944 + next = NEXT_INSN(insn);
113945 + if (!CALL_P(insn))
113946 + continue;
113947 + body = PATTERN(insn);
113948 + if (GET_CODE(body) != CALL)
113949 + continue;
113950 + body = XEXP(body, 0);
113951 + if (GET_CODE(body) != MEM)
113952 + continue;
113953 + body = XEXP(body, 0);
113954 + if (GET_CODE(body) != SYMBOL_REF)
113955 + continue;
113956 + if (strcmp(XSTR(body, 0), track_function))
113957 + continue;
113958 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
113959 + // 2. delete call
113960 + delete_insn_and_edges(insn);
113961 +#if BUILDING_GCC_VERSION >= 4007
113962 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
113963 + insn = next;
113964 + next = NEXT_INSN(insn);
113965 + delete_insn_and_edges(insn);
113966 + }
113967 +#endif
113968 + }
113969 +
113970 +// print_simple_rtl(stderr, get_insns());
113971 +// print_rtl(stderr, get_insns());
113972 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
113973 +
113974 + return 0;
113975 +}
113976 +
113977 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
113978 +{
113979 + const char * const plugin_name = plugin_info->base_name;
113980 + const int argc = plugin_info->argc;
113981 + const struct plugin_argument * const argv = plugin_info->argv;
113982 + int i;
113983 + struct register_pass_info stackleak_tree_instrument_pass_info = {
113984 + .pass = &stackleak_tree_instrument_pass.pass,
113985 +// .reference_pass_name = "tree_profile",
113986 + .reference_pass_name = "optimized",
113987 + .ref_pass_instance_number = 1,
113988 + .pos_op = PASS_POS_INSERT_BEFORE
113989 + };
113990 + struct register_pass_info stackleak_final_pass_info = {
113991 + .pass = &stackleak_final_rtl_opt_pass.pass,
113992 + .reference_pass_name = "final",
113993 + .ref_pass_instance_number = 1,
113994 + .pos_op = PASS_POS_INSERT_BEFORE
113995 + };
113996 +
113997 + if (!plugin_default_version_check(version, &gcc_version)) {
113998 + error(G_("incompatible gcc/plugin versions"));
113999 + return 1;
114000 + }
114001 +
114002 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
114003 +
114004 + for (i = 0; i < argc; ++i) {
114005 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
114006 + if (!argv[i].value) {
114007 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114008 + continue;
114009 + }
114010 + track_frame_size = atoi(argv[i].value);
114011 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
114012 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114013 + continue;
114014 + }
114015 + if (!strcmp(argv[i].key, "initialize-locals")) {
114016 + if (argv[i].value) {
114017 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114018 + continue;
114019 + }
114020 + init_locals = true;
114021 + continue;
114022 + }
114023 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114024 + }
114025 +
114026 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
114027 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
114028 +
114029 + return 0;
114030 +}
114031 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
114032 new file mode 100644
114033 index 0000000..4fae911
114034 --- /dev/null
114035 +++ b/tools/gcc/structleak_plugin.c
114036 @@ -0,0 +1,277 @@
114037 +/*
114038 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
114039 + * Licensed under the GPL v2
114040 + *
114041 + * Note: the choice of the license means that the compilation process is
114042 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
114043 + * but for the kernel it doesn't matter since it doesn't link against
114044 + * any of the gcc libraries
114045 + *
114046 + * gcc plugin to forcibly initialize certain local variables that could
114047 + * otherwise leak kernel stack to userland if they aren't properly initialized
114048 + * by later code
114049 + *
114050 + * Homepage: http://pax.grsecurity.net/
114051 + *
114052 + * Usage:
114053 + * $ # for 4.5/4.6/C based 4.7
114054 + * $ 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
114055 + * $ # for C++ based 4.7/4.8+
114056 + * $ 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
114057 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
114058 + *
114059 + * TODO: eliminate redundant initializers
114060 + * increase type coverage
114061 + */
114062 +
114063 +#include "gcc-plugin.h"
114064 +#include "config.h"
114065 +#include "system.h"
114066 +#include "coretypes.h"
114067 +#include "tree.h"
114068 +#include "tree-pass.h"
114069 +#include "intl.h"
114070 +#include "plugin-version.h"
114071 +#include "tm.h"
114072 +#include "toplev.h"
114073 +#include "function.h"
114074 +#include "tree-flow.h"
114075 +#include "plugin.h"
114076 +#include "gimple.h"
114077 +#include "diagnostic.h"
114078 +#include "cfgloop.h"
114079 +#include "langhooks.h"
114080 +
114081 +#if BUILDING_GCC_VERSION >= 4008
114082 +#define TODO_dump_func 0
114083 +#endif
114084 +
114085 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
114086 +
114087 +// unused type flag in all versions 4.5-4.8
114088 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
114089 +
114090 +int plugin_is_GPL_compatible;
114091 +void debug_gimple_stmt(gimple gs);
114092 +
114093 +static struct plugin_info structleak_plugin_info = {
114094 + .version = "201304082245",
114095 + .help = "disable\tdo not activate plugin\n",
114096 +};
114097 +
114098 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
114099 +{
114100 + *no_add_attrs = true;
114101 +
114102 + // check for types? for now accept everything linux has to offer
114103 + if (TREE_CODE(*node) != FIELD_DECL)
114104 + return NULL_TREE;
114105 +
114106 + *no_add_attrs = false;
114107 + return NULL_TREE;
114108 +}
114109 +
114110 +static struct attribute_spec user_attr = {
114111 + .name = "user",
114112 + .min_length = 0,
114113 + .max_length = 0,
114114 + .decl_required = false,
114115 + .type_required = false,
114116 + .function_type_required = false,
114117 + .handler = handle_user_attribute,
114118 +#if BUILDING_GCC_VERSION >= 4007
114119 + .affects_type_identity = true
114120 +#endif
114121 +};
114122 +
114123 +static void register_attributes(void *event_data, void *data)
114124 +{
114125 + register_attribute(&user_attr);
114126 +// register_attribute(&force_attr);
114127 +}
114128 +
114129 +static tree get_field_type(tree field)
114130 +{
114131 + return strip_array_types(TREE_TYPE(field));
114132 +}
114133 +
114134 +static bool is_userspace_type(tree type)
114135 +{
114136 + tree field;
114137 +
114138 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
114139 + tree fieldtype = get_field_type(field);
114140 + enum tree_code code = TREE_CODE(fieldtype);
114141 +
114142 + if (code == RECORD_TYPE || code == UNION_TYPE)
114143 + if (is_userspace_type(fieldtype))
114144 + return true;
114145 +
114146 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
114147 + return true;
114148 + }
114149 + return false;
114150 +}
114151 +
114152 +static void finish_type(void *event_data, void *data)
114153 +{
114154 + tree type = (tree)event_data;
114155 +
114156 + if (TYPE_USERSPACE(type))
114157 + return;
114158 +
114159 + if (is_userspace_type(type))
114160 + TYPE_USERSPACE(type) = 1;
114161 +}
114162 +
114163 +static void initialize(tree var)
114164 +{
114165 + basic_block bb;
114166 + gimple_stmt_iterator gsi;
114167 + tree initializer;
114168 + gimple init_stmt;
114169 +
114170 + // this is the original entry bb before the forced split
114171 + // TODO: check further BBs in case more splits occured before us
114172 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
114173 +
114174 + // first check if the variable is already initialized, warn otherwise
114175 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114176 + gimple stmt = gsi_stmt(gsi);
114177 + tree rhs1;
114178 +
114179 + // we're looking for an assignment of a single rhs...
114180 + if (!gimple_assign_single_p(stmt))
114181 + continue;
114182 + rhs1 = gimple_assign_rhs1(stmt);
114183 +#if BUILDING_GCC_VERSION >= 4007
114184 + // ... of a non-clobbering expression...
114185 + if (TREE_CLOBBER_P(rhs1))
114186 + continue;
114187 +#endif
114188 + // ... to our variable...
114189 + if (gimple_get_lhs(stmt) != var)
114190 + continue;
114191 + // if it's an initializer then we're good
114192 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
114193 + return;
114194 + }
114195 +
114196 + // these aren't the 0days you're looking for
114197 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
114198 +
114199 + // build the initializer expression
114200 + initializer = build_constructor(TREE_TYPE(var), NULL);
114201 +
114202 + // build the initializer stmt
114203 + init_stmt = gimple_build_assign(var, initializer);
114204 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
114205 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
114206 + update_stmt(init_stmt);
114207 +}
114208 +
114209 +static unsigned int handle_function(void)
114210 +{
114211 + basic_block bb;
114212 + unsigned int ret = 0;
114213 + tree var;
114214 +
114215 +#if BUILDING_GCC_VERSION == 4005
114216 + tree vars;
114217 +#else
114218 + unsigned int i;
114219 +#endif
114220 +
114221 + // split the first bb where we can put the forced initializers
114222 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114223 + if (dom_info_available_p(CDI_DOMINATORS))
114224 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114225 +
114226 + // enumarate all local variables and forcibly initialize our targets
114227 +#if BUILDING_GCC_VERSION == 4005
114228 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
114229 + var = TREE_VALUE(vars);
114230 +#else
114231 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
114232 +#endif
114233 + tree type = TREE_TYPE(var);
114234 +
114235 + gcc_assert(DECL_P(var));
114236 + if (!auto_var_in_fn_p(var, current_function_decl))
114237 + continue;
114238 +
114239 + // only care about structure types
114240 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
114241 + continue;
114242 +
114243 + // if the type is of interest, examine the variable
114244 + if (TYPE_USERSPACE(type))
114245 + initialize(var);
114246 + }
114247 +
114248 + return ret;
114249 +}
114250 +
114251 +static struct gimple_opt_pass structleak_pass = {
114252 + .pass = {
114253 + .type = GIMPLE_PASS,
114254 + .name = "structleak",
114255 +#if BUILDING_GCC_VERSION >= 4008
114256 + .optinfo_flags = OPTGROUP_NONE,
114257 +#endif
114258 + .gate = NULL,
114259 + .execute = handle_function,
114260 + .sub = NULL,
114261 + .next = NULL,
114262 + .static_pass_number = 0,
114263 + .tv_id = TV_NONE,
114264 + .properties_required = PROP_cfg,
114265 + .properties_provided = 0,
114266 + .properties_destroyed = 0,
114267 + .todo_flags_start = 0,
114268 + .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
114269 + }
114270 +};
114271 +
114272 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114273 +{
114274 + int i;
114275 + const char * const plugin_name = plugin_info->base_name;
114276 + const int argc = plugin_info->argc;
114277 + const struct plugin_argument * const argv = plugin_info->argv;
114278 + bool enable = true;
114279 +
114280 + struct register_pass_info structleak_pass_info = {
114281 + .pass = &structleak_pass.pass,
114282 + .reference_pass_name = "ssa",
114283 + .ref_pass_instance_number = 1,
114284 + .pos_op = PASS_POS_INSERT_AFTER
114285 + };
114286 +
114287 + if (!plugin_default_version_check(version, &gcc_version)) {
114288 + error(G_("incompatible gcc/plugin versions"));
114289 + return 1;
114290 + }
114291 +
114292 + if (strcmp(lang_hooks.name, "GNU C")) {
114293 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
114294 + enable = false;
114295 + }
114296 +
114297 + for (i = 0; i < argc; ++i) {
114298 + if (!strcmp(argv[i].key, "disable")) {
114299 + enable = false;
114300 + continue;
114301 + }
114302 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114303 + }
114304 +
114305 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
114306 + if (enable) {
114307 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
114308 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
114309 + }
114310 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
114311 +
114312 + return 0;
114313 +}
114314 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
114315 index 3dba0a4..97175dc 100644
114316 --- a/tools/lib/lk/Makefile
114317 +++ b/tools/lib/lk/Makefile
114318 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
114319
114320 LIBFILE = liblk.a
114321
114322 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114323 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114324 EXTLIBS = -lelf -lpthread -lrt -lm
114325 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
114326 ALL_LDFLAGS = $(LDFLAGS)
114327 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
114328 index 6789d78..4afd019e 100644
114329 --- a/tools/perf/util/include/asm/alternative-asm.h
114330 +++ b/tools/perf/util/include/asm/alternative-asm.h
114331 @@ -5,4 +5,7 @@
114332
114333 #define altinstruction_entry #
114334
114335 + .macro pax_force_retaddr rip=0, reload=0
114336 + .endm
114337 +
114338 #endif
114339 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
114340 index 96b919d..c49bb74 100644
114341 --- a/tools/perf/util/include/linux/compiler.h
114342 +++ b/tools/perf/util/include/linux/compiler.h
114343 @@ -18,4 +18,12 @@
114344 #define __force
114345 #endif
114346
114347 +#ifndef __size_overflow
114348 +# define __size_overflow(...)
114349 +#endif
114350 +
114351 +#ifndef __intentional_overflow
114352 +# define __intentional_overflow(...)
114353 +#endif
114354 +
114355 #endif
114356 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
114357 index 1cf9ccb..b9236e2 100644
114358 --- a/virt/kvm/kvm_main.c
114359 +++ b/virt/kvm/kvm_main.c
114360 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
114361
114362 static cpumask_var_t cpus_hardware_enabled;
114363 static int kvm_usage_count = 0;
114364 -static atomic_t hardware_enable_failed;
114365 +static atomic_unchecked_t hardware_enable_failed;
114366
114367 struct kmem_cache *kvm_vcpu_cache;
114368 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
114369
114370 -static __read_mostly struct preempt_ops kvm_preempt_ops;
114371 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
114372 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
114373 +static struct preempt_ops kvm_preempt_ops = {
114374 + .sched_in = kvm_sched_in,
114375 + .sched_out = kvm_sched_out,
114376 +};
114377
114378 struct dentry *kvm_debugfs_dir;
114379
114380 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
114381 /* We can read the guest memory with __xxx_user() later on. */
114382 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
114383 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
114384 - !access_ok(VERIFY_WRITE,
114385 + !__access_ok(VERIFY_WRITE,
114386 (void __user *)(unsigned long)mem->userspace_addr,
114387 mem->memory_size)))
114388 goto out;
114389 @@ -1867,7 +1872,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
114390 return 0;
114391 }
114392
114393 -static struct file_operations kvm_vcpu_fops = {
114394 +static file_operations_no_const kvm_vcpu_fops __read_only = {
114395 .release = kvm_vcpu_release,
114396 .unlocked_ioctl = kvm_vcpu_ioctl,
114397 #ifdef CONFIG_COMPAT
114398 @@ -2550,7 +2555,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
114399 return 0;
114400 }
114401
114402 -static struct file_operations kvm_vm_fops = {
114403 +static file_operations_no_const kvm_vm_fops __read_only = {
114404 .release = kvm_vm_release,
114405 .unlocked_ioctl = kvm_vm_ioctl,
114406 #ifdef CONFIG_COMPAT
114407 @@ -2651,7 +2656,7 @@ out:
114408 return r;
114409 }
114410
114411 -static struct file_operations kvm_chardev_ops = {
114412 +static file_operations_no_const kvm_chardev_ops __read_only = {
114413 .unlocked_ioctl = kvm_dev_ioctl,
114414 .compat_ioctl = kvm_dev_ioctl,
114415 .llseek = noop_llseek,
114416 @@ -2677,7 +2682,7 @@ static void hardware_enable_nolock(void *junk)
114417
114418 if (r) {
114419 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
114420 - atomic_inc(&hardware_enable_failed);
114421 + atomic_inc_unchecked(&hardware_enable_failed);
114422 printk(KERN_INFO "kvm: enabling virtualization on "
114423 "CPU%d failed\n", cpu);
114424 }
114425 @@ -2731,10 +2736,10 @@ static int hardware_enable_all(void)
114426
114427 kvm_usage_count++;
114428 if (kvm_usage_count == 1) {
114429 - atomic_set(&hardware_enable_failed, 0);
114430 + atomic_set_unchecked(&hardware_enable_failed, 0);
114431 on_each_cpu(hardware_enable_nolock, NULL, 1);
114432
114433 - if (atomic_read(&hardware_enable_failed)) {
114434 + if (atomic_read_unchecked(&hardware_enable_failed)) {
114435 hardware_disable_all_nolock();
114436 r = -EBUSY;
114437 }
114438 @@ -3168,7 +3173,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
114439 kvm_arch_vcpu_put(vcpu);
114440 }
114441
114442 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114443 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114444 struct module *module)
114445 {
114446 int r;
114447 @@ -3215,7 +3220,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114448 if (!vcpu_align)
114449 vcpu_align = __alignof__(struct kvm_vcpu);
114450 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
114451 - 0, NULL);
114452 + SLAB_USERCOPY, NULL);
114453 if (!kvm_vcpu_cache) {
114454 r = -ENOMEM;
114455 goto out_free_3;
114456 @@ -3225,9 +3230,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114457 if (r)
114458 goto out_free;
114459
114460 + pax_open_kernel();
114461 kvm_chardev_ops.owner = module;
114462 kvm_vm_fops.owner = module;
114463 kvm_vcpu_fops.owner = module;
114464 + pax_close_kernel();
114465
114466 r = misc_register(&kvm_dev);
114467 if (r) {
114468 @@ -3237,9 +3244,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114469
114470 register_syscore_ops(&kvm_syscore_ops);
114471
114472 - kvm_preempt_ops.sched_in = kvm_sched_in;
114473 - kvm_preempt_ops.sched_out = kvm_sched_out;
114474 -
114475 r = kvm_init_debug();
114476 if (r) {
114477 printk(KERN_ERR "kvm: create debugfs files failed\n");